configure: Changes from running autconf after previous patch.
[wine/hacks.git] / dlls / oleacc / tests / main.c
blobdb7ee9e5dfb602b8af63bc2920188db6c5332f8f
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] == '*' ||
37 broken(buf[0] == 0), /* Win98 and WinMe */
38 "GetRoleTextA modified buffer on wrong role number\n");
39 buf[0] = '*';
40 ret = GetRoleTextA(-1, buf, 0);
41 ok(ret == 0, "GetRoleTextA doesn't return zero on wrong role number, got %d\n", ret);
42 ok(buf[0] == '*', "GetRoleTextA modified buffer on wrong role number\n");
44 ret = GetRoleTextW(-1, NULL, 0);
45 ok(ret == 0, "GetRoleTextW doesn't return zero on wrong role number, got %d\n", ret);
46 bufW[0] = '*';
47 ret = GetRoleTextW(-1, bufW, 2);
48 ok(ret == 0, "GetRoleTextW doesn't return zero on wrong role number, got %d\n", ret);
49 ok(bufW[0] == '\0' ||
50 broken(bufW[0] == '*'), /* Win98 and WinMe */
51 "GetRoleTextW doesn't return NULL char on wrong role number\n");
52 bufW[0] = '*';
53 ret = GetRoleTextW(-1, bufW, 0);
54 ok(ret == 0, "GetRoleTextW doesn't return zero on wrong role number, got %d\n", ret);
56 /* zero role number - not documented */
57 ret = GetRoleTextA(0, NULL, 0);
58 ok(ret > 0, "GetRoleTextA doesn't return (>0) for zero role number, got %d\n", ret);
59 ret = GetRoleTextW(0, NULL, 0);
60 ok(ret > 0, "GetRoleTextW doesn't return (>0) for zero role number, got %d\n", ret);
62 /* NULL buffer, return length */
63 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, NULL, 0);
64 ok(ret > 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret);
65 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, NULL, 1);
66 ok(ret > 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret);
67 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, NULL, 0);
68 ok(ret > 0, "GetRoleTextW doesn't return length on NULL buffer, got %d\n", ret);
69 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, NULL, 1);
70 ok(ret > 0, "GetRoleTextW doesn't return length on NULL buffer, got %d\n", ret);
72 /* use a smaller buffer */
73 buf[0] = '*';
74 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buf, 1);
75 ok(ret == 0, "GetRoleTextA returned wrong length\n");
76 ok(buf[0] == '\0', "GetRoleTextA returned not zero-length buffer\n");
77 buf[1] = '*';
78 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buf, 2);
79 ok(ret == 1 ||
80 ret == 0, /* Vista and W2K8 */
81 "GetRoleTextA returned wrong length, got %d, expected 0 or 1\n", ret);
82 if (ret == 1)
83 ok(buf[1] == '\0', "GetRoleTextA returned not zero-length buffer : (%c)\n", buf[1]);
85 bufW[0] = '*';
86 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, bufW, 1);
87 ok(ret == 0, "GetRoleTextW returned wrong length, got %d, expected 1\n", ret);
88 ok(bufW[0] == '\0', "GetRoleTextW returned not zero-length buffer\n");
89 bufW[1] = '*';
90 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, bufW, 2);
91 ok(ret == 1, "GetRoleTextW returned wrong length, got %d, expected 1\n", ret);
92 ok(bufW[1] == '\0', "GetRoleTextW returned not zero-length buffer\n");
94 /* use bigger buffer */
95 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, NULL, 0);
96 buff = HeapAlloc(GetProcessHeap(), 0, 2*ret);
97 buff[2*ret-1] = '*';
98 ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buff, 2*ret);
99 ok(buff[2*ret-1] == '*', "GetRoleTextA shouldn't modify this part of buffer\n");
100 HeapFree(GetProcessHeap(), 0, buff);
102 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, NULL, 0);
103 buffW = HeapAlloc(GetProcessHeap(), 0, 2*ret*sizeof(WCHAR));
104 buffW[2*ret-1] = '*';
105 ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, buffW, 2*ret);
106 ok(buffW[2*ret-1] == '*', "GetRoleTextW shouldn't modify this part of buffer\n");
107 HeapFree(GetProcessHeap(), 0, buffW);
109 /* check returned length for all roles */
110 for(role = 0; role <= ROLE_SYSTEM_OUTLINEBUTTON; role++){
111 CHAR buff2[100];
112 WCHAR buff2W[100];
114 /* NT4 and W2K don't clear the buffer on a nonexistent role in the A-call */
115 memset(buff2, 0, sizeof(buff2));
117 ret = GetRoleTextA(role, NULL, 0);
118 /* Win98 up to W2K miss some of the roles */
119 if (role >= ROLE_SYSTEM_SPLITBUTTON)
120 ok(ret > 0 || broken(ret == 0), "Expected the role %d to be present\n", role);
121 else
122 ok(ret > 0, "Expected the role to be present\n");
124 GetRoleTextA(role, buff2, sizeof(buff2));
125 ok(ret == lstrlenA(buff2),
126 "GetRoleTextA: returned length doesn't match returned buffer for role %d\n", role);
128 /* Win98 and WinMe don't clear the buffer on a nonexistent role in the W-call */
129 memset(buff2W, 0, sizeof(buff2W));
131 ret = GetRoleTextW(role, NULL, 0);
132 GetRoleTextW(role, buff2W, sizeof(buff2W)/sizeof(WCHAR));
133 ok(ret == lstrlenW(buff2W),
134 "GetRoleTextW: returned length doesn't match returned buffer for role %d\n", role);
138 START_TEST(main)
140 test_getroletext();