[USER32_APITEST]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 1 Mar 2011 12:05:39 +0000 (12:05 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 1 Mar 2011 12:05:39 +0000 (12:05 +0000)
Patch by Thomas Faber: some tests for GetMessage and PeekMessage

svn path=/trunk/; revision=50943

rostests/apitests/user32/CMakeLists.txt
rostests/apitests/user32/GetPeekMessage.c [new file with mode: 0644]
rostests/apitests/user32/testlist.c
rostests/apitests/user32/user32_apitest.rbuild

index ffe5850..12fb0e4 100644 (file)
@@ -8,6 +8,7 @@ list(APPEND SOURCE
     ScrollWindowEx.c
     GetSystemMetrics.c
     GetIconInfo.c
+    GetPeekMessage.c
     testlist.c)
 
 add_executable(user32_apitest ${SOURCE})
diff --git a/rostests/apitests/user32/GetPeekMessage.c b/rostests/apitests/user32/GetPeekMessage.c
new file mode 100644 (file)
index 0000000..2cf24d2
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * PURPOSE:         Test for GetMessage/PeekMessage
+ * PROGRAMMERS:     Thomas Faber
+ */
+
+#include <stdio.h>
+#include <wine/test.h>
+#include <windows.h>
+
+void Test_GetMessage(HWND hWnd)
+{
+    MSG msg;
+
+    SetLastError(DNS_ERROR_RCODE_NXRRSET);
+
+    ok(GetMessage(&msg, hWnd, 0, 0) == -1, "\n");
+    ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "GetLastError() = %lu\n", GetLastError());
+}
+
+void Test_PeekMessage(HWND hWnd)
+{
+    MSG msg;
+
+    SetLastError(DNS_ERROR_RCODE_NXRRSET);
+
+    ok(PeekMessage(&msg, hWnd, 0, 0, PM_NOREMOVE) == 0, "\n");
+    ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "GetLastError() = %lu\n", GetLastError());
+}
+
+START_TEST(GetPeekMessage)
+{
+    HWND hWnd = CreateWindowExW(0, L"EDIT", L"miau", 0, CW_USEDEFAULT, CW_USEDEFAULT,
+        CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
+    ok(hWnd != INVALID_HANDLE_VALUE, "\n");
+    /* make sure we pass an invalid handle to GetMessage/PeekMessage */
+    ok(DestroyWindow(hWnd), "\n");
+
+    Test_GetMessage(hWnd);
+    Test_PeekMessage(hWnd);
+}
index 34825a2..b37d7ca 100644 (file)
@@ -11,6 +11,7 @@ extern void func_ScrollDC(void);
 extern void func_ScrollWindowEx(void);
 extern void func_GetSystemMetrics(void);
 extern void func_GetIconInfo(void);
+extern void func_GetPeekMessage(void);
 
 const struct test winetest_testlist[] =
 {
@@ -20,6 +21,7 @@ const struct test winetest_testlist[] =
     { "ScrollWindowEx", func_ScrollWindowEx },
     { "GetSystemMetrics", func_GetSystemMetrics },
     { "GetIconInfo", func_GetIconInfo },
+    { "GetPeekMessage", func_GetPeekMessage },
 
     { 0, 0 }
 };
index 26f269c..251ad03 100644 (file)
@@ -15,6 +15,7 @@
        <file>ScrollWindowEx.c</file>
        <file>GetSystemMetrics.c</file>
        <file>GetIconInfo.c</file>
+       <file>GetPeekMessage.c</file>
 
 </module>
 </group>