2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for ShellDimScreen
5 * PROGRAMMER: Mark Jansen
14 // stolen from com_apitest.h
15 DEFINE_GUID(CLSID_FadeTask
, 0x7EB5FBE4, 0x2100, 0x49E6, 0x85, 0x93, 0x17, 0xE1, 0x30, 0x12, 0x2F, 0x91);
18 typedef HRESULT (__stdcall
*tShellDimScreen
) (IUnknown
** Unknown
, HWND
* hWindow
);
20 tShellDimScreen ShellDimScreen
;
22 static void Test_Dim()
24 IUnknown
* unk
= (IUnknown
*)0xdeadbeef;
25 HWND wnd
= (HWND
)0xdeadbeef;
28 HRESULT hr
= ShellDimScreen(NULL
, NULL
);
29 ok_hex(hr
, E_INVALIDARG
);
31 hr
= ShellDimScreen(&unk
, &wnd
);
33 ok(unk
!= ((IUnknown
*)0xdeadbeef), "Expected a valid object\n");
34 ok(wnd
!= ((HWND
)0xdeadbeef), "Expected a valid window ptr\n");
35 ok(IsWindow(wnd
), "Expected a valid window\n");
36 ok(IsWindowVisible(wnd
), "Expected the window to be visible\n");
38 if (unk
!= ((IUnknown
*)0xdeadbeef) && unk
)
40 count
= unk
->Release();
41 ok(count
== 0, "Expected count to be 0, was: %lu\n", count
);
42 ok(!IsWindow(wnd
), "Expected the window to be destroyed\n");
45 unk
= (IUnknown
*)0xdeadbeef;
46 wnd
= (HWND
)0xdeadbeef;
47 hr
= ShellDimScreen(&unk
, &wnd
);
49 ok(unk
!= ((IUnknown
*)0xdeadbeef), "Expected a valid object\n");
50 ok(wnd
!= ((HWND
)0xdeadbeef), "Expected a valid window ptr\n");
51 ok(IsWindow(wnd
), "Expected a valid window\n");
52 ok(IsWindowVisible(wnd
), "Expected the window to be visible\n");
53 char classname
[100] = {0};;
54 int nRet
= GetClassNameA(wnd
, classname
, 100);
55 ok(nRet
== 17, "Expected GetClassName to return 3 was %i\n", nRet
);
56 ok(!strcmp(classname
, "DimmedWindowClass"), "Expected classname to be DimmedWindowClass, was %s\n", classname
);
57 LONG style
= GetWindowLong(wnd
, GWL_STYLE
);
58 LONG expectedstyle
= WS_POPUP
| WS_VISIBLE
| WS_DISABLED
| WS_CLIPSIBLINGS
;
59 ok(style
== expectedstyle
, "Expected style to be %lx, was %lx\n", expectedstyle
, style
);
60 style
= GetWindowLong(wnd
, GWL_EXSTYLE
);
61 ok(style
== WS_EX_TOPMOST
, "Expected exstyle to be %x, was %lx\n", WS_EX_TOPMOST
, style
);
63 if (unk
!= ((IUnknown
*)0xdeadbeef) && unk
)
65 count
= unk
->AddRef();
66 ok(count
== 2, "Expected count to be 2, was: %lu\n", count
);
67 count
= unk
->Release();
68 ok(count
== 1, "Expected count to be 1, was: %lu\n", count
);
71 hr
= unk
->QueryInterface(IID_IUnknown
, (void**)&unk2
);
75 ok(unk2
== unk
, "Expected the object to be the same, was: %p, %p\n", unk
, unk2
);
78 hr
= unk
->QueryInterface(CLSID_FadeTask
, (void**)&unk2
);
79 ok_hex(hr
, E_NOINTERFACE
);
82 ok(unk2
== unk
, "Expected the object to be the same, was: %p, %p\n", unk
, unk2
);
88 GetWindowRect(wnd
, &rc
);
90 ok(rc
.left
== GetSystemMetrics(SM_XVIRTUALSCREEN
), "Expected rc.left to be %u, was %lu\n", GetSystemMetrics(SM_XVIRTUALSCREEN
), rc
.left
);
91 ok(rc
.top
== GetSystemMetrics(SM_YVIRTUALSCREEN
), "Expected rc.top to be %u, was %lu\n", GetSystemMetrics(SM_YVIRTUALSCREEN
), rc
.top
);
92 ok((rc
.right
- rc
.left
) == GetSystemMetrics(SM_CXVIRTUALSCREEN
), "Expected rc.left to be %u, was %lu\n", GetSystemMetrics(SM_CXVIRTUALSCREEN
), (rc
.right
- rc
.left
));
93 ok((rc
.bottom
- rc
.top
) == GetSystemMetrics(SM_CYVIRTUALSCREEN
), "Expected rc.top to be %u, was %lu\n", GetSystemMetrics(SM_CYVIRTUALSCREEN
), (rc
.bottom
- rc
.top
));
95 if (unk
!= ((IUnknown
*)0xdeadbeef) && unk
)
97 count
= unk
->Release();
98 ok(count
== 0, "Expected count to be 0, was: %lu\n", count
);
99 ok(!IsWindow(wnd
), "Expected the window to be destroyed\n");
104 START_TEST(ShellDimScreen
)
106 HMODULE dll
= LoadLibraryA("msgina.dll");
107 ShellDimScreen
= (tShellDimScreen
)GetProcAddress(dll
, MAKEINTRESOURCEA(16));
108 if (!dll
|| !ShellDimScreen
)
110 skip("msgina!#16 not found, skipping tests\n");