1 /* 2 * PROJECT: ReactOS API tests 3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory 4 * PURPOSE: Test for SetProp 5 * PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org> 6 */ 7 8 #include "precomp.h" 9 10 static ATOM Atom1, Atom2, Atom3; 11 12 static 13 BOOL 14 CALLBACK 15 EnumFunc( 16 _In_ HWND hWnd, 17 _In_ PCWSTR lpszString, 18 _In_ HANDLE hData) 19 { 20 if (HIWORD(lpszString)) 21 ok(0, "Unexpected EnumFunc call: %p, '%ls', %p\n", hWnd, lpszString, hData); 22 else 23 ok(0, "Unexpected EnumFunc call: %p, 0x%04x, %p\n", hWnd, (USHORT)(ULONG_PTR)lpszString, hData); 24 return TRUE; 25 } 26 27 static 28 BOOL 29 CALLBACK 30 EnumFuncEx( 31 _In_ HWND hWnd, 32 _In_ PWSTR lpszString, 33 _In_ HANDLE hData, 34 _In_ ULONG_PTR dwData) 35 { 36 if (dwData == 0) 37 { 38 if (HIWORD(lpszString)) 39 ok(0, "Unexpected EnumFuncEx call: %p, '%ls', %p\n", hWnd, lpszString, hData); 40 else 41 ok(0, "Unexpected EnumFuncEx call: %p, 0x%04x, %p\n", hWnd, (USHORT)(ULONG_PTR)lpszString, hData); 42 } 43 else 44 { 45 if (HIWORD(lpszString)) 46 { 47 if (!wcscmp(lpszString, L"PropTestAtom1")) 48 ok(hData == &Atom1, "EnumFuncEx: %p, '%ls', %p; expected %p\n", hWnd, lpszString, hData, &Atom1); 49 else if (!wcscmp(lpszString, L"PropTestAtom2")) 50 ok(hData == &Atom2, "EnumFuncEx: %p, '%ls', %p; expected %p\n", hWnd, lpszString, hData, &Atom2); 51 else 52 ok(0, "Unexpected EnumFuncEx call: %p, '%ls', %p\n", hWnd, lpszString, hData); 53 } 54 else 55 ok(0, "Unexpected EnumFuncEx call: %p, 0x%04x, %p\n", hWnd, (USHORT)(ULONG_PTR)lpszString, hData); 56 } 57 return TRUE; 58 } 59 60 START_TEST(SetProp) 61 { 62 HWND hWnd; 63 MSG msg; 64 UINT Atom; 65 HANDLE Prop; 66 LRESULT Result; 67 ATOM SysICAtom; 68 ATOM SysICSAtom; 69 HICON hIcon; 70 HICON hIcon2; 71 72 Atom1 = GlobalAddAtomW(L"PropTestAtom1"); 73 ok(Atom1 != 0, "PropTestAtom1 is 0x%04x\n", Atom1); 74 ok(Atom1 >= 0xc000, "PropTestAtom1 is 0x%04x\n", Atom1); 75 ok(Atom1 >= 0xc018, "PropTestAtom1 is 0x%04x\n", Atom1); 76 77 /* These are not in the global atom table */ 78 Atom = GlobalFindAtomW(L"SysIC"); 79 ok(Atom == 0, "SysIC atom is 0x%04x\n", Atom); 80 Atom = GlobalFindAtomW(L"SysICS"); 81 ok(Atom == 0, "SysICS atom is 0x%04x\n", Atom); 82 83 SetCursorPos(0, 0); 84 85 RegisterSimpleClass(DefWindowProcW, L"PropTest"); 86 87 hWnd = CreateWindowExW(0, L"PropTest", NULL, 0, 10, 10, 20, 20, NULL, NULL, 0, NULL); 88 89 Result = EnumPropsW(hWnd, EnumFunc); 90 if (0) // Windows returns an uninitialized value here 91 ok(Result == TRUE, "EnumProps returned %Iu\n", Result); 92 Result = EnumPropsExW(hWnd, EnumFuncEx, 0); 93 if (0) // Windows returns an uninitialized value here 94 ok(Result == TRUE, "EnumPropsEx returned %Iu\n", Result); 95 96 Atom2 = GlobalAddAtomW(L"PropTestAtom2"); 97 ok(Atom2 != 0, "PropTestAtom2 is 0x%04x\n", Atom2); 98 ok(Atom2 >= 0xc000, "PropTestAtom2 is 0x%04x\n", Atom2); 99 ok(Atom2 >= 0xc018, "PropTestAtom2 is 0x%04x\n", Atom2); 100 101 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) 102 DispatchMessageA(&msg); 103 104 Result = EnumPropsExW(hWnd, EnumFuncEx, 0); 105 if (0) // Windows returns an uninitialized value here 106 ok(Result == TRUE, "EnumPropsEx returned %Iu\n", Result); 107 108 Result = SetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom1), &Atom1); 109 ok(Result == TRUE, "SetProp returned %Iu\n", Result); 110 Result = SetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom2), &Atom3); 111 ok(Result == TRUE, "SetProp returned %Iu\n", Result); 112 Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom2)); 113 ok(Prop == &Atom3, "GetProp returned %p, expected %p\n", Prop, &Atom3); 114 Result = SetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom2), &Atom2); 115 ok(Result == TRUE, "SetProp returned %Iu\n", Result); 116 Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom2)); 117 ok(Prop == &Atom2, "GetProp returned %p, expected %p\n", Prop, &Atom2); 118 Prop = GetPropW(hWnd, L"PropTestAtom2"); 119 ok(Prop == &Atom2, "GetProp returned %p, expected %p\n", Prop, &Atom2); 120 Prop = GetPropA(hWnd, "PropTestAtom2"); 121 ok(Prop == &Atom2, "GetProp returned %p, expected %p\n", Prop, &Atom2); 122 123 Result = EnumPropsExW(hWnd, EnumFuncEx, 1); 124 ok(Result == TRUE, "EnumPropsEx returned %Iu\n", Result); 125 126 hIcon = LoadImageW(NULL, (PCWSTR)MAKEINTRESOURCE(OIC_NOTE), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); 127 ok(hIcon != NULL, "LoadImage failed with %lu\n", GetLastError()); 128 /* Should not have any icon */ 129 hIcon2 = (HICON)SendMessageW(hWnd, WM_GETICON, ICON_BIG, 0); 130 ok(hIcon2 == NULL, "WM_GETICON returned %p, expected NULL\n", hIcon2); 131 hIcon2 = (HICON)SendMessageW(hWnd, WM_GETICON, ICON_SMALL, 0); 132 ok(hIcon2 == NULL, "WM_GETICON returned %p, expected NULL\n", hIcon2); 133 134 /* Set big icon, should also set small icon */ 135 Result = SendMessageW(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon); 136 ok(Result == 0, "WM_SETICON returned 0x%Ix\n", Result); 137 138 hIcon2 = (HICON)SendMessageW(hWnd, WM_GETICON, ICON_BIG, 0); 139 ok(hIcon2 == hIcon, "WM_GETICON returned %p, expected %p\n", hIcon2, hIcon); 140 hIcon2 = (HICON)SendMessageW(hWnd, WM_GETICON, ICON_SMALL, 0); 141 ok(hIcon2 != hIcon && hIcon != NULL, "WM_GETICON returned %p, expected not %p and not NULL\n", hIcon2, hIcon); 142 143 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) 144 DispatchMessageA(&msg); 145 146 /* We should have only the props that we explicitly set */ 147 for (Atom = 0x0000; Atom <= 0xffff; Atom++) 148 { 149 Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(Atom)); 150 if (Atom == Atom1) 151 ok(Prop == &Atom1, "Window %p Prop 0x%04x = %p, expected %p\n", hWnd, Atom, Prop, &Atom1); 152 else if (Atom == Atom2) 153 ok(Prop == &Atom2, "Window %p Prop 0x%04x = %p, expected %p\n", hWnd, Atom, Prop, &Atom2); 154 else 155 ok(Prop == NULL, "Window %p Prop 0x%04x = %p\n", hWnd, Atom, Prop); 156 } 157 158 /* In particular we shouldn't see these from WM_SETICON */ 159 SysICAtom = RegisterWindowMessageW(L"SysIC"); 160 Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(SysICAtom)); 161 ros_skip_flaky 162 ok(Prop == NULL, "SysIC prop (0x%04x) is %p\n", SysICAtom, Prop); 163 164 SysICSAtom = RegisterWindowMessageW(L"SysICS"); 165 Prop = GetPropW(hWnd, (PCWSTR)MAKEINTATOM(SysICSAtom)); 166 ok(Prop == NULL, "SysICS prop (0x%04x) is %p\n", SysICSAtom, Prop); 167 168 GlobalDeleteAtom(Atom1); 169 GlobalDeleteAtom(Atom2); 170 171 DestroyWindow(hWnd); 172 173 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) 174 DispatchMessageA(&msg); 175 } 176