shell32/tests: Add tests for IShellDispatch::NameSpace.
Alexander Morozov
amorozov at etersoft.ru
Fri Jan 21 06:22:06 CST 2011
-------------- next part --------------
From fe62d9eccaccfc1cceeabfe5266a4c5f2beaf4ca Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov at etersoft.ru>
Date: Fri, 21 Jan 2011 01:26:13 +0300
Subject: [PATCH] shell32/tests: Add tests for IShellDispatch::NameSpace.
---
dlls/shell32/tests/Makefile.in | 1 +
dlls/shell32/tests/shelldispatch.c | 160 ++++++++++++++++++++++++++++++++++++
2 files changed, 161 insertions(+), 0 deletions(-)
create mode 100644 dlls/shell32/tests/shelldispatch.c
diff --git a/dlls/shell32/tests/Makefile.in b/dlls/shell32/tests/Makefile.in
index d6a942c..3399532 100644
--- a/dlls/shell32/tests/Makefile.in
+++ b/dlls/shell32/tests/Makefile.in
@@ -8,6 +8,7 @@ C_SRCS = \
ebrowser.c \
generated.c \
progman_dde.c \
+ shelldispatch.c \
shelllink.c \
shellole.c \
shellpath.c \
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
new file mode 100644
index 0000000..af526ba
--- /dev/null
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -0,0 +1,160 @@
+/*
+ * Unit tests for IShellDispatch
+ *
+ * Copyright 2010 Alexander Morozov for Etersoft
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+
+#include "shldisp.h"
+#include "wine/test.h"
+
+static void test_namespace(void)
+{
+ static const WCHAR program_filesW[] = {'P','r','o','g','r','a','m',' ',
+ 'F','i','l','e','s',0};
+ static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
+ static const WCHAR backslashW[] = {'\\',0};
+
+ static WCHAR tempW[MAX_PATH], curW[MAX_PATH];
+ HRESULT r;
+ IShellDispatch *sd;
+ Folder *folder;
+ VARIANT var;
+ BSTR title;
+ int len;
+
+ r = CoCreateInstance(&CLSID_Shell, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IShellDispatch, (LPVOID*)&sd);
+ if (r == REGDB_E_CLASSNOTREG) /* NT4 */
+ {
+ win_skip("skipping IShellDispatch tests\n");
+ return;
+ }
+ ok(SUCCEEDED(r), "CoCreateInstance failed: %08x\n", r);
+ if (FAILED(r))
+ return;
+
+ VariantInit(&var);
+ folder = (void*)0xdeadbeef;
+ r = IShellDispatch_NameSpace(sd, var, &folder);
+ todo_wine
+ ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r);
+ ok(folder == NULL, "expected NULL, got %p\n", folder);
+
+ V_VT(&var) = VT_I4;
+ V_I4(&var) = -1;
+ r = IShellDispatch_NameSpace(sd, var, &folder);
+ todo_wine
+ ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r);
+
+ V_VT(&var) = VT_I4;
+ V_I4(&var) = ssfPROGRAMFILES;
+ r = IShellDispatch_NameSpace(sd, var, &folder);
+ todo_wine
+ ok(r == S_OK, "IShellDispatch::NameSpace failed: %08x\n", r);
+ if (r == S_OK)
+ {
+ r = Folder_get_Title(folder, &title);
+ todo_wine
+ ok(r == S_OK, "Folder::get_Title failed: %08x\n", r);
+ if (r == S_OK)
+ {
+ todo_wine
+ ok(!lstrcmpW(title, program_filesW), "bad title\n");
+ SysFreeString(title);
+ }
+ Folder_Release(folder);
+ }
+
+ GetTempPathW(MAX_PATH, tempW);
+ GetCurrentDirectoryW(MAX_PATH, curW);
+ SetCurrentDirectoryW(tempW);
+ CreateDirectoryW(winetestW, NULL);
+ V_VT(&var) = VT_BSTR;
+ V_BSTR(&var) = SysAllocString(winetestW);
+ r = IShellDispatch_NameSpace(sd, var, &folder);
+ todo_wine
+ ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r);
+ SysFreeString(V_BSTR(&var));
+
+ GetFullPathNameW(winetestW, MAX_PATH, tempW, NULL);
+ V_VT(&var) = VT_BSTR;
+ V_BSTR(&var) = SysAllocString(tempW);
+ r = IShellDispatch_NameSpace(sd, var, &folder);
+ todo_wine
+ ok(r == S_OK, "IShellDispatch::NameSpace failed: %08x\n", r);
+ if (r == S_OK)
+ {
+ r = Folder_get_Title(folder, &title);
+ todo_wine
+ ok(r == S_OK, "Folder::get_Title failed: %08x\n", r);
+ if (r == S_OK)
+ {
+ todo_wine
+ ok(!lstrcmpW(title, winetestW), "bad title\n");
+ SysFreeString(title);
+ }
+ Folder_Release(folder);
+ }
+ SysFreeString(V_BSTR(&var));
+
+ len = lstrlenW(tempW);
+ if (len < MAX_PATH - 1)
+ {
+ lstrcatW(tempW, backslashW);
+ V_VT(&var) = VT_BSTR;
+ V_BSTR(&var) = SysAllocString(tempW);
+ r = IShellDispatch_NameSpace(sd, var, &folder);
+ todo_wine
+ ok(r == S_OK, "IShellDispatch::NameSpace failed: %08x\n", r);
+ if (r == S_OK)
+ {
+ r = Folder_get_Title(folder, &title);
+ todo_wine
+ ok(r == S_OK, "Folder::get_Title failed: %08x\n", r);
+ if (r == S_OK)
+ {
+ todo_wine
+ ok(!lstrcmpW(title, winetestW), "bad title\n");
+ SysFreeString(title);
+ }
+ Folder_Release(folder);
+ }
+ SysFreeString(V_BSTR(&var));
+ }
+
+ RemoveDirectoryW(winetestW);
+ SetCurrentDirectoryW(curW);
+ IShellDispatch_Release(sd);
+}
+
+START_TEST(shelldispatch)
+{
+ HRESULT r;
+
+ r = CoInitialize(NULL);
+ ok(SUCCEEDED(r), "CoInitialize failed: %08x\n", r);
+ if (FAILED(r))
+ return;
+
+ test_namespace();
+
+ CoUninitialize();
+}
--
1.7.3.4
More information about the wine-patches
mailing list