2 * Tests for ICM functions
4 * Copyright (C) 2005, 2008 Hans Leidekker
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
28 #include "wine/test.h"
30 static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
32 static void test_GetICMProfileA( HDC dc )
36 char filename[MAX_PATH];
38 SetLastError( 0xdeadbeef );
39 ret = GetICMProfileA( NULL, NULL, NULL );
40 if ( !ret && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
42 win_skip( "GetICMProfileA is not implemented\n" );
45 ok( !ret, "GetICMProfileA succeeded\n" );
47 ret = GetICMProfileA( dc, NULL, NULL );
48 ok( !ret, "GetICMProfileA succeeded\n" );
51 ret = GetICMProfileA( dc, &size, NULL );
52 ok( !ret, "GetICMProfileA succeeded\n" );
55 ret = GetICMProfileA( NULL, &size, filename );
56 ok( !ret, "GetICMProfileA succeeded\n" );
60 SetLastError(0xdeadbeef);
61 ret = GetICMProfileA( dc, &size, filename );
62 error = GetLastError();
63 ok( !ret, "GetICMProfileA succeeded\n" );
64 ok( size, "expected size > 0\n" );
65 ok( filename[0] == 0, "Expected filename to be empty\n" );
66 ok( error == ERROR_INSUFFICIENT_BUFFER ||
67 error == ERROR_SUCCESS, /* Win95 */
68 "got %d, expected ERROR_INSUFFICIENT_BUFFER or ERROR_SUCCESS(Win95)\n", error );
70 /* Next test will crash on Win95 */
71 if ( error == ERROR_INSUFFICIENT_BUFFER )
73 ret = GetICMProfileA( dc, NULL, filename );
74 ok( !ret, "GetICMProfileA succeeded\n" );
78 ret = GetICMProfileA( dc, &size, filename );
79 ok( ret, "GetICMProfileA failed %d\n", GetLastError() );
81 trace( "%s\n", filename );
84 static void test_GetICMProfileW( HDC dc )
88 WCHAR filename[MAX_PATH];
90 SetLastError( 0xdeadbeef );
91 ret = GetICMProfileW( NULL, NULL, NULL );
92 if ( !ret && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
94 win_skip( "GetICMProfileW is not implemented\n" );
97 ok( !ret, "GetICMProfileW succeeded\n" );
99 ret = GetICMProfileW( dc, NULL, NULL );
100 ok( !ret, "GetICMProfileW succeeded\n" );
106 ret = GetICMProfileW( dc, &size, NULL );
107 ok( ret, "GetICMProfileW failed %d\n", GetLastError() );
110 ret = GetICMProfileW( dc, NULL, filename );
111 ok( !ret, "GetICMProfileW succeeded\n" );
114 ret = GetICMProfileW( NULL, &size, filename );
115 ok( !ret, "GetICMProfileW succeeded\n" );
118 SetLastError(0xdeadbeef);
119 ret = GetICMProfileW( dc, &size, filename );
120 error = GetLastError();
121 ok( !ret, "GetICMProfileW succeeded\n" );
122 ok( size, "expected size > 0\n" );
123 ok( error == ERROR_INSUFFICIENT_BUFFER, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error );
126 ret = GetICMProfileW( dc, &size, filename );
127 ok( ret, "GetICMProfileW failed %d\n", GetLastError() );
130 static void test_SetICMMode( HDC dc )
135 SetLastError( 0xdeadbeef );
136 impl = GetICMProfileA( NULL, NULL, NULL );
137 if ( !impl && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
139 win_skip( "On NT4 where SetICMMode is not implemented but this is not advertised\n" );
143 SetLastError( 0xdeadbeef );
144 ret = SetICMMode( NULL, 0 );
145 ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
147 ret = SetICMMode( dc, -1 );
148 ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
150 save = SetICMMode( dc, ICM_QUERY );
151 ok( save == ICM_ON || save == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
153 if (save == ICM_ON) knob = ICM_OFF; else knob = ICM_ON;
155 ret = SetICMMode( dc, knob );
156 todo_wine ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
158 ret = SetICMMode( dc, ICM_QUERY );
159 todo_wine ok( ret == knob, "SetICMMode failed (%d)\n", GetLastError() );
161 ret = SetICMMode( dc, save );
162 ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
164 SetLastError( 0xdeadbeef );
165 dc = CreateDCW( displayW, NULL, NULL, NULL );
166 if ( !dc && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
168 win_skip( "CreateDCW is not implemented\n" );
171 ok( dc != NULL, "CreateDCW failed (%d)\n", GetLastError() );
173 ret = SetICMMode( dc, ICM_QUERY );
174 ok( ret == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
179 static CALLBACK INT enum_profiles_callbackA( LPSTR filename, LPARAM lparam )
181 trace("%s\n", filename);
185 static void test_EnumICMProfilesA( HDC dc )
189 ret = EnumICMProfilesA( NULL, NULL, 0 );
190 ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
192 ret = EnumICMProfilesA( dc, enum_profiles_callbackA, 0 );
193 ok(ret == -1 || broken(ret == 0) /* nt4 */ || broken(ret == 1) /* win95 */,
194 "expected -1, got %d\n", ret);
198 /* Crashes on Win95 */
199 ret = EnumICMProfilesA( dc, NULL, 0 );
200 ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
204 static CALLBACK INT enum_profiles_callbackW( LPWSTR filename, LPARAM lparam )
209 static void test_EnumICMProfilesW( HDC dc )
213 ret = EnumICMProfilesW( NULL, NULL, 0 );
214 ok(ret == -1 || broken(ret == 0) /* win9x, nt4 */, "expected -1, got %d\n", ret);
216 ret = EnumICMProfilesW( dc, NULL, 0 );
217 ok(ret == -1 || broken(ret == 0) /* win9x, nt4 */, "expected -1, got %d\n", ret);
219 ret = EnumICMProfilesW( dc, enum_profiles_callbackW, 0 );
220 ok(ret == -1 || broken(ret == 0) /* win9x, nt4 */, "expected -1, got %d\n", ret);
223 static void test_SetICMProfileA( HDC dc )
226 char profile[MAX_PATH];
229 SetLastError( 0xdeadbeef );
230 ret = SetICMProfileA( NULL, NULL );
231 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
233 win_skip("SetICMProfileA is not implemented\n");
237 len = sizeof(profile);
238 ret = GetICMProfileA( dc, &len, profile );
239 ok(ret, "GetICMProfileA failed %u\n", GetLastError());
241 SetLastError( 0xdeadbeef );
242 ret = SetICMProfileA( NULL, NULL );
243 error = GetLastError();
244 ok(!ret, "SetICMProfileA succeeded\n");
245 ok(error == ERROR_INVALID_PARAMETER || broken(error == 0xdeadbeef) /* win9x */,
246 "expected ERROR_INVALID_PARAMETER, got %u\n", error);
248 SetLastError( 0xdeadbeef );
249 ret = SetICMProfileA( NULL, profile );
250 error = GetLastError();
251 ok(!ret, "SetICMProfileA succeeded\n");
252 ok(error == ERROR_INVALID_HANDLE || broken(error == 0xdeadbeef) /* win9x */,
253 "expected ERROR_INVALID_HANDLE, got %u\n", error);
255 SetLastError( 0xdeadbeef );
256 ret = SetICMProfileA( dc, NULL );
257 error = GetLastError();
258 ok(!ret, "SetICMProfileA succeeded\n");
259 ok(error == ERROR_INVALID_PARAMETER || broken(error == 0xdeadbeef) /* win95 */,
260 "expected ERROR_INVALID_PARAMETER, got %u\n", error);
262 ret = SetICMProfileA( dc, profile );
263 ok(ret, "SetICMProfileA failed %u\n", GetLastError());
266 static void test_SetICMProfileW( HDC dc )
269 WCHAR profile[MAX_PATH];
272 SetLastError( 0xdeadbeef );
273 ret = SetICMProfileW( NULL, NULL );
274 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
276 win_skip("SetICMProfileW is not implemented\n");
280 len = sizeof(profile)/sizeof(profile[0]);
281 ret = GetICMProfileW( dc, &len, profile );
282 ok(ret, "GetICMProfileW failed %u\n", GetLastError());
284 SetLastError( 0xdeadbeef );
285 ret = SetICMProfileW( NULL, NULL );
286 error = GetLastError();
287 ok(!ret, "SetICMProfileW succeeded\n");
288 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
290 SetLastError( 0xdeadbeef );
291 ret = SetICMProfileW( NULL, profile );
292 error = GetLastError();
293 ok(!ret, "SetICMProfileW succeeded\n");
294 ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
296 SetLastError( 0xdeadbeef );
297 ret = SetICMProfileW( dc, NULL );
298 error = GetLastError();
299 ok(!ret, "SetICMProfileW succeeded\n");
300 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
302 ret = SetICMProfileW( dc, profile );
303 ok(ret, "SetICMProfileW failed %u\n", GetLastError());
308 HDC dc = GetDC( NULL );
310 test_GetICMProfileA( dc );
311 test_GetICMProfileW( dc );
312 test_SetICMMode( dc );
313 test_EnumICMProfilesA( dc );
314 test_EnumICMProfilesW( dc );
315 test_SetICMProfileA( dc );
316 test_SetICMProfileW( dc );
318 ReleaseDC( NULL, dc );