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
23 static const WCHAR displayW
[] = {'D','I','S','P','L','A','Y',0};
25 static void test_GetICMProfileA( HDC dc
)
29 char filename
[MAX_PATH
];
31 SetLastError( 0xdeadbeef );
32 ret
= GetICMProfileA( NULL
, NULL
, NULL
);
33 if ( !ret
&& ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) )
35 win_skip( "GetICMProfileA is not implemented\n" );
38 ok( !ret
, "GetICMProfileA succeeded\n" );
40 ret
= GetICMProfileA( dc
, NULL
, NULL
);
41 ok( !ret
, "GetICMProfileA succeeded\n" );
44 ret
= GetICMProfileA( dc
, &size
, NULL
);
45 ok( !ret
, "GetICMProfileA succeeded\n" );
46 ok( size
> 0, "got %u\n", size
);
49 ret
= GetICMProfileA( dc
, &size
, NULL
);
50 ok( !ret
, "GetICMProfileA succeeded\n" );
51 ok( size
> 0, "got %u\n", size
);
54 ret
= GetICMProfileA( NULL
, &size
, filename
);
55 ok( !ret
, "GetICMProfileA succeeded\n" );
59 SetLastError(0xdeadbeef);
60 ret
= GetICMProfileA( dc
, &size
, filename
);
61 error
= GetLastError();
62 ok( !ret
, "GetICMProfileA succeeded\n" );
63 ok( size
, "expected size > 0\n" );
64 ok( filename
[0] == 0, "Expected filename to be empty\n" );
65 ok( error
== ERROR_INSUFFICIENT_BUFFER
, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error
);
67 ret
= GetICMProfileA( dc
, NULL
, filename
);
68 ok( !ret
, "GetICMProfileA succeeded\n" );
71 ret
= GetICMProfileA( dc
, &size
, filename
);
72 ok( ret
, "GetICMProfileA failed %d\n", GetLastError() );
74 trace( "%s\n", filename
);
77 static void test_GetICMProfileW( HDC dc
)
81 WCHAR filename
[MAX_PATH
];
83 SetLastError( 0xdeadbeef );
84 ret
= GetICMProfileW( NULL
, NULL
, NULL
);
85 if ( !ret
&& ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) )
87 win_skip( "GetICMProfileW is not implemented\n" );
90 ok( !ret
, "GetICMProfileW succeeded\n" );
92 ret
= GetICMProfileW( dc
, NULL
, NULL
);
93 ok( !ret
, "GetICMProfileW succeeded\n" );
99 ret
= GetICMProfileW( dc
, &size
, NULL
);
100 ok( ret
, "GetICMProfileW failed %d\n", GetLastError() );
103 ret
= GetICMProfileW( dc
, NULL
, filename
);
104 ok( !ret
, "GetICMProfileW succeeded\n" );
107 ret
= GetICMProfileW( NULL
, &size
, filename
);
108 ok( !ret
, "GetICMProfileW succeeded\n" );
111 ret
= GetICMProfileW( dc
, &size
, NULL
);
112 ok( !ret
, "GetICMProfileW succeeded\n" );
113 ok( size
> 0, "got %u\n", size
);
116 SetLastError(0xdeadbeef);
117 ret
= GetICMProfileW( dc
, &size
, filename
);
118 error
= GetLastError();
119 ok( !ret
, "GetICMProfileW succeeded\n" );
120 ok( size
, "expected size > 0\n" );
121 ok( error
== ERROR_INSUFFICIENT_BUFFER
, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error
);
124 ret
= GetICMProfileW( dc
, &size
, filename
);
125 ok( ret
, "GetICMProfileW failed %d\n", GetLastError() );
128 static void test_SetICMMode( HDC dc
)
133 SetLastError( 0xdeadbeef );
134 impl
= GetICMProfileA( NULL
, NULL
, NULL
);
135 if ( !impl
&& ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) )
137 win_skip( "On NT4 where SetICMMode is not implemented but this is not advertised\n" );
141 SetLastError( 0xdeadbeef );
142 ret
= SetICMMode( NULL
, 0 );
143 ok( !ret
, "SetICMMode succeeded (%d)\n", GetLastError() );
145 ret
= SetICMMode( dc
, -1 );
146 ok( !ret
, "SetICMMode succeeded (%d)\n", GetLastError() );
148 save
= SetICMMode( dc
, ICM_QUERY
);
149 ok( save
== ICM_ON
|| save
== ICM_OFF
, "SetICMMode failed (%d)\n", GetLastError() );
151 if (save
== ICM_ON
) knob
= ICM_OFF
; else knob
= ICM_ON
;
153 ret
= SetICMMode( dc
, knob
);
154 todo_wine
ok( ret
, "SetICMMode failed (%d)\n", GetLastError() );
156 ret
= SetICMMode( dc
, ICM_QUERY
);
157 todo_wine
ok( ret
== knob
, "SetICMMode failed (%d)\n", GetLastError() );
159 ret
= SetICMMode( dc
, save
);
160 ok( ret
, "SetICMMode failed (%d)\n", GetLastError() );
162 SetLastError( 0xdeadbeef );
163 dc
= CreateDCW( displayW
, NULL
, NULL
, NULL
);
164 if ( !dc
&& ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) )
166 win_skip( "CreateDCW is not implemented\n" );
169 ok( dc
!= NULL
, "CreateDCW failed (%d)\n", GetLastError() );
171 ret
= SetICMMode( dc
, ICM_QUERY
);
172 ok( ret
== ICM_OFF
, "SetICMMode failed (%d)\n", GetLastError() );
177 static INT CALLBACK
enum_profiles_callbackA( LPSTR filename
, LPARAM lparam
)
179 trace("%s\n", filename
);
183 static void test_EnumICMProfilesA( HDC dc
)
187 ret
= EnumICMProfilesA( NULL
, NULL
, 0 );
188 ok(ret
== -1 || broken(ret
== 0) /* nt4 */, "expected -1, got %d\n", ret
);
190 ret
= EnumICMProfilesA( dc
, enum_profiles_callbackA
, 0 );
191 ok(ret
== -1 || ret
== 1 || broken(ret
== 0) /* nt4 */,
192 "expected -1 or 1, got %d\n", ret
);
194 ret
= EnumICMProfilesA( dc
, NULL
, 0 );
195 ok(ret
== -1 || broken(ret
== 0) /* nt4 */, "expected -1, got %d\n", ret
);
198 static INT CALLBACK
enum_profiles_callbackW( LPWSTR filename
, LPARAM lparam
)
203 static void test_EnumICMProfilesW( HDC dc
)
207 ret
= EnumICMProfilesW( NULL
, NULL
, 0 );
208 ok(ret
== -1 || broken(ret
== 0) /* NT4 */, "expected -1, got %d\n", ret
);
210 ret
= EnumICMProfilesW( dc
, NULL
, 0 );
211 ok(ret
== -1 || broken(ret
== 0) /* NT4 */, "expected -1, got %d\n", ret
);
213 ret
= EnumICMProfilesW( dc
, enum_profiles_callbackW
, 0 );
214 ok(ret
== -1 || ret
== 1 || broken(ret
== 0) /* NT4 */, "expected -1 or 1, got %d\n", ret
);
217 static void test_SetICMProfileA( HDC dc
)
220 char profile
[MAX_PATH
];
223 SetLastError( 0xdeadbeef );
224 ret
= SetICMProfileA( NULL
, NULL
);
225 if (!ret
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
227 win_skip("SetICMProfileA is not implemented\n");
231 len
= sizeof(profile
);
232 ret
= GetICMProfileA( dc
, &len
, profile
);
233 ok(ret
, "GetICMProfileA failed %u\n", GetLastError());
235 SetLastError( 0xdeadbeef );
236 ret
= SetICMProfileA( NULL
, NULL
);
237 error
= GetLastError();
238 ok(!ret
, "SetICMProfileA succeeded\n");
239 ok(error
== ERROR_INVALID_PARAMETER
,
240 "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
242 SetLastError( 0xdeadbeef );
243 ret
= SetICMProfileA( NULL
, profile
);
244 error
= GetLastError();
245 ok(!ret
, "SetICMProfileA succeeded\n");
246 ok(error
== ERROR_INVALID_HANDLE
,
247 "expected ERROR_INVALID_HANDLE, got %u\n", error
);
249 SetLastError( 0xdeadbeef );
250 ret
= SetICMProfileA( dc
, NULL
);
251 error
= GetLastError();
252 ok(!ret
, "SetICMProfileA succeeded\n");
253 ok(error
== ERROR_INVALID_PARAMETER
,
254 "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
256 ret
= SetICMProfileA( dc
, profile
);
257 ok(ret
, "SetICMProfileA failed %u\n", GetLastError());
260 static void test_SetICMProfileW( HDC dc
)
263 WCHAR profile
[MAX_PATH
];
266 SetLastError( 0xdeadbeef );
267 ret
= SetICMProfileW( NULL
, NULL
);
268 if (!ret
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
270 win_skip("SetICMProfileW is not implemented\n");
274 len
= sizeof(profile
)/sizeof(profile
[0]);
275 ret
= GetICMProfileW( dc
, &len
, profile
);
276 ok(ret
, "GetICMProfileW failed %u\n", GetLastError());
278 SetLastError( 0xdeadbeef );
279 ret
= SetICMProfileW( NULL
, NULL
);
280 error
= GetLastError();
281 ok(!ret
, "SetICMProfileW succeeded\n");
282 ok(error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
284 SetLastError( 0xdeadbeef );
285 ret
= SetICMProfileW( NULL
, profile
);
286 error
= GetLastError();
287 ok(!ret
, "SetICMProfileW succeeded\n");
288 ok(error
== ERROR_INVALID_HANDLE
, "expected ERROR_INVALID_HANDLE, got %u\n", error
);
290 SetLastError( 0xdeadbeef );
291 ret
= SetICMProfileW( dc
, NULL
);
292 error
= GetLastError();
293 ok(!ret
, "SetICMProfileW succeeded\n");
294 ok(error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
296 ret
= SetICMProfileW( dc
, profile
);
297 ok(ret
, "SetICMProfileW failed %u\n", GetLastError());
302 HDC dc
= GetDC( NULL
);
304 test_GetICMProfileA( dc
);
305 test_GetICMProfileW( dc
);
306 test_SetICMMode( dc
);
307 test_EnumICMProfilesA( dc
);
308 test_EnumICMProfilesW( dc
);
309 test_SetICMProfileA( dc
);
310 test_SetICMProfileW( dc
);
312 ReleaseDC( NULL
, dc
);