4 * Copyright 2008 Nikolay Sivov
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
22 #include "wine/test.h"
24 static void test_getroletext(void)
28 WCHAR bufW
[2], *buffW
;
30 /* wrong role number */
31 ret
= GetRoleTextA(-1, NULL
, 0);
32 ok(ret
== 0, "GetRoleTextA doesn't return zero on wrong role number, got %d\n", ret
);
34 ret
= GetRoleTextA(-1, buf
, 2);
35 ok(ret
== 0, "GetRoleTextA doesn't return zero on wrong role number, got %d\n", ret
);
36 ok(buf
[0] == '*', "GetRoleTextA modified buffer on wrong role number\n");
38 ret
= GetRoleTextA(-1, buf
, 0);
39 ok(ret
== 0, "GetRoleTextA doesn't return zero on wrong role number, got %d\n", ret
);
40 ok(buf
[0] == '*', "GetRoleTextA modified buffer on wrong role number\n");
42 ret
= GetRoleTextW(-1, NULL
, 0);
43 ok(ret
== 0, "GetRoleTextW doesn't return zero on wrong role number, got %d\n", ret
);
45 ret
= GetRoleTextW(-1, bufW
, 2);
46 ok(ret
== 0, "GetRoleTextW doesn't return zero on wrong role number, got %d\n", ret
);
47 ok(bufW
[0] == '\0', "GetRoleTextW doesn't return NULL char on wrong role number\n");
49 ret
= GetRoleTextW(-1, bufW
, 0);
50 ok(ret
== 0, "GetRoleTextW doesn't return zero on wrong role number, got %d\n", ret
);
51 /* don't know why this char */
52 todo_wine
ok(bufW
[0] == 0x1e90, "GetRoleTextW returned wrong char, got %u\n", bufW
[0]);
54 /* zero role number - not documented */
55 ret
= GetRoleTextA(0, NULL
, 0);
56 ok(ret
> 0, "GetRoleTextA doesn't return (>0) for zero role number, got %d\n", ret
);
57 ret
= GetRoleTextW(0, NULL
, 0);
58 ok(ret
> 0, "GetRoleTextW doesn't return (>0) for zero role number, got %d\n", ret
);
60 /* NULL buffer, return length */
61 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, NULL
, 0);
62 ok(ret
> 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret
);
63 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, NULL
, 1);
64 ok(ret
> 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret
);
65 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, NULL
, 0);
66 ok(ret
> 0, "GetRoleTextW doesn't return length on NULL buffer, got %d\n", ret
);
67 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, NULL
, 1);
68 ok(ret
> 0, "GetRoleTextW doesn't return length on NULL buffer, got %d\n", ret
);
70 /* use a smaller buffer */
72 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, buf
, 1);
73 ok(ret
== 0, "GetRoleTextA returned wrong length\n");
74 ok(buf
[0] == '\0', "GetRoleTextA returned not zero-length buffer\n");
76 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, buf
, 2);
77 ok(ret
== 1, "GetRoleTextA returned wrong length, got %d, expected 1\n", ret
);
78 ok(buf
[1] == '\0', "GetRoleTextA returned not zero-length buffer\n");
81 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, bufW
, 1);
82 ok(ret
== 0, "GetRoleTextW returned wrong length, got %d, expected 1\n", ret
);
83 ok(bufW
[0] == '\0', "GetRoleTextW returned not zero-length buffer\n");
85 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, bufW
, 2);
86 ok(ret
== 1, "GetRoleTextW returned wrong length, got %d, expected 1\n", ret
);
87 ok(bufW
[1] == '\0', "GetRoleTextW returned not zero-length buffer\n");
89 /* use bigger buffer */
90 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, NULL
, 0);
91 buff
= HeapAlloc(GetProcessHeap(), 0, 2*ret
);
93 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, buff
, 2*ret
);
94 ok(buff
[2*ret
-1] == '*', "GetRoleTextA shouldn't modify this part of buffer\n");
95 HeapFree(GetProcessHeap(), 0, buff
);
97 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, NULL
, 0);
98 buffW
= HeapAlloc(GetProcessHeap(), 0, 2*ret
*sizeof(WCHAR
));
100 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, buffW
, 2*ret
);
101 ok(buffW
[2*ret
-1] == '*', "GetRoleTextW shouldn't modify this part of buffer\n");
102 HeapFree(GetProcessHeap(), 0, buffW
);
104 /* check returned length for all roles */
105 for(role
= 0; role
<= ROLE_SYSTEM_OUTLINEBUTTON
; role
++){
109 /* NT4 and W2K don't clear the buffer on a non existing role in the A-call */
110 memset(buff2
, 0, sizeof(buff2
));
112 ret
= GetRoleTextA(role
, NULL
, 0);
113 /* Win98 up to W2K miss some of the roles */
114 if (role
>= ROLE_SYSTEM_SPLITBUTTON
)
115 ok(ret
> 0 || broken(ret
== 0), "Expected the role %d to be present\n", role
);
117 ok(ret
> 0, "Expected the role to be present\n");
119 GetRoleTextA(role
, buff2
, sizeof(buff2
));
120 ok(ret
== lstrlenA(buff2
),
121 "GetRoleTextA: returned length doesn't match returned buffer for role %d\n", role
);
123 /* Win98 and WinMe don't clear the buffer on a non existing role in the W-call */
124 memset(buff2W
, 0, sizeof(buff2W
));
126 ret
= GetRoleTextW(role
, NULL
, 0);
127 GetRoleTextW(role
, buff2W
, sizeof(buff2W
)/sizeof(WCHAR
));
128 ok(ret
== lstrlenW(buff2W
),
129 "GetRoleTextW: returned length doesn't match returned buffer for role %d\n", role
);