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
, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error
);
68 ret
= GetICMProfileA( dc
, NULL
, filename
);
69 ok( !ret
, "GetICMProfileA succeeded\n" );
72 ret
= GetICMProfileA( dc
, &size
, filename
);
73 ok( ret
, "GetICMProfileA failed %d\n", GetLastError() );
75 trace( "%s\n", filename
);
78 static void test_GetICMProfileW( HDC dc
)
82 WCHAR filename
[MAX_PATH
];
84 SetLastError( 0xdeadbeef );
85 ret
= GetICMProfileW( NULL
, NULL
, NULL
);
86 if ( !ret
&& ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) )
88 win_skip( "GetICMProfileW is not implemented\n" );
91 ok( !ret
, "GetICMProfileW succeeded\n" );
93 ret
= GetICMProfileW( dc
, NULL
, NULL
);
94 ok( !ret
, "GetICMProfileW succeeded\n" );
100 ret
= GetICMProfileW( dc
, &size
, NULL
);
101 ok( ret
, "GetICMProfileW failed %d\n", GetLastError() );
104 ret
= GetICMProfileW( dc
, NULL
, filename
);
105 ok( !ret
, "GetICMProfileW succeeded\n" );
108 ret
= GetICMProfileW( NULL
, &size
, filename
);
109 ok( !ret
, "GetICMProfileW succeeded\n" );
112 SetLastError(0xdeadbeef);
113 ret
= GetICMProfileW( dc
, &size
, filename
);
114 error
= GetLastError();
115 ok( !ret
, "GetICMProfileW succeeded\n" );
116 ok( size
, "expected size > 0\n" );
117 ok( error
== ERROR_INSUFFICIENT_BUFFER
, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error
);
120 ret
= GetICMProfileW( dc
, &size
, filename
);
121 ok( ret
, "GetICMProfileW failed %d\n", GetLastError() );
124 static void test_SetICMMode( HDC dc
)
129 SetLastError( 0xdeadbeef );
130 impl
= GetICMProfileA( NULL
, NULL
, NULL
);
131 if ( !impl
&& ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) )
133 win_skip( "On NT4 where SetICMMode is not implemented but this is not advertised\n" );
137 SetLastError( 0xdeadbeef );
138 ret
= SetICMMode( NULL
, 0 );
139 ok( !ret
, "SetICMMode succeeded (%d)\n", GetLastError() );
141 ret
= SetICMMode( dc
, -1 );
142 ok( !ret
, "SetICMMode succeeded (%d)\n", GetLastError() );
144 save
= SetICMMode( dc
, ICM_QUERY
);
145 ok( save
== ICM_ON
|| save
== ICM_OFF
, "SetICMMode failed (%d)\n", GetLastError() );
147 if (save
== ICM_ON
) knob
= ICM_OFF
; else knob
= ICM_ON
;
149 ret
= SetICMMode( dc
, knob
);
150 todo_wine
ok( ret
, "SetICMMode failed (%d)\n", GetLastError() );
152 ret
= SetICMMode( dc
, ICM_QUERY
);
153 todo_wine
ok( ret
== knob
, "SetICMMode failed (%d)\n", GetLastError() );
155 ret
= SetICMMode( dc
, save
);
156 ok( ret
, "SetICMMode failed (%d)\n", GetLastError() );
158 SetLastError( 0xdeadbeef );
159 dc
= CreateDCW( displayW
, NULL
, NULL
, NULL
);
160 if ( !dc
&& ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) )
162 win_skip( "CreateDCW is not implemented\n" );
165 ok( dc
!= NULL
, "CreateDCW failed (%d)\n", GetLastError() );
167 ret
= SetICMMode( dc
, ICM_QUERY
);
168 ok( ret
== ICM_OFF
, "SetICMMode failed (%d)\n", GetLastError() );
173 static CALLBACK INT
enum_profiles_callbackA( LPSTR filename
, LPARAM lparam
)
175 trace("%s\n", filename
);
179 static void test_EnumICMProfilesA( HDC dc
)
183 ret
= EnumICMProfilesA( NULL
, NULL
, 0 );
184 ok(ret
== -1 || broken(ret
== 0) /* nt4 */, "expected -1, got %d\n", ret
);
186 ret
= EnumICMProfilesA( dc
, enum_profiles_callbackA
, 0 );
187 ok(ret
== -1 || broken(ret
== 0) /* nt4 */,
188 "expected -1, got %d\n", ret
);
190 ret
= EnumICMProfilesA( dc
, NULL
, 0 );
191 ok(ret
== -1 || broken(ret
== 0) /* nt4 */, "expected -1, got %d\n", ret
);
194 static CALLBACK INT
enum_profiles_callbackW( LPWSTR filename
, LPARAM lparam
)
199 static void test_EnumICMProfilesW( HDC dc
)
203 ret
= EnumICMProfilesW( NULL
, NULL
, 0 );
204 ok(ret
== -1 || broken(ret
== 0) /* NT4 */, "expected -1, got %d\n", ret
);
206 ret
= EnumICMProfilesW( dc
, NULL
, 0 );
207 ok(ret
== -1 || broken(ret
== 0) /* NT4 */, "expected -1, got %d\n", ret
);
209 ret
= EnumICMProfilesW( dc
, enum_profiles_callbackW
, 0 );
210 ok(ret
== -1 || ret
== 1 || broken(ret
== 0) /* NT4 */, "expected -1, got %d\n", ret
);
213 static void test_SetICMProfileA( HDC dc
)
216 char profile
[MAX_PATH
];
219 SetLastError( 0xdeadbeef );
220 ret
= SetICMProfileA( NULL
, NULL
);
221 if (!ret
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
223 win_skip("SetICMProfileA is not implemented\n");
227 len
= sizeof(profile
);
228 ret
= GetICMProfileA( dc
, &len
, profile
);
229 ok(ret
, "GetICMProfileA failed %u\n", GetLastError());
231 SetLastError( 0xdeadbeef );
232 ret
= SetICMProfileA( NULL
, NULL
);
233 error
= GetLastError();
234 ok(!ret
, "SetICMProfileA succeeded\n");
235 ok(error
== ERROR_INVALID_PARAMETER
,
236 "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
238 SetLastError( 0xdeadbeef );
239 ret
= SetICMProfileA( NULL
, profile
);
240 error
= GetLastError();
241 ok(!ret
, "SetICMProfileA succeeded\n");
242 ok(error
== ERROR_INVALID_HANDLE
,
243 "expected ERROR_INVALID_HANDLE, got %u\n", error
);
245 SetLastError( 0xdeadbeef );
246 ret
= SetICMProfileA( dc
, NULL
);
247 error
= GetLastError();
248 ok(!ret
, "SetICMProfileA succeeded\n");
249 ok(error
== ERROR_INVALID_PARAMETER
,
250 "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
252 ret
= SetICMProfileA( dc
, profile
);
253 ok(ret
, "SetICMProfileA failed %u\n", GetLastError());
256 static void test_SetICMProfileW( HDC dc
)
259 WCHAR profile
[MAX_PATH
];
262 SetLastError( 0xdeadbeef );
263 ret
= SetICMProfileW( NULL
, NULL
);
264 if (!ret
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
266 win_skip("SetICMProfileW is not implemented\n");
270 len
= sizeof(profile
)/sizeof(profile
[0]);
271 ret
= GetICMProfileW( dc
, &len
, profile
);
272 ok(ret
, "GetICMProfileW failed %u\n", GetLastError());
274 SetLastError( 0xdeadbeef );
275 ret
= SetICMProfileW( NULL
, NULL
);
276 error
= GetLastError();
277 ok(!ret
, "SetICMProfileW succeeded\n");
278 ok(error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
280 SetLastError( 0xdeadbeef );
281 ret
= SetICMProfileW( NULL
, profile
);
282 error
= GetLastError();
283 ok(!ret
, "SetICMProfileW succeeded\n");
284 ok(error
== ERROR_INVALID_HANDLE
, "expected ERROR_INVALID_HANDLE, got %u\n", error
);
286 SetLastError( 0xdeadbeef );
287 ret
= SetICMProfileW( dc
, NULL
);
288 error
= GetLastError();
289 ok(!ret
, "SetICMProfileW succeeded\n");
290 ok(error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
292 ret
= SetICMProfileW( dc
, profile
);
293 ok(ret
, "SetICMProfileW failed %u\n", GetLastError());
298 HDC dc
= GetDC( NULL
);
300 test_GetICMProfileA( dc
);
301 test_GetICMProfileW( dc
);
302 test_SetICMMode( dc
);
303 test_EnumICMProfilesA( dc
);
304 test_EnumICMProfilesW( dc
);
305 test_SetICMProfileA( dc
);
306 test_SetICMProfileW( dc
);
308 ReleaseDC( NULL
, dc
);