ReactOS 0.4.16-dev-320-g3bd9ddc
toolbar.c
Go to the documentation of this file.
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
18{
19 ACTCTXW ActCtx = {sizeof(ACTCTX)};
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
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
42 ok(version == 6, "Got %d, expected 6\n", version);
43
45 ok(version == 6, "Got %d, expected 6\n", version);
46
48 ok(version == 6, "Got %d, expected 6\n", version);
49
51 ok(version == 6, "Got %d, expected 6\n", version);
52
54 ok(version == 6, "Got %d, expected 6\n", version);
55
57 ok(version == 6, "Got %d, expected 6\n", version);
58
60 ok(version == 6, "Got %d, expected 6\n", version);
61
63}
64
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
77 bsize = SendMessageW(hwnd, TB_GETBUTTONSIZE, 0, 0);
78 ok(bsize == 0x160018, "Expected 0x160018 got %lx\n", bsize);
79
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
97}
98
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 || bsize == 0xe0002, "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
172}
173
175{
176 HWND hwnd;
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));
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);
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
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
209 ok(version == 0, "Got %d, expected 0\n", version);
210
212 ok(version == -1, "Got %d, expected -1\n", version);
213
215 ok(version == -1, "Got %d, expected -1\n", version);
216
218 ok(version == 0, "Got %d, expected -1\n", version);
219
221 ok(version == 5, "Got %d, expected 5\n", version);
222
224 ok(version == 5, "Got %d, expected -1\n", version);
225
227 ok(version == 4, "Got %d, expected 5\n", version);
228
230 ok(version == 4, "Got %d, expected -1\n", version);
231
233 ok(version == 3, "Got %d, expected 5\n", version);
234
236}
237
239{
240 HANDLE hV5ActCtx;
241
242 LoadLibraryW(L"comctl32.dll");
243
246 TestPadding();
248
249 hV5ActCtx = _CreateV5ActCtx();
250 ok (hV5ActCtx != INVALID_HANDLE_VALUE, "CreateActCtxW failed\n");
251 if (hV5ActCtx)
252 {
254 BOOL bActivated = ActivateActCtx(hV5ActCtx, &cookie);
255 if (bActivated)
256 {
259 }
260 }
261}
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define wcsrchr
Definition: compat.h:16
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define LoadLibraryW(x)
Definition: compat.h:747
static const WCHAR version[]
Definition: asmname.c:66
static const WCHAR separator[]
Definition: asmname.c:65
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
Definition: actctx.c:102
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint buffer
Definition: glext.h:5915
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:247
void TestButtonSpacing()
Definition: toolbar.c:174
HANDLE _CreateV5ActCtx()
Definition: toolbar.c:17
void TestVersionMessage()
Definition: toolbar.c:33
void TestV5VersionMessage()
Definition: toolbar.c:200
void TestSetButtonSize()
Definition: toolbar.c:65
void TestPadding()
Definition: toolbar.c:99
#define L(x)
Definition: ntvdm.h:50
#define TB_GETMETRICS
Definition: commctrl.h:1302
#define TB_SETPADDING
Definition: commctrl.h:1193
#define CCM_GETVERSION
Definition: commctrl.h:115
#define TB_GETBUTTONSIZE
Definition: commctrl.h:1160
#define TB_SETBUTTONSIZE
Definition: commctrl.h:1135
#define TOOLBARCLASSNAMEW
Definition: commctrl.h:943
#define TBMF_BUTTONSPACING
Definition: commctrl.h:1289
#define TB_SETBITMAPSIZE
Definition: commctrl.h:1136
#define CCM_SETVERSION
Definition: commctrl.h:114
#define TBMF_PAD
Definition: commctrl.h:1287
#define TB_GETPADDING
Definition: commctrl.h:1192
#define TBMF_BARPAD
Definition: commctrl.h:1288
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define memset(x, y, z)
Definition: compat.h:39
Definition: cookie.c:34
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MAKELONG(a, b)
Definition: typedefs.h:249
HRESULT WINAPI SetWindowTheme(_In_ HWND hwnd, _In_ LPCWSTR pszSubAppName, _In_ LPCWSTR pszSubIdList)
Definition: uxthemesupp.c:69
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI DestroyWindow(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180