[PATCH 3/5] shell32/tests: Add tests for FolderItems.

Alex Henrie alexhenrie24 at gmail.com
Mon Jul 4 00:25:04 CDT 2016


Cc: Christian Costa <titan.costa at gmail.com>
Cc: Sebastian Lackner <sebastian at fds-team.de>

I waited until the very end of the function to release items, items2,
and items3 so that in the future we can add tests for what happens if
these interfaces are used after the folder has been deleted.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/shell32/tests/shelldispatch.c | 137 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 136 insertions(+), 1 deletion(-)

diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index dfcbe6d..2a0f67b 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -31,6 +31,8 @@
 #define EXPECT_HR(hr,hr_exp) \
     ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
 
+static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
+
 static HRESULT (WINAPI *pSHGetFolderPathW)(HWND, int, HANDLE, DWORD, LPWSTR);
 static HRESULT (WINAPI *pSHGetNameFromIDList)(PCIDLIST_ABSOLUTE,SIGDN,PWSTR*);
 static HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *);
@@ -51,7 +53,6 @@ static void init_function_pointers(void)
 
 static void test_namespace(void)
 {
-    static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
     static const WCHAR backslashW[] = {'\\',0};
     static const WCHAR clsidW[] = {
         ':',':','{','6','4','5','F','F','0','4','0','-','5','0','8','1','-',
@@ -307,6 +308,139 @@ static void test_namespace(void)
     IShellDispatch_Release(sd);
 }
 
+static void test_items(void)
+{
+    WCHAR wstr[MAX_PATH], orig_dir[MAX_PATH];
+    HRESULT r;
+    IShellDispatch *sd = NULL;
+    Folder *folder = NULL;
+    FolderItems *items = NULL;
+    FolderItems2 *items2 = NULL;
+    FolderItems3 *items3 = NULL;
+    FolderItem *item = (FolderItem*)0xdeadbeef;
+    IDispatch *disp = NULL;
+    IUnknown *unk = NULL;
+    FolderItemVerbs *verbs = (FolderItemVerbs*)0xdeadbeef;
+    VARIANT var;
+    LONG lcount = -1;
+
+    r = CoCreateInstance(&CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, &IID_IShellDispatch, (void**)&sd);
+    ok(SUCCEEDED(r), "CoCreateInstance failed: %08x\n", r);
+    ok(!!sd, "sd is null\n");
+
+    GetTempPathW(MAX_PATH, wstr);
+    GetCurrentDirectoryW(MAX_PATH, orig_dir);
+    SetCurrentDirectoryW(wstr);
+    CreateDirectoryW(winetestW, NULL);
+    GetFullPathNameW(winetestW, MAX_PATH, wstr, NULL);
+    V_VT(&var) = VT_BSTR;
+    V_BSTR(&var) = SysAllocString(wstr);
+    r = IShellDispatch_NameSpace(sd, var, &folder);
+    ok(r == S_OK, "IShellDispatch::NameSpace failed: %08x\n", r);
+    ok(!!folder, "folder is null\n");
+    IShellDispatch_Release(sd);
+    SetCurrentDirectoryW(winetestW);
+
+    r = Folder_Items(folder, &items);
+    ok(r == S_OK, "Folder::Items failed: %08x\n", r);
+    ok(!!items, "items is null\n");
+    r = FolderItems_QueryInterface(items, &IID_FolderItems2, (void**)&items2);
+    ok(r == S_OK || broken(E_NOINTERFACE) /* xp and later */, "FolderItems::QueryInterface failed: %08x\n", r);
+    ok(!!items2 || broken(!items2) /* xp and later */, "items2 is null\n");
+    r = FolderItems_QueryInterface(items, &IID_FolderItems3, (void**)&items3);
+    ok(r == S_OK, "FolderItems::QueryInterface failed: %08x\n", r);
+    ok(!!items3, "items3 is null\n");
+    Folder_Release(folder);
+
+    if (0) /* crashes on all versions of Windows */
+    {
+        r = FolderItems_get_Count(items, NULL);
+todo_wine
+        ok(r == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", r);
+    }
+
+    r = FolderItems_get_Count(items, &lcount);
+todo_wine
+    ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r);
+todo_wine
+    ok(!lcount, "expected 0 files, got %d\n", lcount);
+
+    V_VT(&var) = VT_I4;
+    V_I4(&var) = 0;
+    r = FolderItems_Item(items, var, &item);
+todo_wine
+    ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r);
+todo_wine
+    ok(!item, "item is not null\n");
+
+    if (0) /* crashes on xp */
+    {
+        r = FolderItems_get_Application(items, NULL);
+todo_wine
+        ok(r == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", r);
+    }
+
+    r = FolderItems_get_Application(items, &disp);
+todo_wine
+    ok(r == S_OK, "FolderItems::get_Application failed: %08x\n", r);
+todo_wine
+    ok(!!disp, "disp is null\n");
+    if (disp) IDispatch_Release(disp);
+
+    if (0) /* crashes on xp */
+    {
+        r = FolderItems_get_Parent(items, NULL);
+        ok(r == E_NOTIMPL, "expected E_NOTIMPL, got %08x\n", r);
+    }
+
+    disp = (IDispatch*)0xdeadbeef;
+    r = FolderItems_get_Parent(items, &disp);
+    ok(r == E_NOTIMPL, "expected E_NOTIMPL, got %08x\n", r);
+todo_wine
+    ok(!disp, "disp is not null\n");
+
+    if (0) /* crashes on xp */
+    {
+        r = FolderItems__NewEnum(items, NULL);
+todo_wine
+        ok(r == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", r);
+    }
+
+    r = FolderItems__NewEnum(items, &unk);
+todo_wine
+    ok(r == S_OK, "FolderItems::_NewEnum failed: %08x\n", r);
+todo_wine
+    ok(!!unk, "unk is null\n");
+    if (unk) IUnknown_Release(unk);
+
+    if (items3)
+    {
+        r = FolderItems3_Filter(items3, 0, NULL);
+todo_wine
+        ok(r == S_OK, "expected S_OK, got %08x\n", r);
+
+        if (0) /* crashes on xp */
+        {
+            r = FolderItems3_get_Verbs(items3, NULL);
+todo_wine
+            ok(r == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", r);
+        }
+
+        r = FolderItems3_get_Verbs(items3, &verbs);
+todo_wine
+        ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r);
+todo_wine
+        ok(!verbs, "verbs is not null\n");
+    }
+
+    RemoveDirectoryW(winetestW);
+    SetCurrentDirectoryW(orig_dir);
+
+    FolderItems_Release(items);
+    if (items2) FolderItems2_Release(items2);
+    if (items3) FolderItems3_Release(items3);
+}
+
 static void test_service(void)
 {
     static const WCHAR spooler[] = {'S','p','o','o','l','e','r',0};
@@ -880,6 +1014,7 @@ START_TEST(shelldispatch)
 
     init_function_pointers();
     test_namespace();
+    test_items();
     test_service();
     test_ShellFolderViewDual();
     test_ShellWindows();
-- 
2.9.0




More information about the wine-patches mailing list