[MSGINA_APITEST] Add a test for ShellDimScreen, used to fade out the background of...
authorMark Jansen <mark.jansen@reactos.org>
Thu, 16 Jun 2016 21:00:08 +0000 (21:00 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Thu, 16 Jun 2016 21:00:08 +0000 (21:00 +0000)
svn path=/trunk/; revision=71649

rostests/apitests/CMakeLists.txt
rostests/apitests/msgina/CMakeLists.txt [new file with mode: 0644]
rostests/apitests/msgina/ShellDimScreen.cpp [new file with mode: 0644]
rostests/apitests/msgina/testlist.c [new file with mode: 0644]

index d383a12..ab2c36d 100644 (file)
@@ -14,6 +14,7 @@ add_subdirectory(iphlpapi)
 if(NOT ARCH STREQUAL "amd64")
     add_subdirectory(kernel32)
 endif()
+add_subdirectory(msgina)
 add_subdirectory(msvcrt)
 add_subdirectory(ntdll)
 add_subdirectory(ole32)
diff --git a/rostests/apitests/msgina/CMakeLists.txt b/rostests/apitests/msgina/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b742cff
--- /dev/null
@@ -0,0 +1,13 @@
+
+set_cpp(WITH_RUNTIME)
+
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
+
+add_executable(msgina_apitest
+    ShellDimScreen.cpp
+    testlist.c)
+
+target_link_libraries(msgina_apitest wine uuid)
+set_module_type(msgina_apitest win32cui)
+add_importlibs(msgina_apitest msvcrt user32 kernel32)
+add_cd_file(TARGET msgina_apitest DESTINATION reactos/bin FOR all)
diff --git a/rostests/apitests/msgina/ShellDimScreen.cpp b/rostests/apitests/msgina/ShellDimScreen.cpp
new file mode 100644 (file)
index 0000000..95761ea
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE:         Test for ShellDimScreen
+ * PROGRAMMER:      Mark Jansen
+ */
+
+#include <apitest.h>
+#include <atlbase.h>
+#include <atlcom.h>
+
+#define INITGUID
+#include <guiddef.h>
+// stolen from com_apitest.h
+DEFINE_GUID(CLSID_FadeTask,                0x7EB5FBE4, 0x2100, 0x49E6, 0x85, 0x93, 0x17, 0xE1, 0x30, 0x12, 0x2F, 0x91);
+
+
+typedef HRESULT (__stdcall *tShellDimScreen) (IUnknown** Unknown, HWND* hWindow);
+
+tShellDimScreen ShellDimScreen;
+
+static void Test_Dim()
+{
+    IUnknown* unk = (IUnknown*)0xdeadbeef;
+    HWND wnd = (HWND)0xdeadbeef;
+    ULONG count;
+
+    HRESULT hr = ShellDimScreen(NULL, NULL);
+    ok_hex(hr, E_INVALIDARG);
+
+    hr = ShellDimScreen(&unk, &wnd);
+    ok_hex(hr, S_OK);
+    ok(unk != ((IUnknown*)0xdeadbeef), "Expected a valid object\n");
+    ok(wnd != ((HWND)0xdeadbeef), "Expected a valid window ptr\n");
+    ok(IsWindow(wnd), "Expected a valid window\n");
+    ok(IsWindowVisible(wnd), "Expected the window to be visible\n");
+
+    if (unk != ((IUnknown*)0xdeadbeef) && unk)
+    {
+        count = unk->Release();
+        ok(count == 0, "Expected count to be 0, was: %lu\n", count);
+        ok(!IsWindow(wnd), "Expected the window to be destroyed\n");
+    }
+
+    unk = (IUnknown*)0xdeadbeef;
+    wnd = (HWND)0xdeadbeef;
+    hr = ShellDimScreen(&unk, &wnd);
+    ok_hex(hr, S_OK);
+    ok(unk != ((IUnknown*)0xdeadbeef), "Expected a valid object\n");
+    ok(wnd != ((HWND)0xdeadbeef), "Expected a valid window ptr\n");
+    ok(IsWindow(wnd), "Expected a valid window\n");
+    ok(IsWindowVisible(wnd), "Expected the window to be visible\n");
+    char classname[100] = {0};;
+    int nRet = GetClassNameA(wnd, classname, 100);
+    ok(nRet == 17, "Expected GetClassName to return 3 was %i\n", nRet);
+    ok(!strcmp(classname, "DimmedWindowClass"), "Expected classname to be DimmedWindowClass, was %s\n", classname);
+    LONG style = GetWindowLong(wnd, GWL_STYLE);
+    LONG expectedstyle = WS_POPUP | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS;
+    ok(style == expectedstyle, "Expected style to be %lx, was %lx\n", expectedstyle, style);
+    style = GetWindowLong(wnd, GWL_EXSTYLE);
+    ok(style == WS_EX_TOPMOST, "Expected exstyle to be %x, was %lx\n", WS_EX_TOPMOST, style);
+
+    if (unk != ((IUnknown*)0xdeadbeef) && unk)
+    {
+        count = unk->AddRef();
+        ok(count == 2, "Expected count to be 2, was: %lu\n", count);
+        count = unk->Release();
+        ok(count == 1, "Expected count to be 1, was: %lu\n", count);
+
+        IUnknown* unk2;
+        hr = unk->QueryInterface(IID_IUnknown, (void**)&unk2);
+        ok_hex(hr, S_OK);
+        if (SUCCEEDED(hr))
+        {
+            ok(unk2 == unk, "Expected the object to be the same, was: %p, %p\n", unk, unk2);
+            unk2->Release();
+        }
+        hr = unk->QueryInterface(CLSID_FadeTask, (void**)&unk2);
+        ok_hex(hr, E_NOINTERFACE);
+        if (SUCCEEDED(hr))
+        {
+            ok(unk2 == unk, "Expected the object to be the same, was: %p, %p\n", unk, unk2);
+            unk2->Release();
+        }
+    }
+
+    RECT rc;
+    GetWindowRect(wnd, &rc);
+
+    ok(rc.left == GetSystemMetrics(SM_XVIRTUALSCREEN), "Expected rc.left to be %u, was %lu\n", GetSystemMetrics(SM_XVIRTUALSCREEN), rc.left);
+    ok(rc.top == GetSystemMetrics(SM_YVIRTUALSCREEN), "Expected rc.top to be %u, was %lu\n", GetSystemMetrics(SM_YVIRTUALSCREEN), rc.top);
+    ok((rc.right - rc.left) == GetSystemMetrics(SM_CXVIRTUALSCREEN), "Expected rc.left to be %u, was %lu\n", GetSystemMetrics(SM_CXVIRTUALSCREEN), (rc.right - rc.left));
+    ok((rc.bottom - rc.top) == GetSystemMetrics(SM_CYVIRTUALSCREEN), "Expected rc.top to be %u, was %lu\n", GetSystemMetrics(SM_CYVIRTUALSCREEN), (rc.bottom - rc.top));
+
+    if (unk != ((IUnknown*)0xdeadbeef) && unk)
+    {
+        count = unk->Release();
+        ok(count == 0, "Expected count to be 0, was: %lu\n", count);
+        ok(!IsWindow(wnd), "Expected the window to be destroyed\n");
+    }
+}
+
+
+START_TEST(ShellDimScreen)
+{
+    HMODULE dll = LoadLibraryA("msgina.dll");
+    ShellDimScreen = (tShellDimScreen)GetProcAddress(dll, MAKEINTRESOURCEA(16));
+    if (!dll || !ShellDimScreen)
+    {
+        skip("msgina!#16 not found, skipping tests\n");
+        return;
+    }
+    Test_Dim();
+}
diff --git a/rostests/apitests/msgina/testlist.c b/rostests/apitests/msgina/testlist.c
new file mode 100644 (file)
index 0000000..fb5bd8d
--- /dev/null
@@ -0,0 +1,10 @@
+#define STANDALONE
+#include <apitest.h>
+
+extern void func_ShellDimScreen(void);
+
+const struct test winetest_testlist[] =
+{
+    { "ShellDimScreen", func_ShellDimScreen },
+    { 0, 0 }
+};