TESTING -- override pthreads to fix gstreamer v5
[wine/multimedia.git] / dlls / gdi32 / tests / icm.c
blob620809018a1257a2263b6036ff967b399ceabe15
1 /*
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
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "wingdi.h"
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 )
34 BOOL ret;
35 DWORD size, error;
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" );
43 return;
45 ok( !ret, "GetICMProfileA succeeded\n" );
47 ret = GetICMProfileA( dc, NULL, NULL );
48 ok( !ret, "GetICMProfileA succeeded\n" );
50 size = MAX_PATH;
51 ret = GetICMProfileA( dc, &size, NULL );
52 ok( !ret, "GetICMProfileA succeeded\n" );
53 ok( size > 0, "got %u\n", size );
55 size = 0;
56 ret = GetICMProfileA( dc, &size, NULL );
57 ok( !ret, "GetICMProfileA succeeded\n" );
58 ok( size > 0, "got %u\n", size );
60 size = MAX_PATH;
61 ret = GetICMProfileA( NULL, &size, filename );
62 ok( !ret, "GetICMProfileA succeeded\n" );
64 size = 0;
65 filename[0] = 0;
66 SetLastError(0xdeadbeef);
67 ret = GetICMProfileA( dc, &size, filename );
68 error = GetLastError();
69 ok( !ret, "GetICMProfileA succeeded\n" );
70 ok( size, "expected size > 0\n" );
71 ok( filename[0] == 0, "Expected filename to be empty\n" );
72 ok( error == ERROR_INSUFFICIENT_BUFFER, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error );
74 ret = GetICMProfileA( dc, NULL, filename );
75 ok( !ret, "GetICMProfileA succeeded\n" );
77 size = MAX_PATH;
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 )
86 BOOL ret;
87 DWORD size, error;
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" );
95 return;
97 ok( !ret, "GetICMProfileW succeeded\n" );
99 ret = GetICMProfileW( dc, NULL, NULL );
100 ok( !ret, "GetICMProfileW succeeded\n" );
102 if (0)
104 /* Vista crashes */
105 size = MAX_PATH;
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" );
113 size = MAX_PATH;
114 ret = GetICMProfileW( NULL, &size, filename );
115 ok( !ret, "GetICMProfileW succeeded\n" );
117 size = 0;
118 ret = GetICMProfileW( dc, &size, NULL );
119 ok( !ret, "GetICMProfileW succeeded\n" );
120 ok( size > 0, "got %u\n", size );
122 size = 0;
123 SetLastError(0xdeadbeef);
124 ret = GetICMProfileW( dc, &size, filename );
125 error = GetLastError();
126 ok( !ret, "GetICMProfileW succeeded\n" );
127 ok( size, "expected size > 0\n" );
128 ok( error == ERROR_INSUFFICIENT_BUFFER, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error );
130 size = MAX_PATH;
131 ret = GetICMProfileW( dc, &size, filename );
132 ok( ret, "GetICMProfileW failed %d\n", GetLastError() );
135 static void test_SetICMMode( HDC dc )
137 INT ret, knob, save;
138 BOOL impl;
140 SetLastError( 0xdeadbeef );
141 impl = GetICMProfileA( NULL, NULL, NULL );
142 if ( !impl && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
144 win_skip( "On NT4 where SetICMMode is not implemented but this is not advertised\n" );
145 return;
148 SetLastError( 0xdeadbeef );
149 ret = SetICMMode( NULL, 0 );
150 ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
152 ret = SetICMMode( dc, -1 );
153 ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
155 save = SetICMMode( dc, ICM_QUERY );
156 ok( save == ICM_ON || save == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
158 if (save == ICM_ON) knob = ICM_OFF; else knob = ICM_ON;
160 ret = SetICMMode( dc, knob );
161 todo_wine ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
163 ret = SetICMMode( dc, ICM_QUERY );
164 todo_wine ok( ret == knob, "SetICMMode failed (%d)\n", GetLastError() );
166 ret = SetICMMode( dc, save );
167 ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
169 SetLastError( 0xdeadbeef );
170 dc = CreateDCW( displayW, NULL, NULL, NULL );
171 if ( !dc && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
173 win_skip( "CreateDCW is not implemented\n" );
174 return;
176 ok( dc != NULL, "CreateDCW failed (%d)\n", GetLastError() );
178 ret = SetICMMode( dc, ICM_QUERY );
179 ok( ret == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
181 DeleteDC( dc );
184 static INT CALLBACK enum_profiles_callbackA( LPSTR filename, LPARAM lparam )
186 trace("%s\n", filename);
187 return 1;
190 static void test_EnumICMProfilesA( HDC dc )
192 INT ret;
194 ret = EnumICMProfilesA( NULL, NULL, 0 );
195 ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
197 ret = EnumICMProfilesA( dc, enum_profiles_callbackA, 0 );
198 ok(ret == -1 || ret == 1 || broken(ret == 0) /* nt4 */,
199 "expected -1 or 1, got %d\n", ret);
201 ret = EnumICMProfilesA( dc, NULL, 0 );
202 ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
205 static INT CALLBACK enum_profiles_callbackW( LPWSTR filename, LPARAM lparam )
207 return 1;
210 static void test_EnumICMProfilesW( HDC dc )
212 INT ret;
214 ret = EnumICMProfilesW( NULL, NULL, 0 );
215 ok(ret == -1 || broken(ret == 0) /* NT4 */, "expected -1, got %d\n", ret);
217 ret = EnumICMProfilesW( dc, NULL, 0 );
218 ok(ret == -1 || broken(ret == 0) /* NT4 */, "expected -1, got %d\n", ret);
220 ret = EnumICMProfilesW( dc, enum_profiles_callbackW, 0 );
221 ok(ret == -1 || ret == 1 || broken(ret == 0) /* NT4 */, "expected -1 or 1, got %d\n", ret);
224 static void test_SetICMProfileA( HDC dc )
226 BOOL ret;
227 char profile[MAX_PATH];
228 DWORD len, error;
230 SetLastError( 0xdeadbeef );
231 ret = SetICMProfileA( NULL, NULL );
232 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
234 win_skip("SetICMProfileA is not implemented\n");
235 return;
238 len = sizeof(profile);
239 ret = GetICMProfileA( dc, &len, profile );
240 ok(ret, "GetICMProfileA failed %u\n", GetLastError());
242 SetLastError( 0xdeadbeef );
243 ret = SetICMProfileA( NULL, NULL );
244 error = GetLastError();
245 ok(!ret, "SetICMProfileA succeeded\n");
246 ok(error == ERROR_INVALID_PARAMETER,
247 "expected ERROR_INVALID_PARAMETER, got %u\n", error);
249 SetLastError( 0xdeadbeef );
250 ret = SetICMProfileA( NULL, profile );
251 error = GetLastError();
252 ok(!ret, "SetICMProfileA succeeded\n");
253 ok(error == ERROR_INVALID_HANDLE,
254 "expected ERROR_INVALID_HANDLE, got %u\n", error);
256 SetLastError( 0xdeadbeef );
257 ret = SetICMProfileA( dc, NULL );
258 error = GetLastError();
259 ok(!ret, "SetICMProfileA succeeded\n");
260 ok(error == ERROR_INVALID_PARAMETER,
261 "expected ERROR_INVALID_PARAMETER, got %u\n", error);
263 ret = SetICMProfileA( dc, profile );
264 ok(ret, "SetICMProfileA failed %u\n", GetLastError());
267 static void test_SetICMProfileW( HDC dc )
269 BOOL ret;
270 WCHAR profile[MAX_PATH];
271 DWORD len, error;
273 SetLastError( 0xdeadbeef );
274 ret = SetICMProfileW( NULL, NULL );
275 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
277 win_skip("SetICMProfileW is not implemented\n");
278 return;
281 len = sizeof(profile)/sizeof(profile[0]);
282 ret = GetICMProfileW( dc, &len, profile );
283 ok(ret, "GetICMProfileW failed %u\n", GetLastError());
285 SetLastError( 0xdeadbeef );
286 ret = SetICMProfileW( NULL, NULL );
287 error = GetLastError();
288 ok(!ret, "SetICMProfileW succeeded\n");
289 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
291 SetLastError( 0xdeadbeef );
292 ret = SetICMProfileW( NULL, profile );
293 error = GetLastError();
294 ok(!ret, "SetICMProfileW succeeded\n");
295 ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
297 SetLastError( 0xdeadbeef );
298 ret = SetICMProfileW( dc, NULL );
299 error = GetLastError();
300 ok(!ret, "SetICMProfileW succeeded\n");
301 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
303 ret = SetICMProfileW( dc, profile );
304 ok(ret, "SetICMProfileW failed %u\n", GetLastError());
307 START_TEST(icm)
309 HDC dc = GetDC( NULL );
311 test_GetICMProfileA( dc );
312 test_GetICMProfileW( dc );
313 test_SetICMMode( dc );
314 test_EnumICMProfilesA( dc );
315 test_EnumICMProfilesW( dc );
316 test_SetICMProfileA( dc );
317 test_SetICMProfileW( dc );
319 ReleaseDC( NULL, dc );