ReactOS  0.4.14-dev-599-g2d4d3f5
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
15 DEFINE_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 
23 static void Test_Dim()
24 {
26  HWND wnd = (HWND)INVALID_POINTER;
27  ULONG count;
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 
46  unk = (IUnknown*)INVALID_POINTER;
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);
59  LONG expectedstyle = WS_POPUP | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS;
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 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_DISABLED
Definition: pedump.c:621
#define HRESULT
Definition: msvc.h:7
#define E_NOINTERFACE
Definition: winerror.h:2364
int WINAPI GetClassNameA(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPSTR lpClassName, _In_ int nMaxCount)
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1026
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1028
GLuint GLuint GLsizei count
Definition: gl.h:1545
tShellDimScreen ShellDimScreen
LONG top
Definition: windef.h:307
HANDLE HWND
Definition: compat.h:13
#define GWL_EXSTYLE
Definition: winuser.h:845
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
WCHAR classname[128]
Definition: startup.c:15
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define ok_hex(expression, result)
Definition: atltest.h:94
static HMODULE dll
Definition: str.c:188
static void Test_Dim()
long LONG
Definition: pedump.c:60
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
ULONG Release()
#define INVALID_POINTER
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
DEFINE_GUID(CLSID_FadeTask, 0x7EB5FBE4, 0x2100, 0x49E6, 0x85, 0x93, 0x17, 0xE1, 0x30, 0x12, 0x2F, 0x91)
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1029
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
int WINAPI GetSystemMetrics(_In_ int)
nsrefcnt Release()
#define __stdcall
Definition: typedefs.h:25
ULONG AddRef()
#define GetWindowLong
Definition: winuser.h:5771
#define WS_EX_TOPMOST
Definition: pedump.c:647
START_TEST(ShellDimScreen)
HRESULT(__stdcall * tShellDimScreen)(IUnknown **Unknown, HWND *hWindow)
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1027
#define GWL_STYLE
Definition: winuser.h:846
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
#define WS_POPUP
Definition: pedump.c:616
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1
BOOL WINAPI IsWindowVisible(_In_ HWND)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
LONG bottom
Definition: windef.h:309
#define GetProcAddress(x, y)
Definition: compat.h:418
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620
#define SUCCEEDED(hr)
Definition: intsafe.h:57