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 19 typedef HRESULT (__stdcall *tShellDimScreen) (IUnknown** Unknown, HWND* hWindow); 20 21 tShellDimScreen ShellDimScreen; 22 23 static void Test_Dim() 24 { 25 IUnknown* unk = (IUnknown*)INVALID_POINTER; 26 HWND wnd = (HWND)INVALID_POINTER; 27 ULONG count; 28 29 HRESULT hr = ShellDimScreen(NULL, NULL); 30 ok_hex(hr, E_INVALIDARG); 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); 58 LONG style = GetWindowLong(wnd, GWL_STYLE); 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); 61 style = GetWindowLong(wnd, GWL_EXSTYLE); 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); 80 ok_hex(hr, E_NOINTERFACE); 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 105 START_TEST(ShellDimScreen) 106 { 107 HMODULE dll = LoadLibraryA("msgina.dll"); 108 ShellDimScreen = (tShellDimScreen)GetProcAddress(dll, MAKEINTRESOURCEA(16)); 109 if (!dll || !ShellDimScreen) 110 { 111 skip("msgina!#16 not found, skipping tests\n"); 112 return; 113 } 114 Test_Dim(); 115 } 116