1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for toolbar window class v6 5 * PROGRAMMERS: Giannis Adamopoulos 6 */ 7 8 #include "wine/test.h" 9 #include <stdio.h> 10 #include <windows.h> 11 #include <commctrl.h> 12 #include <uxtheme.h> 13 #include <undocuser.h> 14 #include <msgtrace.h> 15 #include <user32testhelpers.h> 16 17 HANDLE _CreateV5ActCtx() 18 { 19 ACTCTXW ActCtx = {sizeof(ACTCTX)}; 20 WCHAR buffer[MAX_PATH] , *separator; 21 22 ok (GetModuleFileNameW(NULL, buffer, MAX_PATH), "GetModuleFileName failed\n"); 23 separator = wcsrchr(buffer, L'\\'); 24 if (separator) 25 wcscpy(separator + 1, L"comctl32v5.manifest"); 26 27 ActCtx.lpSource = buffer; 28 29 return CreateActCtxW(&ActCtx);; 30 } 31 32 33 void TestVersionMessage() 34 { 35 HWND hwnd; 36 int version; 37 38 hwnd = CreateWindowExW(0, TOOLBARCLASSNAMEW, L"Test", 0, 0, 0, 0, 0, 0, 0, 0, NULL); 39 ok(hwnd != NULL, "CreateWindowEx failed\n"); 40 41 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0); 42 ok(version == 6, "Got %d, expected 6\n", version); 43 44 version = SendMessageW(hwnd, CCM_SETVERSION, 5, 0); 45 ok(version == 6, "Got %d, expected 6\n", version); 46 47 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0); 48 ok(version == 6, "Got %d, expected 6\n", version); 49 50 version = SendMessageW(hwnd, CCM_SETVERSION, 7, 0); 51 ok(version == 6, "Got %d, expected 6\n", version); 52 53 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0); 54 ok(version == 6, "Got %d, expected 6\n", version); 55 56 version = SendMessageW(hwnd, CCM_SETVERSION, 4, 0); 57 ok(version == 6, "Got %d, expected 6\n", version); 58 59 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0); 60 ok(version == 6, "Got %d, expected 6\n", version); 61 62 DestroyWindow(hwnd); 63 } 64 65 void TestSetButtonSize() 66 { 67 HWND hwnd; 68 LRESULT bsize; 69 70 hwnd = CreateWindowExW(0, TOOLBARCLASSNAMEW, L"Test", 0, 0, 0, 0, 0, 0, 0, 0, NULL); 71 ok(hwnd != NULL, "CreateWindowEx failed\n"); 72 73 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 74 ok(bsize == 0x160017, "Expected 0x160017 got %lx\n", bsize); 75 76 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, MAKELONG(0, 0)); 77 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 78 ok(bsize == 0x160018, "Expected 0x160018 got %lx\n", bsize); 79 80 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x10001); 81 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 82 ok(bsize == 0x160017, "Expected 0x160017 got %lx\n", bsize); 83 84 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x100001); 85 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 86 ok(bsize == 0x160017, "Expected 0x160017 got %lx\n", bsize); 87 88 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x160017); 89 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 90 ok(bsize == 0x160017, "Expected 0x160017 got %lx\n", bsize); 91 92 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x170017); 93 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 94 ok(bsize == 0x170017, "Expected 0x170017 got %lx\n", bsize); 95 96 DestroyWindow(hwnd); 97 } 98 99 void TestPadding() 100 { 101 HWND hwnd; 102 LRESULT bsize; 103 104 hwnd = CreateWindowExW(0, TOOLBARCLASSNAMEW, L"Test", 0, 0, 0, 0, 0, 0, 0, 0, NULL); 105 ok(hwnd != NULL, "CreateWindowEx failed\n"); 106 107 bsize = SendMessageW(hwnd, TB_GETPADDING, 0, 0); 108 ok(bsize == 0x60007, "Expected 0x60007 got %lx\n", bsize); 109 110 SendMessageW(hwnd, TB_SETPADDING, 0, 0x10001); 111 SendMessageW(hwnd, TB_SETBITMAPSIZE, 0, 0x10001); 112 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x10001); 113 114 bsize = SendMessageW(hwnd, TB_GETPADDING, 0, 0); 115 ok(bsize == 0x10001, "Expected 0x10001 got %lx\n", bsize); 116 117 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 118 ok(bsize == 0x20002, "Expected 0x20002 got %lx\n", bsize); 119 120 #if 0 /* Luna specific */ 121 SetWindowTheme(hwnd, L"TaskBand", NULL); 122 123 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 124 ok(bsize == 0x20002, "Expected 0x20002 got %lx\n", bsize); 125 126 bsize = SendMessageW(hwnd, TB_GETPADDING, 0, 0); 127 ok(bsize == 0x10001, "Expected 0x10001 got %lx\n", bsize); 128 129 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x10001); 130 131 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 132 ok(bsize == 0x160006, "Expected 0x160006 got %lx\n", bsize); 133 134 bsize = SendMessageW(hwnd, TB_GETPADDING, 0, 0); 135 ok(bsize == 0x10001, "Expected 0x10001 got %lx\n", bsize); 136 137 SendMessageW(hwnd, TB_SETPADDING, 0, 0x10001); 138 SendMessageW(hwnd, TB_SETBITMAPSIZE, 0, 0x10001); 139 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x10001); 140 141 bsize = SendMessageW(hwnd, TB_GETPADDING, 0, 0); 142 ok(bsize == 0x10001, "Expected 0x10001 got %lx\n", bsize); 143 144 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 145 ok(bsize == 0x160006, "Expected 0x160006 got %lx\n", bsize); 146 147 SendMessageW(hwnd, TB_SETBITMAPSIZE, 0, 0x10001); 148 SendMessageW(hwnd, TB_SETPADDING, 0, 0x20002); 149 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x10001); 150 151 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 152 ok(bsize == 0x170007, "Expected 0x170007 got %lx\n", bsize); 153 154 SendMessageW(hwnd, TB_SETBITMAPSIZE, 0, 0x20002); 155 SendMessageW(hwnd, TB_SETPADDING, 0, 0x20002); 156 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x10001); 157 158 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 159 ok(bsize == 0x170008, "Expected 0x170008 got %lx\n", bsize); 160 161 SendMessageW(hwnd, TB_SETBITMAPSIZE, 0, 0x100010); 162 SendMessageW(hwnd, TB_SETPADDING, 0, 0x20002); 163 SendMessageW(hwnd, TB_SETBUTTONSIZE, 0, 0x10001); 164 165 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0); 166 167 /* With a big enough image size the button size is bitmap size + pading + theme content margins */ 168 ok(bsize == 0x1a0016, "Expected 0x1a0016 got %lx\n", bsize); 169 #endif 170 171 DestroyWindow(hwnd); 172 } 173 174 void TestButtonSpacing() 175 { 176 HWND hwnd; 177 TBMETRICS metrics; 178 LRESULT lres; 179 180 hwnd = CreateWindowExW(0, TOOLBARCLASSNAMEW, L"Test", 0, 0, 0, 0, 0, 0, 0, 0, NULL); 181 ok(hwnd != NULL, "CreateWindowEx failed\n"); 182 183 memset(&metrics, 0, sizeof(metrics)); 184 lres = SendMessageW(hwnd, TB_GETMETRICS, 0, (LPARAM)&metrics); 185 ok (lres == 0, "Got %d result\n", (int)lres); 186 ok (metrics.dwMask == 0, "Got %lu\n", metrics.dwMask); 187 ok (metrics.cxPad == 0, "Got %d\n", metrics.cxPad); 188 189 metrics.cbSize = sizeof(metrics); 190 metrics.dwMask = TBMF_PAD|TBMF_BARPAD|TBMF_BUTTONSPACING; 191 lres = SendMessageW(hwnd, TB_GETMETRICS, 0, (LPARAM)&metrics); 192 ok (lres == 0, "Got %lu result\n", lres); 193 ok (metrics.dwMask == (TBMF_PAD|TBMF_BARPAD|TBMF_BUTTONSPACING), "Got %lu\n", metrics.dwMask); 194 ok (metrics.cxPad == 7, "Got %d\n", metrics.cxPad); 195 ok (metrics.cyPad == 6, "Got %d\n", metrics.cyPad); 196 ok (metrics.cxButtonSpacing == 0, "Got %d\n", metrics.cxButtonSpacing); 197 ok (metrics.cyButtonSpacing == 0, "Got %d\n", metrics.cyButtonSpacing); 198 } 199 200 void TestV5VersionMessage() 201 { 202 HWND hwnd; 203 int version; 204 205 hwnd = CreateWindowExW(0, TOOLBARCLASSNAMEW, L"Test", 0, 0, 0, 0, 0, 0, 0, 0, NULL); 206 ok(hwnd != NULL, "CreateWindowEx failed\n"); 207 208 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0); 209 ok(version == 0, "Got %d, expected 0\n", version); 210 211 version = SendMessageW(hwnd, CCM_SETVERSION, 6, 0); 212 ok(version == -1, "Got %d, expected -1\n", version); 213 214 version = SendMessageW(hwnd, CCM_SETVERSION, 7, 0); 215 ok(version == -1, "Got %d, expected -1\n", version); 216 217 version = SendMessageW(hwnd, CCM_SETVERSION, 5, 0); 218 ok(version == 0, "Got %d, expected -1\n", version); 219 220 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0); 221 ok(version == 5, "Got %d, expected 5\n", version); 222 223 version = SendMessageW(hwnd, CCM_SETVERSION, 4, 0); 224 ok(version == 5, "Got %d, expected -1\n", version); 225 226 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0); 227 ok(version == 4, "Got %d, expected 5\n", version); 228 229 version = SendMessageW(hwnd, CCM_SETVERSION, 3, 0); 230 ok(version == 4, "Got %d, expected -1\n", version); 231 232 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0); 233 ok(version == 3, "Got %d, expected 5\n", version); 234 235 DestroyWindow(hwnd); 236 } 237 238 START_TEST(toolbar) 239 { 240 HANDLE hV5ActCtx; 241 242 LoadLibraryW(L"comctl32.dll"); 243 244 TestVersionMessage(); 245 TestSetButtonSize(); 246 TestPadding(); 247 TestButtonSpacing(); 248 249 hV5ActCtx = _CreateV5ActCtx(); 250 ok (hV5ActCtx != INVALID_HANDLE_VALUE, "CreateActCtxW failed\n"); 251 if (hV5ActCtx) 252 { 253 ULONG_PTR cookie; 254 BOOL bActivated = ActivateActCtx(hV5ActCtx, &cookie); 255 if (bActivated) 256 { 257 TestV5VersionMessage(); 258 DeactivateActCtx(0, cookie); 259 } 260 } 261 }