push 8742e928a3d078c1d2cecb5ceee0ffde3118cbb7
[wine/hacks.git] / dlls / oleacc / tests / main.c
blob66b25af173741f2d8f038efac29f272f425b322e
1 /*
2 * oleacc tests
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
21 #include <oleacc.h>
22 #include "wine/test.h"
24 static void test_getroletext(void)
26 INT ret, role;
27 CHAR buf[2], *buff, buff2[100];
28 WCHAR bufW[2], *buffW, buff2W[100];
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);
33 buf[0] = '*';
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");
37 buf[0] = '*';
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);
44 bufW[0] = '*';
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");
48 bufW[0] = '*';
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 */
71 buf[0] = '*';
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");
75 buf[1] = '*';
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");
80 bufW[0] = '*';
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");
84 bufW[1] = '*';
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);
92 buff[2*ret-1] = '*';
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));
99 buffW[2*ret-1] = '*';
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++){
106 ret = GetRoleTextA(role, NULL, 0);
107 GetRoleTextA(role, buff2, sizeof(buff2));
108 ok(ret == lstrlenA(buff2),
109 "GetRoleTextA: returned length doesn't match returned buffer for role %d\n", role);
111 ret = GetRoleTextW(role, NULL, 0);
112 GetRoleTextW(role, buff2W, sizeof(buff2W)/sizeof(WCHAR));
113 ok(ret == lstrlenW(buff2W),
114 "GetRoleTextW: returned length doesn't match returned buffer for role %d\n", role);
118 START_TEST(main)
120 test_getroletext();