push ada2d4f150af430b0cf01adcbe8b6d3e34deeeb1
[wine/hacks.git] / dlls / oleacc / tests / main.c
blobbd002944b0c1645c6c090144662cdfc234b0d8fd
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;
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);
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);
52 /* zero role number - not documented */
53 ret = GetRoleTextA(0, NULL, 0);
54 ok(ret > 0, "GetRoleTextA doesn't return (>0) for zero role number, got %d\n", ret);
55 ret = GetRoleTextW(0, NULL, 0);
56 ok(ret > 0, "GetRoleTextW doesn't return (>0) for zero role number, got %d\n", ret);
58 /* NULL buffer, return length */
59 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, NULL, 0);
60 ok(ret > 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret);
61 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, NULL, 1);
62 ok(ret > 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret);
63 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, NULL, 0);
64 ok(ret > 0, "GetRoleTextW doesn't return length on NULL buffer, got %d\n", ret);
65 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, NULL, 1);
66 ok(ret > 0, "GetRoleTextW doesn't return length on NULL buffer, got %d\n", ret);
68 /* use a smaller buffer */
69 buf[0] = '*';
70 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buf, 1);
71 ok(ret == 0, "GetRoleTextA returned wrong length\n");
72 ok(buf[0] == '\0', "GetRoleTextA returned not zero-length buffer\n");
73 buf[1] = '*';
74 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buf, 2);
75 ok(ret == 1, "GetRoleTextA returned wrong length, got %d, expected 1\n", ret);
76 ok(buf[1] == '\0', "GetRoleTextA returned not zero-length buffer\n");
78 bufW[0] = '*';
79 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, bufW, 1);
80 ok(ret == 0, "GetRoleTextW returned wrong length, got %d, expected 1\n", ret);
81 ok(bufW[0] == '\0', "GetRoleTextW returned not zero-length buffer\n");
82 bufW[1] = '*';
83 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, bufW, 2);
84 ok(ret == 1, "GetRoleTextW returned wrong length, got %d, expected 1\n", ret);
85 ok(bufW[1] == '\0', "GetRoleTextW returned not zero-length buffer\n");
87 /* use bigger buffer */
88 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, NULL, 0);
89 buff = HeapAlloc(GetProcessHeap(), 0, 2*ret);
90 buff[2*ret-1] = '*';
91 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buff, 2*ret);
92 ok(buff[2*ret-1] == '*', "GetRoleTextA shouldn't modify this part of buffer\n");
93 HeapFree(GetProcessHeap(), 0, buff);
95 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, NULL, 0);
96 buffW = HeapAlloc(GetProcessHeap(), 0, 2*ret*sizeof(WCHAR));
97 buffW[2*ret-1] = '*';
98 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, buffW, 2*ret);
99 ok(buffW[2*ret-1] == '*', "GetRoleTextW shouldn't modify this part of buffer\n");
100 HeapFree(GetProcessHeap(), 0, buffW);
102 /* check returned length for all roles */
103 for(role = 0; role <= ROLE_SYSTEM_OUTLINEBUTTON; role++){
104 CHAR buff2[100];
105 WCHAR buff2W[100];
107 /* NT4 and W2K don't clear the buffer on a non existing role in the A-call */
108 memset(buff2, 0, sizeof(buff2));
110 ret = GetRoleTextA(role, NULL, 0);
111 /* Win98 up to W2K miss some of the roles */
112 if (role >= ROLE_SYSTEM_SPLITBUTTON)
113 ok(ret > 0 || broken(ret == 0), "Expected the role %d to be present\n", role);
114 else
115 ok(ret > 0, "Expected the role to be present\n");
117 GetRoleTextA(role, buff2, sizeof(buff2));
118 ok(ret == lstrlenA(buff2),
119 "GetRoleTextA: returned length doesn't match returned buffer for role %d\n", role);
121 /* Win98 and WinMe don't clear the buffer on a non existing role in the W-call */
122 memset(buff2W, 0, sizeof(buff2W));
124 ret = GetRoleTextW(role, NULL, 0);
125 GetRoleTextW(role, buff2W, sizeof(buff2W)/sizeof(WCHAR));
126 ok(ret == lstrlenW(buff2W),
127 "GetRoleTextW: returned length doesn't match returned buffer for role %d\n", role);
131 START_TEST(main)
133 test_getroletext();