ReactOS 0.4.15-dev-7907-g95bf896
ShellDimScreen.cpp
Go to the documentation of this file.
1/*
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
6 */
7
8#include <apitest.h>
9#include <atlbase.h>
10#include <atlcom.h>
11
12#define INITGUID
13#include <guiddef.h>
14// stolen from com_apitest.h
15DEFINE_GUID(CLSID_FadeTask, 0x7EB5FBE4, 0x2100, 0x49E6, 0x85, 0x93, 0x17, 0xE1, 0x30, 0x12, 0x2F, 0x91);
16
17#define INVALID_POINTER ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)
18
20
22
23static void Test_Dim()
24{
28
31
32 hr = ShellDimScreen(&unk, &wnd);
33 ok_hex(hr, S_OK);
34 ok(unk != INVALID_POINTER, "Expected a valid object\n");
35 ok(wnd != INVALID_POINTER, "Expected a valid window ptr\n");
36 ok(IsWindow(wnd), "Expected a valid window\n");
37 ok(IsWindowVisible(wnd), "Expected the window to be visible\n");
38
39 if (unk != ((IUnknown*)INVALID_POINTER) && unk)
40 {
41 count = unk->Release();
42 ok(count == 0, "Expected count to be 0, was: %lu\n", count);
43 ok(!IsWindow(wnd), "Expected the window to be destroyed\n");
44 }
45
47 wnd = (HWND)INVALID_POINTER;
48 hr = ShellDimScreen(&unk, &wnd);
49 ok_hex(hr, S_OK);
50 ok(unk != ((IUnknown*)INVALID_POINTER), "Expected a valid object\n");
51 ok(wnd != ((HWND)INVALID_POINTER), "Expected a valid window ptr\n");
52 ok(IsWindow(wnd), "Expected a valid window\n");
53 ok(IsWindowVisible(wnd), "Expected the window to be visible\n");
54 char classname[100] = {0};
55 int nRet = GetClassNameA(wnd, classname, 100);
56 ok(nRet == 17, "Expected GetClassName to return 3 was %i\n", nRet);
57 ok(!strcmp(classname, "DimmedWindowClass"), "Expected classname to be DimmedWindowClass, was %s\n", classname);
60 ok(style == expectedstyle, "Expected style to be %lx, was %lx\n", expectedstyle, style);
62 ok(style == WS_EX_TOPMOST, "Expected exstyle to be %x, was %lx\n", WS_EX_TOPMOST, style);
63
64 if (unk != ((IUnknown*)INVALID_POINTER) && unk)
65 {
66 count = unk->AddRef();
67 ok(count == 2, "Expected count to be 2, was: %lu\n", count);
68 count = unk->Release();
69 ok(count == 1, "Expected count to be 1, was: %lu\n", count);
70
71 IUnknown* unk2;
72 hr = unk->QueryInterface(IID_IUnknown, (void**)&unk2);
73 ok_hex(hr, S_OK);
74 if (SUCCEEDED(hr))
75 {
76 ok(unk2 == unk, "Expected the object to be the same, was: %p, %p\n", unk, unk2);
77 unk2->Release();
78 }
79 hr = unk->QueryInterface(CLSID_FadeTask, (void**)&unk2);
81 if (SUCCEEDED(hr))
82 {
83 ok(unk2 == unk, "Expected the object to be the same, was: %p, %p\n", unk, unk2);
84 unk2->Release();
85 }
86 }
87
88 RECT rc;
89 GetWindowRect(wnd, &rc);
90
91 ok(rc.left == GetSystemMetrics(SM_XVIRTUALSCREEN), "Expected rc.left to be %u, was %lu\n", GetSystemMetrics(SM_XVIRTUALSCREEN), rc.left);
92 ok(rc.top == GetSystemMetrics(SM_YVIRTUALSCREEN), "Expected rc.top to be %u, was %lu\n", GetSystemMetrics(SM_YVIRTUALSCREEN), rc.top);
93 ok((rc.right - rc.left) == GetSystemMetrics(SM_CXVIRTUALSCREEN), "Expected rc.left to be %u, was %lu\n", GetSystemMetrics(SM_CXVIRTUALSCREEN), (rc.right - rc.left));
94 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
96 if (unk != ((IUnknown*)INVALID_POINTER) && unk)
97 {
98 count = unk->Release();
99 ok(count == 0, "Expected count to be 0, was: %lu\n", count);
100 ok(!IsWindow(wnd), "Expected the window to be destroyed\n");
101 }
102}
103
104
106{
107 HMODULE dll = LoadLibraryA("msgina.dll");
109 if (!dll || !ShellDimScreen)
110 {
111 skip("msgina!#16 not found, skipping tests\n");
112 return;
113 }
114 Test_Dim();
115}
tShellDimScreen ShellDimScreen
#define INVALID_POINTER
static void Test_Dim()
HRESULT(__stdcall * tShellDimScreen)(IUnknown **Unknown, HWND *hWindow)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
Arabic default style
Definition: afstyles.h:94
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
const GUID IID_IUnknown
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
HANDLE HWND
Definition: compat.h:19
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
GLuint GLuint GLsizei count
Definition: gl.h:1545
@ Unknown
Definition: i8042prt.h:114
ULONG AddRef()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static HMODULE dll
Definition: str.c:188
#define WS_POPUP
Definition: pedump.c:616
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_EX_TOPMOST
Definition: pedump.c:647
long LONG
Definition: pedump.c:60
#define WS_DISABLED
Definition: pedump.c:621
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
WCHAR classname[128]
Definition: startup.c:15
HRESULT hr
Definition: shlfolder.c:183
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define __stdcall
Definition: typedefs.h:25
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7
#define E_NOINTERFACE
Definition: winerror.h:2364
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1039
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPI GetClassNameA(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPSTR lpClassName, _In_ int nMaxCount)
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1038
#define GetWindowLong
Definition: winuser.h:5796
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1036
#define GWL_STYLE
Definition: winuser.h:852
BOOL WINAPI IsWindowVisible(_In_ HWND)
int WINAPI GetSystemMetrics(_In_ int)
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1037
#define GWL_EXSTYLE
Definition: winuser.h:851