Zhiyi Zhang : shell32/tests: Add SHOpenFolderAndSelectItems() tests.
Alexandre Julliard
julliard at winehq.org
Fri Jul 15 14:44:42 CDT 2022
Module: wine
Branch: master
Commit: 7c60e6233aa7ff1bef8e2db69e685f40547a1bbf
URL: https://gitlab.winehq.org/wine/wine/-/commit/7c60e6233aa7ff1bef8e2db69e685f40547a1bbf
Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date: Mon Jul 11 12:19:52 2022 +0800
shell32/tests: Add SHOpenFolderAndSelectItems() tests.
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
dlls/shell32/tests/shlfolder.c | 100 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index da606a9e707..10a989e9ca4 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -81,6 +81,37 @@ static WCHAR *make_wstr(const char *str)
return ret;
}
+static BOOL check_window_exists(const char *name)
+{
+ HWND window = NULL;
+ int i;
+
+ for (i = 0; i < 10; i++)
+ {
+ if ((window = FindWindowA("ExplorerWClass", name))
+ || (window = FindWindowA("CabinetWClass", name)))
+ {
+ SendMessageA(window, WM_SYSCOMMAND, SC_CLOSE, 0);
+ break;
+ }
+
+ Sleep(100);
+ }
+
+ if (!window)
+ return FALSE;
+
+ for (i = 0; i < 10; i++)
+ {
+ if (!IsWindow(window))
+ break;
+
+ Sleep(100);
+ }
+
+ return TRUE;
+}
+
static void init_function_pointers(void)
{
HMODULE hmod;
@@ -5410,6 +5441,74 @@ static void test_SHGetSetFolderCustomSettings(void)
RemoveDirectoryW(pathW);
}
+static void test_SHOpenFolderAndSelectItems(void)
+{
+ PIDLIST_ABSOLUTE folder, items[2];
+ HRESULT hr;
+
+ /* NULL folder */
+ hr = SHOpenFolderAndSelectItems(NULL, 0, NULL, 0);
+ todo_wine
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+
+ /* Open and select folder without child items */
+ folder = ILCreateFromPathW(L"C:\\Windows\\System32");
+ hr = SHOpenFolderAndSelectItems(folder, 0, NULL, 0);
+ todo_wine
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ todo_wine
+ ok(check_window_exists("Windows"), "Failed to create window.\n");
+ ILFree(folder);
+
+ /* Open folder and select one child item */
+ folder = ILCreateFromPathW(L"C:\\Windows");
+ items[0] = ILCreateFromPathW(L"C:\\Windows\\System32");
+ hr = SHOpenFolderAndSelectItems(folder, 1, (PCUITEMID_CHILD_ARRAY)items, 0);
+ todo_wine
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ todo_wine
+ ok(check_window_exists("Windows"), "Failed to create window.\n");
+ ILFree(items[0]);
+ ILFree(folder);
+
+ /* Open folder and select two child items */
+ folder = ILCreateFromPathW(L"C:\\Windows");
+ items[0] = ILCreateFromPathW(L"C:\\Windows\\System32");
+ items[1] = ILCreateFromPathW(L"C:\\Windows\\Resources");
+ hr = SHOpenFolderAndSelectItems(folder, 2, (PCUITEMID_CHILD_ARRAY)items, 0);
+ todo_wine
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ todo_wine
+ ok(check_window_exists("Windows"), "Failed to create window.\n");
+ ILFree(items[1]);
+ ILFree(items[0]);
+ ILFree(folder);
+
+ /* Open folder and select one child item with OFASI_EDIT */
+ folder = ILCreateFromPathW(L"C:\\Windows");
+ items[0] = ILCreateFromPathW(L"C:\\Windows\\System32");
+ hr = SHOpenFolderAndSelectItems(folder, 1, (PCUITEMID_CHILD_ARRAY)items, OFASI_EDIT);
+ todo_wine
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ todo_wine
+ ok(check_window_exists("Windows"), "Failed to create window.\n");
+ ILFree(items[0]);
+ ILFree(folder);
+
+ /* Open folder and select two child items and OFASI_EDIT */
+ folder = ILCreateFromPathW(L"C:\\Windows");
+ items[0] = ILCreateFromPathW(L"C:\\Windows\\System32");
+ items[1] = ILCreateFromPathW(L"C:\\Windows\\Resources");
+ hr = SHOpenFolderAndSelectItems(folder, 2, (PCUITEMID_CHILD_ARRAY)items, 0);
+ todo_wine
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ todo_wine
+ ok(check_window_exists("Windows"), "Failed to create window.\n");
+ ILFree(items[1]);
+ ILFree(items[0]);
+ ILFree(folder);
+}
+
START_TEST(shlfolder)
{
init_function_pointers();
@@ -5455,6 +5554,7 @@ START_TEST(shlfolder)
test_GetDefaultSearchGUID();
test_SHLimitInputEdit();
test_SHGetSetFolderCustomSettings();
+ test_SHOpenFolderAndSelectItems();
OleUninitialize();
}
More information about the wine-cvs
mailing list