ReactOS 0.4.16-dev-927-g467dec4
WinList.cpp
Go to the documentation of this file.
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
13typedef IShellWindows* (WINAPI *FN_WinList_GetShellWindows)(BOOL);
14
18
19static VOID
21{
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 {
54 }
55
56 if (pShellWindows2)
57 pShellWindows2->Release();
58
59 if (pShellWindows3)
60 pShellWindows3->Release();
61
62 if (bInited && g_pWinList_Terminate)
64}
65
66static 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
88{
89 HINSTANCE hSHDOCVW = LoadLibraryW(L"shdocvw.dll");
90 if (!hSHDOCVW)
91 {
92 skip("shdocvw.dll not loaded\n");
93 return;
94 }
95
100 {
101 skip("Some WinList_* functions not found: %p %p %p\n",
103 }
104 else
105 {
108 }
109
110 FreeLibrary(hSHDOCVW);
111}
112
113static 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
149{
150 HRESULT hrCoInit = CoInitialize(NULL);
151
154
155 if (SUCCEEDED(hrCoInit))
157}
static VOID TEST_SHDOCVW_WinList(VOID)
Definition: WinList.cpp:87
BOOL(WINAPI * FN_WinList_Init)(VOID)
Definition: WinList.cpp:11
VOID(WINAPI * FN_WinList_Terminate)(VOID)
Definition: WinList.cpp:12
static VOID TEST_WinList_Mix(VOID)
Definition: WinList.cpp:67
static FN_WinList_Terminate g_pWinList_Terminate
Definition: WinList.cpp:16
static VOID TEST_CLSID_ShellWindows(VOID)
Definition: WinList.cpp:114
static FN_WinList_GetShellWindows g_pWinList_GetShellWindows
Definition: WinList.cpp:17
static VOID TEST_WinList_GetShellWindows(VOID)
Definition: WinList.cpp:20
IShellWindows *(WINAPI * FN_WinList_GetShellWindows)(BOOL)
Definition: WinList.cpp:13
static FN_WinList_Init g_pWinList_Init
Definition: WinList.cpp:15
#define VOID
Definition: acefi.h:82
#define ok_hex(expression, result)
Definition: atltest.h:94
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
unsigned int BOOL
Definition: ntddk_ex.h:94
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define BOOL
Definition: nt_native.h:43
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
HRESULT hr
Definition: shlfolder.c:183
#define WINAPI
Definition: msvc.h:6
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581