1 /* Unit tests for treeview.
3 * Copyright 2005 Krzysztof Foltman
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/test.h"
33 static void MakeButton(TBBUTTON *p, int idCommand, int fsStyle, int nString) {
35 p->idCommand = idCommand;
36 p->fsState = TBSTATE_ENABLED;
41 static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
51 MakeButton(buttons+i, 1000+i, TBSTYLE_CHECKGROUP, 0);
52 MakeButton(buttons+3, 1003, TBSTYLE_SEP|TBSTYLE_GROUP, 0);
53 MakeButton(buttons+6, 1006, TBSTYLE_SEP, 0);
55 hToolbar = CreateToolbarEx(hWnd,
56 WS_VISIBLE | WS_CLIPCHILDREN | CCS_TOP |
57 WS_CHILD | TBSTYLE_LIST,
60 buttons, sizeof(buttons)/sizeof(buttons[0]),
61 0, 0, 20, 16, sizeof(TBBUTTON));
62 ok(hToolbar != NULL, "Toolbar creation\n");
64 SendMessage(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)"test\000");
66 /* test for exclusion working inside a separator-separated :-) group */
67 SendMessage(hToolbar, TB_CHECKBUTTON, 1000, 1); /* press A1 */
68 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 pressed\n");
69 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1001, 0), "A2 not pressed\n");
71 SendMessage(hToolbar, TB_CHECKBUTTON, 1004, 1); /* press A5, release A1 */
72 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1004, 0), "A5 pressed\n");
73 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 not pressed anymore\n");
75 SendMessage(hToolbar, TB_CHECKBUTTON, 1005, 1); /* press A6, release A5 */
76 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 pressed\n");
77 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1004, 0), "A5 not pressed anymore\n");
79 /* test for inter-group crosstalk, ie. two radio groups interfering with each other */
80 SendMessage(hToolbar, TB_CHECKBUTTON, 1007, 1); /* press B2 */
81 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 still pressed, no inter-group crosstalk\n");
82 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 still not pressed\n");
83 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1007, 0), "B2 pressed\n");
85 SendMessage(hToolbar, TB_CHECKBUTTON, 1000, 1); /* press A1 and ensure B group didn't suffer */
86 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 not pressed anymore\n");
87 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 pressed\n");
88 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1007, 0), "B2 still pressed\n");
90 SendMessage(hToolbar, TB_CHECKBUTTON, 1008, 1); /* press B3, and ensure A group didn't suffer */
91 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 pressed\n");
92 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 pressed\n");
93 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1007, 0), "B2 not pressed\n");
94 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1008, 0), "B3 pressed\n");
95 PostMessage(hWnd, WM_CLOSE, 0, 0);
103 return DefWindowProcA(hWnd, msg, wParam, lParam);
115 InitCommonControls();
117 wc.style = CS_HREDRAW | CS_VREDRAW;
120 wc.hInstance = GetModuleHandleA(NULL);
122 wc.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_IBEAM));
123 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
124 wc.lpszMenuName = NULL;
125 wc.lpszClassName = "MyTestWnd";
126 wc.lpfnWndProc = MyWndProc;
129 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
130 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
131 GetClientRect(hMainWnd, &rc);
133 while(GetMessageA(&msg,0,0,0)) {
134 TranslateMessage(&msg);
135 DispatchMessageA(&msg);