Reactos
at master 157 lines 4.7 kB view raw
1/* 2 * PROJECT: ReactOS api tests 3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 * PURPOSE: Tests for shdocvw!WinList_* functions 5 * COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6 */ 7 8#include <apitest.h> 9#include <shlobj.h> 10 11typedef BOOL (WINAPI *FN_WinList_Init)(VOID); 12typedef VOID (WINAPI *FN_WinList_Terminate)(VOID); 13typedef IShellWindows* (WINAPI *FN_WinList_GetShellWindows)(BOOL); 14 15static FN_WinList_Init g_pWinList_Init = NULL; 16static FN_WinList_Terminate g_pWinList_Terminate = NULL; 17static FN_WinList_GetShellWindows g_pWinList_GetShellWindows = NULL; 18 19static VOID 20TEST_WinList_GetShellWindows(VOID) 21{ 22 BOOL bInited = g_pWinList_Init && g_pWinList_Init(); 23 ok_int(bInited, FALSE); // WinList_Init should fail because this process is not explorer.exe 24 25 IShellWindows *pShellWindows1 = g_pWinList_GetShellWindows(FALSE); 26 trace("%p\n", pShellWindows1); 27 ok(pShellWindows1 != NULL, "pShellWindows1 was null\n"); 28 29 IShellWindows *pShellWindows2 = g_pWinList_GetShellWindows(FALSE); 30 trace("%p\n", pShellWindows2); 31 ok(pShellWindows2 != NULL, "pShellWindows2 was null\n"); 32 33 IShellWindows *pShellWindows3 = g_pWinList_GetShellWindows(TRUE); 34 trace("%p\n", pShellWindows3); 35 ok(pShellWindows3 != NULL, "pShellWindows3 was null\n"); 36 37 ok_ptr(pShellWindows1, pShellWindows2); 38 ok_ptr(pShellWindows2, pShellWindows3); 39 40 if (pShellWindows1) 41 { 42 LONG nCount = -1; 43 HRESULT hr = pShellWindows1->get_Count(&nCount); 44 ok_hex(hr, S_OK); 45 ok(nCount >= 0, "nCount was %ld\n", nCount); 46 trace("%ld\n", nCount); 47 48 pShellWindows1->Release(); 49 } 50 else 51 { 52 ok_int(TRUE, FALSE); 53 ok_int(TRUE, FALSE); 54 } 55 56 if (pShellWindows2) 57 pShellWindows2->Release(); 58 59 if (pShellWindows3) 60 pShellWindows3->Release(); 61 62 if (bInited && g_pWinList_Terminate) 63 g_pWinList_Terminate(); 64} 65 66static VOID 67TEST_WinList_Mix(VOID) 68{ 69 IShellWindows *pShellWindows1 = g_pWinList_GetShellWindows(FALSE); 70 trace("%p\n", pShellWindows1); 71 ok(pShellWindows1 != NULL, "pShellWindows1 was null\n"); 72 73 IShellWindows *pShellWindows2 = NULL; 74 CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, 75 IID_IShellWindows, (LPVOID *)&pShellWindows2); 76 ok(pShellWindows2 != NULL, "pShellWindows2 was null\n"); 77 78 ok_ptr(pShellWindows1, pShellWindows2); 79 80 if (pShellWindows1) 81 pShellWindows1->Release(); 82 if (pShellWindows2) 83 pShellWindows2->Release(); 84} 85 86static VOID 87TEST_SHDOCVW_WinList(VOID) 88{ 89 HINSTANCE hSHDOCVW = LoadLibraryW(L"shdocvw.dll"); 90 if (!hSHDOCVW) 91 { 92 skip("shdocvw.dll not loaded\n"); 93 return; 94 } 95 96 g_pWinList_Init = (FN_WinList_Init)GetProcAddress(hSHDOCVW, MAKEINTRESOURCEA(110)); 97 g_pWinList_Terminate = (FN_WinList_Terminate)GetProcAddress(hSHDOCVW, MAKEINTRESOURCEA(111)); 98 g_pWinList_GetShellWindows = (FN_WinList_GetShellWindows)GetProcAddress(hSHDOCVW, MAKEINTRESOURCEA(179)); 99 if (!g_pWinList_Init || !g_pWinList_Terminate || !g_pWinList_GetShellWindows) 100 { 101 skip("Some WinList_* functions not found: %p %p %p\n", 102 g_pWinList_Init, g_pWinList_Terminate, g_pWinList_GetShellWindows); 103 } 104 else 105 { 106 TEST_WinList_GetShellWindows(); 107 TEST_WinList_Mix(); 108 } 109 110 FreeLibrary(hSHDOCVW); 111} 112 113static VOID 114TEST_CLSID_ShellWindows(VOID) 115{ 116 IShellWindows *pShellWindows1 = NULL; 117 CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, 118 IID_IShellWindows, (LPVOID *)&pShellWindows1); 119 ok(pShellWindows1 != NULL, "pShellWindows1 was null\n"); 120 121 IShellWindows *pShellWindows2 = NULL; 122 CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, 123 IID_IShellWindows, (LPVOID *)&pShellWindows2); 124 ok(pShellWindows2 != NULL, "pShellWindows2 was null\n"); 125 126 ok_ptr(pShellWindows1, pShellWindows2); 127 128 if (pShellWindows1) 129 { 130 LONG nCount = -1; 131 HRESULT hr = pShellWindows1->get_Count(&nCount); 132 ok_hex(hr, S_OK); 133 ok(nCount >= 0, "nCount was %ld\n", nCount); 134 trace("%ld\n", nCount); 135 136 pShellWindows1->Release(); 137 } 138 else 139 { 140 ok_int(TRUE, FALSE); 141 ok_int(TRUE, FALSE); 142 } 143 144 if (pShellWindows2) 145 pShellWindows2->Release(); 146} 147 148START_TEST(WinList) 149{ 150 HRESULT hrCoInit = CoInitialize(NULL); 151 152 TEST_SHDOCVW_WinList(); 153 TEST_CLSID_ShellWindows(); 154 155 if (SUCCEEDED(hrCoInit)) 156 CoUninitialize(); 157}