1 /* Unit test suite for status control.
3 * Copyright 2007 Google (Lei Zhang)
4 * Copyright 2007 Alex Arazi
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
27 #define expect(expected,got) ok (expected == got,"Expected %d, got %d\n",expected,got);
29 static HINSTANCE hinst
;
31 static HWND
create_status_control(DWORD style
, DWORD exstyle
)
35 /* make the control */
36 hWndStatus
= CreateWindowEx(exstyle
, STATUSCLASSNAME
, NULL
, style
,
40 NULL
, NULL
, hinst
, NULL
);
45 static void test_status_control(void)
49 int nParts
[] = {50, 150, -1};
50 int checkParts
[] = {0, 0, 0};
51 int borders
[] = {0, 0, 0};
56 hWndStatus
= create_status_control(WS_VISIBLE
, 0);
58 /* Divide into parts and set text */
59 r
= SendMessage(hWndStatus
, SB_SETPARTS
, 3, (long)nParts
);
61 r
= SendMessage(hWndStatus
, SB_SETTEXT
, 0, (LPARAM
)"First");
63 r
= SendMessage(hWndStatus
, SB_SETTEXT
, 1, (LPARAM
)"Second");
65 r
= SendMessage(hWndStatus
, SB_SETTEXT
, 2, (LPARAM
)"Third");
68 /* Get RECT Information */
69 r
= SendMessage(hWndStatus
, SB_GETRECT
, 0, (LPARAM
)&rc
);
72 /* The rc.bottom test is system dependent
73 expect(22,rc.bottom); */
76 r
= SendMessage(hWndStatus
, SB_GETRECT
, -1, (LPARAM
)&rc
);
78 r
= SendMessage(hWndStatus
, SB_GETRECT
, 3, (LPARAM
)&rc
);
80 /* Get text length and text */
81 r
= SendMessage(hWndStatus
, SB_GETTEXTLENGTH
, 2, 0);
84 r
= SendMessage(hWndStatus
, SB_GETTEXT
, 2, (LPARAM
) charArray
);
85 ok(strcmp(charArray
,"Third") == 0, "Expected Third, got %s\n", charArray
);
89 /* Get parts and borders */
90 r
= SendMessage(hWndStatus
, SB_GETPARTS
, 3, (long)checkParts
);
91 ok(r
== 3, "Expected 3, got %d\n", r
);
92 expect(50,checkParts
[0]);
93 expect(150,checkParts
[1]);
94 expect(-1,checkParts
[2]);
95 r
= SendMessage(hWndStatus
, SB_GETBORDERS
, 0, (long)borders
);
96 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
101 /* Test resetting text with different characters */
102 r
= SendMessage(hWndStatus
, SB_SETTEXT
, 0, (LPARAM
)"First@Again");
104 r
= SendMessage(hWndStatus
, SB_SETTEXT
, 1, (LPARAM
)"InvalidChars\\7\7");
106 r
= SendMessage(hWndStatus
, SB_SETTEXT
, 2, (LPARAM
)"InvalidChars\\n\n");
110 r
= SendMessage(hWndStatus
, SB_GETTEXT
, 0, (LPARAM
) charArray
);
111 ok(strcmp(charArray
,"First@Again") == 0, "Expected First@Again, got %s\n", charArray
);
112 expect(11,LOWORD(r
));
114 r
= SendMessage(hWndStatus
, SB_GETTEXT
, 1, (LPARAM
) charArray
);
117 ok(strcmp(charArray
,"InvalidChars\\7 ") == 0, "Expected InvalidChars\\7 , got %s\n", charArray
);
119 expect(15,LOWORD(r
));
121 r
= SendMessage(hWndStatus
, SB_GETTEXT
, 2, (LPARAM
) charArray
);
124 ok(strcmp(charArray
,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray
);
126 expect(15,LOWORD(r
));
129 /* Set background color */
130 r
= SendMessage(hWndStatus
, SB_SETBKCOLOR
, 0, RGB(255,0,0));
131 expect(CLR_DEFAULT
,r
);
132 r
= SendMessage(hWndStatus
, SB_SETBKCOLOR
, 0, CLR_DEFAULT
);
133 expect(RGB(255,0,0),r
);
135 /* Add an icon to the status bar */
136 hIcon
= LoadIcon(NULL
, IDI_QUESTION
);
137 r
= SendMessage(hWndStatus
, SB_SETICON
, 1, (LPARAM
) NULL
);
138 ok(r
!= 0, "Expected non-zero, got %d\n", r
);
139 r
= SendMessage(hWndStatus
, SB_SETICON
, 1, (LPARAM
) hIcon
);
140 ok(r
!= 0, "Expected non-zero, got %d\n", r
);
141 r
= SendMessage(hWndStatus
, SB_SETICON
, 1, (LPARAM
) NULL
);
142 ok(r
!= 0, "Expected non-zero, got %d\n", r
);
144 /* Set the Unicode format */
145 r
= SendMessage(hWndStatus
, SB_SETUNICODEFORMAT
, FALSE
, 0);
146 r
= SendMessage(hWndStatus
, SB_GETUNICODEFORMAT
, 0, 0);
148 r
= SendMessage(hWndStatus
, SB_SETUNICODEFORMAT
, TRUE
, 0);
150 r
= SendMessage(hWndStatus
, SB_GETUNICODEFORMAT
, 0, 0);
153 /* Reset number of parts */
154 r
= SendMessage(hWndStatus
, SB_SETPARTS
, 2, (long)nParts
);
157 /* Set the minimum height and get rectangle information again */
158 SendMessage(hWndStatus
, SB_SETMINHEIGHT
, 50, (LPARAM
) 0);
159 r
= SendMessage(hWndStatus
, WM_SIZE
, 0, (LPARAM
) 0);
161 r
= SendMessage(hWndStatus
, SB_GETRECT
, 0, (LPARAM
)&rc
);
164 /* The rc.bottom test is system dependent
165 expect(22,rc.bottom); */
168 r
= SendMessage(hWndStatus
, SB_GETRECT
, -1, (LPARAM
)&rc
);
170 r
= SendMessage(hWndStatus
, SB_GETRECT
, 3, (LPARAM
)&rc
);
173 /* Set the ToolTip text */
176 SendMessage(hWndStatus
, SB_SETTIPTEXT
, 0,(LPARAM
) "Tooltip Text");
177 SendMessage(hWndStatus
, SB_GETTIPTEXT
, MAKEWPARAM (0, 20),(LPARAM
) charArray
);
178 ok(strcmp(charArray
,"Tooltip Text") == 0, "Expected Tooltip Text, got %s\n", charArray
);
182 SendMessage(hWndStatus
, SB_SIMPLE
, TRUE
, 0);
183 r
= SendMessage(hWndStatus
, SB_ISSIMPLE
, 0, 0);
186 DestroyWindow(hWndStatus
);
191 hinst
= GetModuleHandleA(NULL
);
193 InitCommonControls();
195 test_status_control();