[USER32_APITEST]
authorThomas Faber <thomas.faber@reactos.org>
Sat, 10 Oct 2015 16:08:31 +0000 (16:08 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Sat, 10 Oct 2015 16:08:31 +0000 (16:08 +0000)
- Add some tests for window properties
CORE-3897

svn path=/trunk/; revision=69490

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

index e401c97..17ec36b 100644 (file)
@@ -27,6 +27,7 @@ list(APPEND SOURCE
     SetActiveWindow.c
     SetCursorPos.c
     SetParent.c
+    SetProp.c
     SetScrollInfo.c
     SystemParametersInfo.c
     TrackMouseEvent.c
diff --git a/rostests/apitests/user32/SetProp.c b/rostests/apitests/user32/SetProp.c
new file mode 100644 (file)
index 0000000..6cc377c
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * PROJECT:         ReactOS API tests
+ * LICENSE:         LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE:         Test for SetProp
+ * PROGRAMMERS:     Thomas Faber <thomas.faber@reactos.org>
+ */
+
+#include <apitest.h>
+
+#include <winuser.h>
+#include "helper.h"
+
+static ATOM Atom1, Atom2, Atom3;
+
+static
+BOOL
+CALLBACK
+EnumFunc(
+    _In_ HWND hWnd,
+    _In_ PCWSTR lpszString,
+    _In_ HANDLE hData)
+{
+    if (HIWORD(lpszString))
+        ok(0, "Unexpected EnumFunc call: %p, '%ls', %p\n", hWnd, lpszString, hData);
+    else
+        ok(0, "Unexpected EnumFunc call: %p, 0x%04x, %p\n", hWnd, (USHORT)(ULONG_PTR)lpszString, hData);
+    return TRUE;
+}
+
+static
+BOOL
+CALLBACK
+EnumFuncEx(
+    _In_ HWND hWnd,
+    _In_ PWSTR lpszString,
+    _In_ HANDLE hData,
+    _In_ ULONG_PTR dwData)
+{
+    if (dwData == 0)
+    {
+        if (HIWORD(lpszString))
+            ok(0, "Unexpected EnumFuncEx call: %p, '%ls', %p\n", hWnd, lpszString, hData);
+        else
+            ok(0, "Unexpected EnumFuncEx call: %p, 0x%04x, %p\n", hWnd, (USHORT)(ULONG_PTR)lpszString, hData);
+    }
+    else
+    {
+        if (HIWORD(lpszString))
+        {
+            if (!wcscmp(lpszString, L"PropTestAtom1"))
+                ok(hData == &Atom1, "EnumFuncEx: %p, '%ls', %p; expected %p\n", hWnd, lpszString, hData, &Atom1);
+            else if (!wcscmp(lpszString, L"PropTestAtom2"))
+                ok(hData == &Atom2, "EnumFuncEx: %p, '%ls', %p; expected %p\n", hWnd, lpszString, hData, &Atom2);
+            else
+                ok(0, "Unexpected EnumFuncEx call: %p, '%ls', %p\n", hWnd, lpszString, hData);
+        }
+        else
+            ok(0, "Unexpected EnumFuncEx call: %p, 0x%04x, %p\n", hWnd, (USHORT)(ULONG_PTR)lpszString, hData);
+    }
+    return TRUE;
+}
+
+START_TEST(SetProp)
+{
+    HWND hWnd;
+    MSG msg;
+    UINT Atom;
+    HANDLE Prop;
+    LRESULT Result;
+    ATOM SysICAtom;
+    ATOM SysICSAtom;
+    HICON hIcon;
+    HICON hIcon2;
+
+    Atom1 = GlobalAddAtomW(L"PropTestAtom1");
+    ok(Atom1 != 0, "PropTestAtom1 is 0x%04x\n", Atom1);
+    ok(Atom1 >= 0xc000, "PropTestAtom1 is 0x%04x\n", Atom1);
+    ok(Atom1 >= 0xc018, "PropTestAtom1 is 0x%04x\n", Atom1);
+
+    /* These are not in the global atom table */
+    Atom = GlobalFindAtomW(L"SysIC");
+    ok(Atom == 0, "SysIC atom is 0x%04x\n", Atom);
+    Atom = GlobalFindAtomW(L"SysICS");
+    ok(Atom == 0, "SysICS atom is 0x%04x\n", Atom);
+
+    SetCursorPos(0, 0);
+
+    RegisterSimpleClass(DefWindowProcW, L"PropTest");
+
+    hWnd = CreateWindowExW(0, L"PropTest", NULL, 0,  10, 10, 20, 20,  NULL, NULL, 0, NULL);
+
+    Result = EnumPropsW(hWnd, EnumFunc);
+    if (0) // Windows returns an uninitialized value here
+    ok(Result == TRUE, "EnumProps returned %Iu\n", Result);
+    Result = EnumPropsExW(hWnd, EnumFuncEx, 0);
+    if (0) // Windows returns an uninitialized value here
+    ok(Result == TRUE, "EnumPropsEx returned %Iu\n", Result);
+
+    Atom2 = GlobalAddAtomW(L"PropTestAtom2");
+    ok(Atom2 != 0, "PropTestAtom2 is 0x%04x\n", Atom2);
+    ok(Atom2 >= 0xc000, "PropTestAtom2 is 0x%04x\n", Atom2);
+    ok(Atom2 >= 0xc018, "PropTestAtom2 is 0x%04x\n", Atom2);
+
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+        DispatchMessageA(&msg);
+
+    Result = EnumPropsExW(hWnd, EnumFuncEx, 0);
+    if (0) // Windows returns an uninitialized value here
+    ok(Result == TRUE, "EnumPropsEx returned %Iu\n", Result);
+
+    Result = SetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom1), &Atom1);
+    ok(Result == TRUE, "SetProp returned %Iu\n", Result);
+    Result = SetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom2), &Atom3);
+    ok(Result == TRUE, "SetProp returned %Iu\n", Result);
+    Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom2));
+    ok(Prop == &Atom3, "GetProp returned %p, expected %p\n", Prop, &Atom3);
+    Result = SetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom2), &Atom2);
+    ok(Result == TRUE, "SetProp returned %Iu\n", Result);
+    Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom2));
+    ok(Prop == &Atom2, "GetProp returned %p, expected %p\n", Prop, &Atom2);
+    Prop = GetPropW(hWnd, L"PropTestAtom2");
+    ok(Prop == &Atom2, "GetProp returned %p, expected %p\n", Prop, &Atom2);
+    Prop = GetPropA(hWnd, "PropTestAtom2");
+    ok(Prop == &Atom2, "GetProp returned %p, expected %p\n", Prop, &Atom2);
+
+    Result = EnumPropsExW(hWnd, EnumFuncEx, 1);
+    ok(Result == TRUE, "EnumPropsEx returned %Iu\n", Result);
+
+    hIcon = LoadImageW(NULL, (PCWSTR)MAKEINTRESOURCE(OIC_NOTE), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+    ok(hIcon != NULL, "LoadImage failed with %lu\n", GetLastError());
+    /* Should not have any icon */
+    hIcon2 = (HICON)SendMessageW(hWnd, WM_GETICON, ICON_BIG, 0);
+    ok(hIcon2 == NULL, "WM_GETICON returned %p, expected NULL\n", hIcon2);
+    hIcon2 = (HICON)SendMessageW(hWnd, WM_GETICON, ICON_SMALL, 0);
+    ok(hIcon2 == NULL, "WM_GETICON returned %p, expected NULL\n", hIcon2);
+
+    /* Set big icon, should also set small icon */
+    Result = SendMessageW(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
+    ok(Result == 0, "WM_SETICON returned 0x%Ix\n", Result);
+
+    hIcon2 = (HICON)SendMessageW(hWnd, WM_GETICON, ICON_BIG, 0);
+    ok(hIcon2 == hIcon, "WM_GETICON returned %p, expected %p\n", hIcon2, hIcon);
+    hIcon2 = (HICON)SendMessageW(hWnd, WM_GETICON, ICON_SMALL, 0);
+    ok(hIcon2 != hIcon && hIcon != NULL, "WM_GETICON returned %p, expected not %p and not NULL\n", hIcon2, hIcon);
+
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+        DispatchMessageA(&msg);
+
+    /* We should have only the props that we explicitly set */
+    for (Atom = 0x0000; Atom <= 0xffff; Atom++)
+    {
+        Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom));
+        if (Atom == Atom1)
+            ok(Prop == &Atom1, "Window %p Prop 0x%04x = %p, expected %p\n", hWnd, Atom, Prop, &Atom1);
+        else if (Atom == Atom2)
+            ok(Prop == &Atom2, "Window %p Prop 0x%04x = %p, expected %p\n", hWnd, Atom, Prop, &Atom2);
+        else
+            ok(Prop == NULL, "Window %p Prop 0x%04x = %p\n", hWnd, Atom, Prop);
+    }
+
+    /* In particular we shouldn't see these from WM_SETICON */
+    SysICAtom = RegisterWindowMessageW(L"SysIC");
+    Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(SysICAtom));
+    ok(Prop == NULL, "SysIC prop (0x%04x) is %p\n", SysICAtom, Prop);
+
+    SysICSAtom = RegisterWindowMessageW(L"SysICS");
+    Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(SysICSAtom));
+    ok(Prop == NULL, "SysICS prop (0x%04x) is %p\n", SysICSAtom, Prop);
+
+    GlobalDeleteAtom(Atom1);
+    GlobalDeleteAtom(Atom2);
+
+    DestroyWindow(hWnd);
+
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+        DispatchMessageA(&msg);
+ }
index 6c309fe..deaa4e8 100644 (file)
@@ -29,6 +29,7 @@ extern void func_SendMessageTimeout(void);
 extern void func_SetActiveWindow(void);
 extern void func_SetCursorPos(void);
 extern void func_SetParent(void);
+extern void func_SetProp(void);
 extern void func_SetScrollInfo(void);
 extern void func_SystemParametersInfo(void);
 extern void func_TrackMouseEvent(void);
@@ -63,6 +64,7 @@ const struct test winetest_testlist[] =
     { "SetActiveWindow", func_SetActiveWindow },
     { "SetCursorPos", func_SetCursorPos },
     { "SetParent", func_SetParent },
+    { "SetProp", func_SetProp },
     { "SetScrollInfo", func_SetScrollInfo },
     { "SystemParametersInfo", func_SystemParametersInfo },
     { "TrackMouseEvent", func_TrackMouseEvent },