5c2bb093a315fe0c45caf76f02459cec83bed59e
[reactos.git] / rostests / apitests / comctl32 / toolbar.c
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 TestV5VersionMessage()
66 {
67 HWND hwnd;
68 int version;
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 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0);
74 ok(version == 0, "Got %d, expected 0\n", version);
75
76 version = SendMessageW(hwnd, CCM_SETVERSION, 6, 0);
77 ok(version == -1, "Got %d, expected -1\n", version);
78
79 version = SendMessageW(hwnd, CCM_SETVERSION, 7, 0);
80 ok(version == -1, "Got %d, expected -1\n", version);
81
82 version = SendMessageW(hwnd, CCM_SETVERSION, 5, 0);
83 ok(version == 0, "Got %d, expected -1\n", version);
84
85 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0);
86 ok(version == 5, "Got %d, expected 5\n", version);
87
88 version = SendMessageW(hwnd, CCM_SETVERSION, 4, 0);
89 ok(version == 5, "Got %d, expected -1\n", version);
90
91 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0);
92 ok(version == 4, "Got %d, expected 5\n", version);
93
94 version = SendMessageW(hwnd, CCM_SETVERSION, 3, 0);
95 ok(version == 4, "Got %d, expected -1\n", version);
96
97 version = SendMessageW(hwnd, CCM_GETVERSION, 0, 0);
98 ok(version == 3, "Got %d, expected 5\n", version);
99
100 DestroyWindow(hwnd);
101 }
102
103 START_TEST(toolbar)
104 {
105 HANDLE hV5ActCtx;
106
107 LoadLibraryW(L"comctl32.dll");
108
109 TestVersionMessage();
110
111 hV5ActCtx = _CreateV5ActCtx();
112 ok (hV5ActCtx != INVALID_HANDLE_VALUE, "CreateActCtxW failed\n");
113 if (hV5ActCtx)
114 {
115 ULONG_PTR cookie;
116 BOOL bActivated = ActivateActCtx(hV5ActCtx, &cookie);
117 if (bActivated)
118 {
119 TestV5VersionMessage();
120 DeactivateActCtx(0, cookie);
121 }
122 }
123 }