2 * Tests for color profile functions
4 * Copyright 2004, 2005, 2006 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
31 #include "wine/test.h"
33 static const char machine
[] = "dummy";
34 static const WCHAR machineW
[] = L
"dummy";
36 /* To do any real functionality testing with this suite you need a copy of
37 * the freely distributable standard RGB color space profile. It comes
38 * standard with Windows, but on Wine you probably need to install it yourself
39 * in one of the locations mentioned below.
42 /* Two common places to find the standard color space profile, relative
43 * to the system directory.
45 static const char profile1
[] =
46 "\\color\\srgb color space profile.icm";
47 static const char profile2
[] =
48 "\\spool\\drivers\\color\\srgb color space profile.icm";
50 static const WCHAR profile1W
[] =
51 L
"\\color\\srgb color space profile.icm";
52 static const WCHAR profile2W
[] =
53 L
"\\spool\\drivers\\color\\srgb color space profile.icm";
55 static BOOL have_color_profile
;
57 static const unsigned char rgbheader
[] =
58 { 0x48, 0x0c, 0x00, 0x00, 0x6f, 0x6e, 0x69, 0x4c, 0x00, 0x00, 0x10, 0x02,
59 0x72, 0x74, 0x6e, 0x6d, 0x20, 0x42, 0x47, 0x52, 0x20, 0x5a, 0x59, 0x58,
60 0x02, 0x00, 0xce, 0x07, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, 0x31, 0x00,
61 0x70, 0x73, 0x63, 0x61, 0x54, 0x46, 0x53, 0x4d, 0x00, 0x00, 0x00, 0x00,
62 0x20, 0x43, 0x45, 0x49, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xf6, 0x00, 0x00,
64 0x00, 0x00, 0x01, 0x00, 0x2d, 0xd3, 0x00, 0x00, 0x20, 0x20, 0x50, 0x48 };
66 #define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
68 static void MSCMS_basenameA( LPCSTR path
, LPSTR name
)
70 INT i
= strlen( path
);
72 while (i
> 0 && !IS_SEPARATOR(path
[i
- 1])) i
--;
73 strcpy( name
, &path
[i
] );
76 static void MSCMS_basenameW( LPCWSTR path
, LPWSTR name
)
78 INT i
= lstrlenW( path
);
80 while (i
> 0 && !IS_SEPARATOR(path
[i
- 1])) i
--;
81 lstrcpyW( name
, &path
[i
] );
84 static void test_GetColorDirectoryA(void)
88 char buffer
[MAX_PATH
];
90 /* Parameter checks */
91 ret
= GetColorDirectoryA( NULL
, NULL
, NULL
);
92 ok( !ret
, "GetColorDirectoryA() succeeded (%lu)\n", GetLastError() );
95 ret
= GetColorDirectoryA( NULL
, NULL
, &size
);
96 ok( !ret
&& size
> 0, "GetColorDirectoryA() succeeded (%lu)\n", GetLastError() );
99 ret
= GetColorDirectoryA( NULL
, buffer
, &size
);
100 ok( !ret
&& size
> 0, "GetColorDirectoryA() succeeded (%lu)\n", GetLastError() );
103 ret
= GetColorDirectoryA( NULL
, buffer
, &size
);
104 ok( !ret
&& size
> 0, "GetColorDirectoryA() succeeded (%lu)\n", GetLastError() );
106 /* Functional checks */
107 size
= sizeof(buffer
);
108 ret
= GetColorDirectoryA( NULL
, buffer
, &size
);
109 ok( ret
&& size
> 0, "GetColorDirectoryA() failed (%lu)\n", GetLastError() );
112 static void test_GetColorDirectoryW(void)
116 WCHAR buffer
[MAX_PATH
];
118 /* Parameter checks */
119 ret
= GetColorDirectoryW( NULL
, NULL
, NULL
);
120 ok( !ret
, "GetColorDirectoryW() succeeded (%lu)\n", GetLastError() );
123 ret
= GetColorDirectoryW( NULL
, NULL
, &size
);
124 ok( !ret
&& size
> 0, "GetColorDirectoryW() succeeded (%lu)\n", GetLastError() );
127 ret
= GetColorDirectoryW( NULL
, buffer
, &size
);
128 ok( !ret
&& size
> 0, "GetColorDirectoryW() succeeded (%lu)\n", GetLastError() );
131 ret
= GetColorDirectoryW( NULL
, buffer
, &size
);
132 ok( !ret
&& size
> 0, "GetColorDirectoryW() succeeded (%lu)\n", GetLastError() );
134 /* Functional checks */
135 size
= sizeof(buffer
);
136 ret
= GetColorDirectoryW( NULL
, buffer
, &size
);
137 ok( ret
&& size
> 0, "GetColorDirectoryW() failed (%lu)\n", GetLastError() );
140 static void test_GetColorProfileElement( char *standardprofile
)
148 TAGTYPE tag
= 0x63707274; /* 'cprt' */
150 static const char expect
[] = "text\0\0\0\0Copyright";
152 profile
.dwType
= PROFILE_FILENAME
;
153 profile
.pProfileData
= standardprofile
;
154 profile
.cbDataSize
= strlen(standardprofile
);
156 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
157 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
159 /* Parameter checks */
160 ret
= GetColorProfileElement( handle
, tag
, 0, NULL
, NULL
, &ref
);
161 ok( !ret
, "GetColorProfileElement() succeeded (%lu)\n", GetLastError() );
163 ret
= GetColorProfileElement( handle
, tag
, 0, &size
, NULL
, NULL
);
164 ok( !ret
, "GetColorProfileElement() succeeded (%lu)\n", GetLastError() );
167 ret
= GetColorProfileElement( handle
, tag
, 0, &size
, NULL
, &ref
);
168 ok( !ret
, "GetColorProfileElement() succeeded\n" );
169 ok( size
> 0, "wrong size\n" );
171 /* Functional checks */
172 size
= sizeof(buffer
);
173 ret
= GetColorProfileElement( handle
, tag
, 0, &size
, buffer
, &ref
);
174 ok( ret
, "GetColorProfileElement() failed %lu\n", GetLastError() );
175 ok( size
> 0, "wrong size\n" );
176 ok( !memcmp( buffer
, expect
, sizeof(expect
)-1 ), "Unexpected tag data\n" );
178 CloseColorProfile( handle
);
182 static void test_GetColorProfileElementTag( char *standardprofile
)
190 TAGTYPE tag
, expect
= 0x63707274; /* 'cprt' */
192 profile
.dwType
= PROFILE_FILENAME
;
193 profile
.pProfileData
= standardprofile
;
194 profile
.cbDataSize
= strlen(standardprofile
);
196 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
197 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
199 /* Parameter checks */
200 ret
= GetColorProfileElementTag( NULL
, index
, &tag
);
201 ok( !ret
, "GetColorProfileElementTag() succeeded (%lu)\n", GetLastError() );
203 ret
= GetColorProfileElementTag( handle
, 0, &tag
);
204 ok( !ret
, "GetColorProfileElementTag() succeeded (%lu)\n", GetLastError() );
206 ret
= GetColorProfileElementTag( handle
, index
, NULL
);
207 ok( !ret
, "GetColorProfileElementTag() succeeded (%lu)\n", GetLastError() );
209 ret
= GetColorProfileElementTag( handle
, 18, NULL
);
210 ok( !ret
, "GetColorProfileElementTag() succeeded (%lu)\n", GetLastError() );
212 /* Functional checks */
213 while ((ret
= GetColorProfileElementTag( handle
, index
, &tag
)) && tag
!= expect
) index
++;
214 ok( ret
&& tag
== expect
, "GetColorProfileElementTag() failed (%lu)\n", GetLastError() );
216 CloseColorProfile( handle
);
220 static void test_GetColorProfileFromHandle( char *testprofile
)
224 PROFILEHEADER
*header
;
229 unsigned char *buffer
;
231 profile
.dwType
= PROFILE_FILENAME
;
232 profile
.pProfileData
= testprofile
;
233 profile
.cbDataSize
= strlen(testprofile
);
235 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
236 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
238 /* Parameter checks */
240 ret
= GetColorProfileFromHandle( handle
, NULL
, &size
);
241 ok( !ret
&& size
> 0, "GetColorProfileFromHandle() failed (%lu)\n", GetLastError() );
243 buffer
= HeapAlloc( GetProcessHeap(), 0, size
);
246 ret
= GetColorProfileFromHandle( NULL
, buffer
, &size
);
247 ok( !ret
, "GetColorProfileFromHandle() succeeded (%lu)\n", GetLastError() );
249 ret
= GetColorProfileFromHandle( handle
, buffer
, NULL
);
250 ok( !ret
, "GetColorProfileFromHandle() succeeded (%lu)\n", GetLastError() );
252 /* Functional checks */
253 ret
= GetColorProfileFromHandle( handle
, buffer
, &size
);
254 ok( ret
&& size
> 0, "GetColorProfileFromHandle() failed (%lu)\n", GetLastError() );
256 header
= (PROFILEHEADER
*)buffer
;
257 ok( header
->phClass
== 0x72746e6d, "wrong phClass %lx\n", header
->phClass
);
258 ok( header
->phDataColorSpace
== 0x20424752, "wrong phDataColorSpace %lx\n", header
->phDataColorSpace
);
259 ok( header
->phConnectionSpace
== 0x205a5958, "wrong phConnectionSpace %lx\n", header
->phConnectionSpace
);
260 ok( header
->phSignature
== 0x70736361, "wrong phSignature %lx\n", header
->phSignature
);
261 ok( header
->phProfileFlags
== 0x00000000, "wrong phProfileFlags %lx\n", header
->phProfileFlags
);
262 ok( header
->phRenderingIntent
== 0x00000000, "wrong phRenderingIntent %lx\n", header
->phRenderingIntent
);
263 ok( header
->phIlluminant
.ciexyzX
== 0xd6f60000, "wrong phIlluminant.ciexyzX %lx\n", header
->phIlluminant
.ciexyzX
);
264 ok( header
->phIlluminant
.ciexyzY
== 0x00000100, "wrong phIlluminant.ciexyzY %lx\n", header
->phIlluminant
.ciexyzY
);
265 ok( header
->phIlluminant
.ciexyzZ
== 0x2dd30000, "wrong phIlluminant.ciexyzZ %lx\n", header
->phIlluminant
.ciexyzZ
);
266 HeapFree( GetProcessHeap(), 0, buffer
);
269 CloseColorProfile( handle
);
273 static void test_GetColorProfileHeader( char *testprofile
)
280 PROFILEHEADER header
;
282 profile
.dwType
= PROFILE_FILENAME
;
283 profile
.pProfileData
= testprofile
;
284 profile
.cbDataSize
= strlen(testprofile
);
286 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
287 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
289 /* Parameter checks */
290 ret
= GetColorProfileHeader( NULL
, NULL
);
291 ok( !ret
, "GetColorProfileHeader() succeeded (%lu)\n", GetLastError() );
293 ret
= GetColorProfileHeader( NULL
, &header
);
294 ok( !ret
, "GetColorProfileHeader() succeeded (%lu)\n", GetLastError() );
296 if (0) /* Crashes on Vista */
298 ret
= GetColorProfileHeader( handle
, NULL
);
299 ok( !ret
, "GetColorProfileHeader() succeeded (%lu)\n", GetLastError() );
302 /* Functional checks */
303 ret
= GetColorProfileHeader( handle
, &header
);
304 ok( ret
, "GetColorProfileHeader() failed (%lu)\n", GetLastError() );
306 ok( header
.phClass
== 0x6d6e7472, "wrong phClass %#lx\n", header
.phClass
);
307 ok( header
.phDataColorSpace
== 0x52474220, "wrong phDataColorSpace %#lx\n", header
.phDataColorSpace
);
308 ok( header
.phConnectionSpace
== 0x58595a20, "wrong phConnectionSpace %#lx\n", header
.phConnectionSpace
);
309 ok( header
.phSignature
== 0x61637370, "wrong phSignature %#lx\n", header
.phSignature
);
310 ok( header
.phProfileFlags
== 0x00000000, "wrong phProfileFlags %#lx\n", header
.phProfileFlags
);
311 ok( header
.phRenderingIntent
== 0x00000000, "wrong phRenderingIntent %#lx\n", header
.phRenderingIntent
);
312 ok( header
.phIlluminant
.ciexyzX
== 0x0000f6d6, "wrong phIlluminant.ciexyzX %#lx\n", header
.phIlluminant
.ciexyzX
);
313 ok( header
.phIlluminant
.ciexyzY
== 0x00010000, "wrong phIlluminant.ciexyzY %#lx\n", header
.phIlluminant
.ciexyzY
);
314 ok( header
.phIlluminant
.ciexyzZ
== 0x0000d32d, "wrong phIlluminant.ciexyzZ %#lx\n", header
.phIlluminant
.ciexyzZ
);
316 CloseColorProfile( handle
);
320 static void test_GetCountColorProfileElements( char *standardprofile
)
329 profile
.dwType
= PROFILE_FILENAME
;
330 profile
.pProfileData
= standardprofile
;
331 profile
.cbDataSize
= strlen(standardprofile
);
333 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
334 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
336 /* Parameter checks */
337 ret
= GetCountColorProfileElements( NULL
, &count
);
338 ok( !ret
, "GetCountColorProfileElements() succeeded (%lu)\n", GetLastError() );
340 ret
= GetCountColorProfileElements( handle
, NULL
);
341 ok( !ret
, "GetCountColorProfileElements() succeeded (%lu)\n", GetLastError() );
343 /* Functional checks */
344 ret
= GetCountColorProfileElements( handle
, &count
);
345 ok( ret
&& count
> 15 && count
< 20,
346 "GetCountColorProfileElements() failed (%lu) %lu\n", GetLastError(), count
);
348 CloseColorProfile( handle
);
352 static void test_GetStandardColorSpaceProfileA( char *standardprofile
)
356 CHAR oldprofile
[MAX_PATH
];
357 CHAR newprofile
[MAX_PATH
];
359 /* Single invalid parameter checks: */
360 size
= sizeof(newprofile
);
361 SetLastError(0xfaceabee); /* 1st param, */
362 ret
= GetStandardColorSpaceProfileA(machine
, LCS_sRGB
, newprofile
, &size
);
363 ok( !ret
&& GetLastError() == ERROR_NOT_SUPPORTED
, "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n",
364 ret
, GetLastError() );
366 size
= sizeof(newprofile
);
367 SetLastError(0xfaceabee); /* 2nd param, */
368 ret
= GetStandardColorSpaceProfileA(NULL
, (DWORD
)-1, newprofile
, &size
);
369 ok( !ret
&& GetLastError() == ERROR_FILE_NOT_FOUND
, "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n",
370 ret
, GetLastError() );
372 size
= sizeof(newprofile
);
373 SetLastError(0xfaceabee); /* 4th param, */
374 ret
= GetStandardColorSpaceProfileA(NULL
, LCS_sRGB
, newprofile
, NULL
);
375 ok( !ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n",
376 ret
, GetLastError() );
378 size
= sizeof(newprofile
);
379 SetLastError(0xfaceabee); /* 3rd param, */
380 ret
= GetStandardColorSpaceProfileA(NULL
, LCS_sRGB
, NULL
, &size
);
381 ok( !ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n",
382 ret
, GetLastError() );
385 SetLastError(0xfaceabee); /* dereferenced 4th param, */
386 ret
= GetStandardColorSpaceProfileA(NULL
, LCS_sRGB
, newprofile
, &size
);
387 ok( !ret
&& (GetLastError() == ERROR_MORE_DATA
|| GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
388 "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n", ret
, GetLastError() );
390 /* Several invalid parameter checks: */
392 SetLastError(0xfaceabee); /* 1st, maybe 2nd and then dereferenced 4th param, */
393 ret
= GetStandardColorSpaceProfileA(machine
, 0, newprofile
, &size
);
394 ok( !ret
&& (GetLastError() == ERROR_INVALID_PARAMETER
|| GetLastError() == ERROR_NOT_SUPPORTED
),
395 "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n", ret
, GetLastError() );
397 SetLastError(0xfaceabee); /* maybe 2nd and then 4th param, */
398 ret
= GetStandardColorSpaceProfileA(NULL
, 0, newprofile
, NULL
);
399 ok( !ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n",
400 ret
, GetLastError() );
403 SetLastError(0xfaceabee); /* maybe 2nd, then 3rd and dereferenced 4th param, */
404 ret
= GetStandardColorSpaceProfileA(NULL
, 0, NULL
, &size
);
405 ok( !ret
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
|| GetLastError() == ERROR_FILE_NOT_FOUND
),
406 "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n", ret
, GetLastError() );
408 size
= sizeof(newprofile
);
409 SetLastError(0xfaceabee); /* maybe 2nd param. */
410 ret
= GetStandardColorSpaceProfileA(NULL
, 0, newprofile
, &size
);
411 if (!ret
) ok( GetLastError() == ERROR_FILE_NOT_FOUND
, "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n",
412 ret
, GetLastError() );
413 else ok( !lstrcmpiA( newprofile
, "" ) && GetLastError() == 0xfaceabee,
414 "GetStandardColorSpaceProfileA() returns %d (GLE=%lu)\n", ret
, GetLastError() );
416 /* Functional checks */
417 size
= sizeof(oldprofile
);
418 ret
= GetStandardColorSpaceProfileA( NULL
, LCS_sRGB
, oldprofile
, &size
);
419 ok( ret
, "GetStandardColorSpaceProfileA() failed (%lu)\n", GetLastError() );
421 SetLastError(0xdeadbeef);
422 ret
= SetStandardColorSpaceProfileA( NULL
, LCS_sRGB
, standardprofile
);
423 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
425 skip("Not enough rights for SetStandardColorSpaceProfileA\n");
428 ok( ret
, "SetStandardColorSpaceProfileA() failed (%lu)\n", GetLastError() );
430 size
= sizeof(newprofile
);
431 ret
= GetStandardColorSpaceProfileA( NULL
, LCS_sRGB
, newprofile
, &size
);
432 ok( ret
, "GetStandardColorSpaceProfileA() failed (%lu)\n", GetLastError() );
434 ret
= SetStandardColorSpaceProfileA( NULL
, LCS_sRGB
, oldprofile
);
435 ok( ret
, "SetStandardColorSpaceProfileA() failed (%lu)\n", GetLastError() );
438 static void test_GetStandardColorSpaceProfileW( WCHAR
*standardprofileW
)
442 WCHAR oldprofile
[MAX_PATH
];
443 WCHAR newprofile
[MAX_PATH
];
444 CHAR newprofileA
[MAX_PATH
];
446 /* Single invalid parameter checks: */
447 size
= sizeof(newprofile
);
448 SetLastError(0xfaceabee); /* 1st param, */
449 ret
= GetStandardColorSpaceProfileW(machineW
, LCS_sRGB
, newprofile
, &size
);
450 ok( !ret
&& GetLastError() == ERROR_NOT_SUPPORTED
, "GetStandardColorSpaceProfileW() returns %d (GLE=%lu)\n",
451 ret
, GetLastError() );
453 size
= sizeof(newprofile
);
454 SetLastError(0xfaceabee); /* 2nd param, */
455 ret
= GetStandardColorSpaceProfileW(NULL
, (DWORD
)-1, newprofile
, &size
);
456 ok( !ret
&& GetLastError() == ERROR_FILE_NOT_FOUND
, "GetStandardColorSpaceProfileW() returns %d (GLE=%lu)\n",
457 ret
, GetLastError() );
459 size
= sizeof(newprofile
);
460 SetLastError(0xfaceabee); /* 2nd param, */
461 ret
= GetStandardColorSpaceProfileW(NULL
, 0, newprofile
, &size
);
462 ok( !ret
&& GetLastError() == ERROR_FILE_NOT_FOUND
,
463 "GetStandardColorSpaceProfileW() returns %d (GLE=%lu)\n", ret
, GetLastError() );
465 size
= sizeof(newprofile
);
466 SetLastError(0xfaceabee); /* 3rd param, */
467 ret
= GetStandardColorSpaceProfileW(NULL
, LCS_sRGB
, NULL
, &size
);
468 ok( !ret
, "GetStandardColorSpaceProfileW succeeded\n" );
469 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER
,
470 "GetStandardColorSpaceProfileW() returns GLE=%lu\n", GetLastError() );
472 size
= sizeof(newprofile
);
473 SetLastError(0xfaceabee); /* 4th param, */
474 ret
= GetStandardColorSpaceProfileW(NULL
, LCS_sRGB
, newprofile
, NULL
);
475 ok( !ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "GetStandardColorSpaceProfileW() returns %d (GLE=%lu)\n",
476 ret
, GetLastError() );
479 SetLastError(0xfaceabee); /* dereferenced 4th param. */
480 ret
= GetStandardColorSpaceProfileW(NULL
, LCS_sRGB
, newprofile
, &size
);
481 ok( !ret
, "GetStandardColorSpaceProfileW succeeded\n" );
482 ok( GetLastError() == ERROR_MORE_DATA
||
483 GetLastError() == ERROR_INSUFFICIENT_BUFFER
,
484 "GetStandardColorSpaceProfileW() returns GLE=%lu\n", GetLastError() );
486 /* Several invalid parameter checks: */
488 SetLastError(0xfaceabee); /* 1st, maybe 2nd and then dereferenced 4th param, */
489 ret
= GetStandardColorSpaceProfileW(machineW
, 0, newprofile
, &size
);
490 ok( !ret
&& (GetLastError() == ERROR_INVALID_PARAMETER
|| GetLastError() == ERROR_NOT_SUPPORTED
),
491 "GetStandardColorSpaceProfileW() returns %d (GLE=%lu)\n", ret
, GetLastError() );
493 SetLastError(0xfaceabee); /* maybe 2nd and then 4th param, */
494 ret
= GetStandardColorSpaceProfileW(NULL
, 0, newprofile
, NULL
);
495 ok( !ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "GetStandardColorSpaceProfileW() returns %d (GLE=%lu)\n",
496 ret
, GetLastError() );
499 SetLastError(0xfaceabee); /* maybe 2nd, then 3rd and dereferenced 4th param, */
500 ret
= GetStandardColorSpaceProfileW(NULL
, 0, NULL
, &size
);
501 ok( !ret
, "GetStandardColorSpaceProfileW succeeded\n" );
502 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER
||
503 GetLastError() == ERROR_FILE_NOT_FOUND
,
504 "GetStandardColorSpaceProfileW() returns GLE=%lu\n", GetLastError() );
506 size
= sizeof(newprofile
);
507 SetLastError(0xfaceabee); /* maybe 2nd param. */
508 ret
= GetStandardColorSpaceProfileW(NULL
, 0, newprofile
, &size
);
509 if (!ret
) ok( GetLastError() == ERROR_FILE_NOT_FOUND
, "GetStandardColorSpaceProfileW() returns %d (GLE=%lu)\n",
510 ret
, GetLastError() );
513 WideCharToMultiByte(CP_ACP
, 0, newprofile
, -1, newprofileA
, sizeof(newprofileA
), NULL
, NULL
);
514 ok( !lstrcmpiA( newprofileA
, "" ) && GetLastError() == 0xfaceabee,
515 "GetStandardColorSpaceProfileW() returns %d (GLE=%lu)\n", ret
, GetLastError() );
518 /* Functional checks */
519 size
= sizeof(oldprofile
);
520 ret
= GetStandardColorSpaceProfileW( NULL
, LCS_sRGB
, oldprofile
, &size
);
521 ok( ret
, "GetStandardColorSpaceProfileW() failed (%lu)\n", GetLastError() );
523 SetLastError(0xdeadbeef);
524 ret
= SetStandardColorSpaceProfileW( NULL
, LCS_sRGB
, standardprofileW
);
525 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
527 skip("Not enough rights for SetStandardColorSpaceProfileW\n");
530 ok( ret
, "SetStandardColorSpaceProfileW() failed (%lu)\n", GetLastError() );
532 size
= sizeof(newprofile
);
533 ret
= GetStandardColorSpaceProfileW( NULL
, LCS_sRGB
, newprofile
, &size
);
534 ok( ret
, "GetStandardColorSpaceProfileW() failed (%lu)\n", GetLastError() );
536 ret
= SetStandardColorSpaceProfileW( NULL
, LCS_sRGB
, oldprofile
);
537 ok( ret
, "SetStandardColorSpaceProfileW() failed (%lu)\n", GetLastError() );
540 static void test_EnumColorProfilesA( char *standardprofile
)
543 DWORD total
, size
, number
;
547 /* Parameter checks */
548 memset( &record
, 0, sizeof(ENUMTYPEA
) );
549 record
.dwSize
= sizeof(ENUMTYPEA
);
550 record
.dwVersion
= ENUM_TYPE_VERSION
;
551 record
.dwFields
|= ET_DATACOLORSPACE
;
552 record
.dwDataColorSpace
= SPACE_RGB
;
555 SetLastError( 0xdeadbeef );
556 ret
= EnumColorProfilesA( NULL
, &record
, NULL
, &total
, &number
);
557 ok( !ret
, "EnumColorProfilesA succeeded\n" );
558 if (have_color_profile
) ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "got %lu\n", GetLastError() );
559 buffer
= HeapAlloc( GetProcessHeap(), 0, total
);
562 ret
= EnumColorProfilesA( machine
, &record
, buffer
, &size
, &number
);
563 ok( !ret
, "EnumColorProfilesA succeeded\n" );
565 ret
= EnumColorProfilesA( NULL
, NULL
, buffer
, &size
, &number
);
566 ok( !ret
, "EnumColorProfilesA succeeded\n" );
568 ret
= EnumColorProfilesA( NULL
, &record
, buffer
, NULL
, &number
);
569 ok( !ret
, "EnumColorProfilesA succeeded\n" );
571 ret
= EnumColorProfilesA( NULL
, &record
, buffer
, &size
, &number
);
572 todo_wine_if (!have_color_profile
)
573 ok( ret
, "EnumColorProfilesA failed %lu\n", GetLastError() );
576 ret
= EnumColorProfilesA( NULL
, &record
, buffer
, &size
, &number
);
577 ok( !ret
, "EnumColorProfilesA succeeded\n" );
579 /* Functional checks */
581 ret
= EnumColorProfilesA( NULL
, &record
, buffer
, &size
, &number
);
582 todo_wine_if (!have_color_profile
)
583 ok( ret
, "EnumColorProfilesA failed %lu\n", GetLastError() );
585 HeapFree( GetProcessHeap(), 0, buffer
);
588 static void test_EnumColorProfilesW( WCHAR
*standardprofileW
)
591 DWORD total
, size
, number
;
595 /* Parameter checks */
596 memset( &record
, 0, sizeof(ENUMTYPEW
) );
597 record
.dwSize
= sizeof(ENUMTYPEW
);
598 record
.dwVersion
= ENUM_TYPE_VERSION
;
599 record
.dwFields
|= ET_DATACOLORSPACE
;
600 record
.dwDataColorSpace
= SPACE_RGB
;
603 SetLastError( 0xdeadbeef );
604 ret
= EnumColorProfilesW( NULL
, &record
, NULL
, &total
, &number
);
605 ok( !ret
, "EnumColorProfilesW succeeded\n" );
606 if (have_color_profile
) ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "got %lu\n", GetLastError() );
607 buffer
= HeapAlloc( GetProcessHeap(), 0, total
* sizeof(WCHAR
) );
610 ret
= EnumColorProfilesW( machineW
, &record
, buffer
, &size
, &number
);
611 ok( !ret
, "EnumColorProfilesW succeeded\n" );
613 ret
= EnumColorProfilesW( NULL
, NULL
, buffer
, &size
, &number
);
614 ok( !ret
, "EnumColorProfilesW succeeded\n" );
616 ret
= EnumColorProfilesW( NULL
, &record
, buffer
, NULL
, &number
);
617 ok( !ret
, "EnumColorProfilesW succeeded\n" );
619 ret
= EnumColorProfilesW( NULL
, &record
, buffer
, &size
, &number
);
620 todo_wine_if (!have_color_profile
)
621 ok( ret
, "EnumColorProfilesW failed %lu\n", GetLastError() );
624 ret
= EnumColorProfilesW( NULL
, &record
, buffer
, &size
, &number
);
625 ok( !ret
, "EnumColorProfilesW succeeded\n" );
627 /* Functional checks */
629 ret
= EnumColorProfilesW( NULL
, &record
, buffer
, &size
, &number
);
630 todo_wine_if (!have_color_profile
)
631 ok( ret
, "EnumColorProfilesW failed %lu\n", GetLastError() );
633 HeapFree( GetProcessHeap(), 0, buffer
);
636 static void test_InstallColorProfileA( char *standardprofile
, char *testprofile
)
640 /* Parameter checks */
641 ret
= InstallColorProfileA( NULL
, NULL
);
642 ok( !ret
, "InstallColorProfileA() succeeded (%lu)\n", GetLastError() );
644 ret
= InstallColorProfileA( machine
, NULL
);
645 ok( !ret
, "InstallColorProfileA() succeeded (%lu)\n", GetLastError() );
647 ret
= InstallColorProfileA( NULL
, machine
);
648 ok( !ret
, "InstallColorProfileA() succeeded (%lu)\n", GetLastError() );
652 ret
= InstallColorProfileA( NULL
, standardprofile
);
653 ok( ret
, "InstallColorProfileA() failed (%lu)\n", GetLastError() );
656 /* Functional checks */
659 CHAR dest
[MAX_PATH
], base
[MAX_PATH
];
660 DWORD size
= sizeof(dest
);
663 SetLastError(0xdeadbeef);
664 ret
= InstallColorProfileA( NULL
, testprofile
);
665 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
667 skip("Not enough rights for InstallColorProfileA\n");
670 ok( ret
, "InstallColorProfileA() failed (%lu)\n", GetLastError() );
672 ret
= GetColorDirectoryA( NULL
, dest
, &size
);
673 ok( ret
, "GetColorDirectoryA() failed (%lu)\n", GetLastError() );
675 MSCMS_basenameA( testprofile
, base
);
677 lstrcatA( dest
, "\\" );
678 lstrcatA( dest
, base
);
680 /* Check if the profile is really there */
681 handle
= CreateFileA( dest
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
682 ok( handle
!= INVALID_HANDLE_VALUE
, "Couldn't find the profile (%lu)\n", GetLastError() );
683 CloseHandle( handle
);
685 ret
= UninstallColorProfileA( NULL
, dest
, TRUE
);
686 ok( ret
, "UninstallColorProfileA() failed (%lu)\n", GetLastError() );
690 static void test_InstallColorProfileW( WCHAR
*standardprofileW
, WCHAR
*testprofileW
)
694 /* Parameter checks */
695 ret
= InstallColorProfileW( NULL
, NULL
);
696 ok( !ret
, "InstallColorProfileW() succeeded (%lu)\n", GetLastError() );
698 ret
= InstallColorProfileW( machineW
, NULL
);
699 ok( !ret
, "InstallColorProfileW() succeeded (%lu)\n", GetLastError() );
701 ret
= InstallColorProfileW( NULL
, machineW
);
702 ok( !ret
, "InstallColorProfileW() failed (%lu)\n", GetLastError() );
704 if (standardprofileW
)
706 ret
= InstallColorProfileW( NULL
, standardprofileW
);
707 ok( ret
, "InstallColorProfileW() failed (%lu)\n", GetLastError() );
710 /* Functional checks */
713 WCHAR dest
[MAX_PATH
], base
[MAX_PATH
];
714 DWORD size
= sizeof(dest
);
717 SetLastError(0xdeadbeef);
718 ret
= InstallColorProfileW( NULL
, testprofileW
);
719 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
721 skip("Not enough rights for InstallColorProfileW\n");
724 ok( ret
, "InstallColorProfileW() failed (%lu)\n", GetLastError() );
726 ret
= GetColorDirectoryW( NULL
, dest
, &size
);
727 ok( ret
, "GetColorDirectoryW() failed (%lu)\n", GetLastError() );
729 MSCMS_basenameW( testprofileW
, base
);
730 lstrcatW( dest
, L
"\\" );
731 lstrcatW( dest
, base
);
733 /* Check if the profile is really there */
734 handle
= CreateFileW( dest
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
735 ok( handle
!= INVALID_HANDLE_VALUE
, "Couldn't find the profile (%lu)\n", GetLastError() );
736 CloseHandle( handle
);
738 ret
= UninstallColorProfileW( NULL
, dest
, TRUE
);
739 ok( ret
, "UninstallColorProfileW() failed (%lu)\n", GetLastError() );
743 static void test_IsColorProfileTagPresent( char *standardprofile
)
752 profile
.dwType
= PROFILE_FILENAME
;
753 profile
.pProfileData
= standardprofile
;
754 profile
.cbDataSize
= strlen(standardprofile
);
756 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
757 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
759 /* Parameter checks */
761 ret
= IsColorProfileTagPresent( handle
, tag
, &present
);
762 ok( !(ret
&& present
), "IsColorProfileTagPresent() succeeded (%lu)\n", GetLastError() );
764 tag
= 0x63707274; /* 'cprt' */
765 ret
= IsColorProfileTagPresent( NULL
, tag
, &present
);
766 ok( !ret
, "IsColorProfileTagPresent() succeeded (%lu)\n", GetLastError() );
768 ret
= IsColorProfileTagPresent( handle
, tag
, NULL
);
769 ok( !ret
, "IsColorProfileTagPresent() succeeded (%lu)\n", GetLastError() );
771 /* Functional checks */
772 ret
= IsColorProfileTagPresent( handle
, tag
, &present
);
773 ok( ret
&& present
, "IsColorProfileTagPresent() failed (%lu)\n", GetLastError() );
775 CloseColorProfile( handle
);
779 static void test_OpenColorProfileA( char *standardprofile
)
785 profile
.dwType
= PROFILE_FILENAME
;
786 profile
.pProfileData
= NULL
;
787 profile
.cbDataSize
= 0;
789 /* Parameter checks */
790 handle
= OpenColorProfileA( NULL
, 0, 0, 0 );
791 ok( handle
== NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
793 handle
= OpenColorProfileA( &profile
, 0, 0, 0 );
794 ok( handle
== NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
796 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, 0 );
797 ok( handle
== NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
799 handle
= OpenColorProfileA( &profile
, PROFILE_READWRITE
, 0, 0 );
800 ok( handle
== NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
802 ok( !CloseColorProfile( NULL
), "CloseColorProfile() succeeded\n" );
806 profile
.pProfileData
= standardprofile
;
807 profile
.cbDataSize
= strlen(standardprofile
);
809 handle
= OpenColorProfileA( &profile
, 0, 0, 0 );
810 ok( handle
== NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
812 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, 0 );
813 ok( handle
== NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
815 handle
= OpenColorProfileA( &profile
, PROFILE_READ
|PROFILE_READWRITE
, 0, 0 );
816 ok( handle
== NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
818 /* Functional checks */
819 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
820 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
822 ret
= CloseColorProfile( handle
);
823 ok( ret
, "CloseColorProfile() failed (%lu)\n", GetLastError() );
825 profile
.dwType
= PROFILE_FILENAME
;
826 profile
.pProfileData
= (void *)"sRGB Color Space Profile.icm";
827 profile
.cbDataSize
= sizeof("sRGB Color Space Profile.icm");
829 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, FILE_SHARE_READ
, OPEN_EXISTING
);
830 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
832 ret
= CloseColorProfile( handle
);
833 ok( ret
, "CloseColorProfile() failed (%lu)\n", GetLastError() );
837 static void test_OpenColorProfileW( WCHAR
*standardprofileW
)
843 profile
.dwType
= PROFILE_FILENAME
;
844 profile
.pProfileData
= NULL
;
845 profile
.cbDataSize
= 0;
847 /* Parameter checks */
848 handle
= OpenColorProfileW( NULL
, 0, 0, 0 );
849 ok( handle
== NULL
, "OpenColorProfileW() failed (%lu)\n", GetLastError() );
851 handle
= OpenColorProfileW( &profile
, 0, 0, 0 );
852 ok( handle
== NULL
, "OpenColorProfileW() failed (%lu)\n", GetLastError() );
854 handle
= OpenColorProfileW( &profile
, PROFILE_READ
, 0, 0 );
855 ok( handle
== NULL
, "OpenColorProfileW() failed (%lu)\n", GetLastError() );
857 handle
= OpenColorProfileW( &profile
, PROFILE_READWRITE
, 0, 0 );
858 ok( handle
== NULL
, "OpenColorProfileW() failed (%lu)\n", GetLastError() );
860 ok( !CloseColorProfile( NULL
), "CloseColorProfile() succeeded\n" );
862 if (standardprofileW
)
864 profile
.pProfileData
= standardprofileW
;
865 profile
.cbDataSize
= lstrlenW(standardprofileW
) * sizeof(WCHAR
);
867 handle
= OpenColorProfileW( &profile
, 0, 0, 0 );
868 ok( handle
== NULL
, "OpenColorProfileW() failed (%lu)\n", GetLastError() );
870 handle
= OpenColorProfileW( &profile
, PROFILE_READ
, 0, 0 );
871 ok( handle
== NULL
, "OpenColorProfileW() failed (%lu)\n", GetLastError() );
873 handle
= OpenColorProfileW( &profile
, PROFILE_READ
|PROFILE_READWRITE
, 0, 0 );
874 ok( handle
== NULL
, "OpenColorProfileW() failed (%lu)\n", GetLastError() );
876 /* Functional checks */
877 handle
= OpenColorProfileW( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
878 ok( handle
!= NULL
, "OpenColorProfileW() failed (%lu)\n", GetLastError() );
880 ret
= CloseColorProfile( handle
);
881 ok( ret
, "CloseColorProfile() failed (%lu)\n", GetLastError() );
885 static void test_SetColorProfileElement( char *testprofile
)
894 TAGTYPE tag
= 0x63707274; /* 'cprt' */
895 static char data
[] = "(c) The Wine Project";
898 profile
.dwType
= PROFILE_FILENAME
;
899 profile
.pProfileData
= testprofile
;
900 profile
.cbDataSize
= strlen(testprofile
);
902 /* Parameter checks */
903 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
904 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
906 ret
= SetColorProfileElement( handle
, tag
, 0, &size
, data
);
907 ok( !ret
, "SetColorProfileElement() succeeded (%lu)\n", GetLastError() );
908 CloseColorProfile( handle
);
910 handle
= OpenColorProfileA( &profile
, PROFILE_READWRITE
, 0, OPEN_EXISTING
);
911 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
913 ret
= SetColorProfileElement( NULL
, 0, 0, NULL
, NULL
);
914 ok( !ret
, "SetColorProfileElement() succeeded (%lu)\n", GetLastError() );
916 ret
= SetColorProfileElement( handle
, 0, 0, NULL
, NULL
);
917 ok( !ret
, "SetColorProfileElement() succeeded (%lu)\n", GetLastError() );
919 ret
= SetColorProfileElement( handle
, tag
, 0, NULL
, NULL
);
920 ok( !ret
, "SetColorProfileElement() succeeded (%lu)\n", GetLastError() );
922 ret
= SetColorProfileElement( handle
, tag
, 0, &size
, NULL
);
923 ok( !ret
, "SetColorProfileElement() succeeded (%lu)\n", GetLastError() );
925 /* Functional checks */
927 ret
= SetColorProfileElement( handle
, tag
, 0, &size
, data
);
928 ok( ret
, "SetColorProfileElement() failed %lu\n", GetLastError() );
930 size
= sizeof(buffer
);
931 ret
= GetColorProfileElement( handle
, tag
, 0, &size
, buffer
, &ref
);
932 ok( ret
, "GetColorProfileElement() failed %lu\n", GetLastError() );
933 ok( size
> 0, "wrong size\n" );
935 ok( !memcmp( data
, buffer
, sizeof(data
) ),
936 "Unexpected tag data, expected %s, got %s (%lu)\n", data
, buffer
, GetLastError() );
938 CloseColorProfile( handle
);
942 static void test_SetColorProfileHeader( char *testprofile
)
949 PROFILEHEADER header
;
951 profile
.dwType
= PROFILE_FILENAME
;
952 profile
.pProfileData
= testprofile
;
953 profile
.cbDataSize
= strlen(testprofile
);
955 header
.phSize
= 0x00000c48;
956 header
.phCMMType
= 0x4c696e6f;
957 header
.phVersion
= 0x02100000;
958 header
.phClass
= 0x6d6e7472;
959 header
.phDataColorSpace
= 0x52474220;
960 header
.phConnectionSpace
= 0x58595a20;
961 header
.phDateTime
[0] = 0x07ce0002;
962 header
.phDateTime
[1] = 0x00090006;
963 header
.phDateTime
[2] = 0x00310000;
964 header
.phSignature
= 0x61637370;
965 header
.phPlatform
= 0x4d534654;
966 header
.phProfileFlags
= 0x00000000;
967 header
.phManufacturer
= 0x49454320;
968 header
.phModel
= 0x73524742;
969 header
.phAttributes
[0] = 0x00000000;
970 header
.phAttributes
[1] = 0x00000000;
971 header
.phRenderingIntent
= 0x00000000;
972 header
.phIlluminant
.ciexyzX
= 0x0000f6d6;
973 header
.phIlluminant
.ciexyzY
= 0x00010000;
974 header
.phIlluminant
.ciexyzZ
= 0x0000d32d;
975 header
.phCreator
= 0x48502020;
977 /* Parameter checks */
978 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
979 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
981 ret
= SetColorProfileHeader( handle
, &header
);
982 ok( !ret
, "SetColorProfileHeader() succeeded (%lu)\n", GetLastError() );
983 CloseColorProfile( handle
);
985 handle
= OpenColorProfileA( &profile
, PROFILE_READWRITE
, 0, OPEN_EXISTING
);
986 ok( handle
!= NULL
, "OpenColorProfileA() failed (%lu)\n", GetLastError() );
988 ret
= SetColorProfileHeader( NULL
, NULL
);
989 ok( !ret
, "SetColorProfileHeader() succeeded (%lu)\n", GetLastError() );
991 ret
= SetColorProfileHeader( handle
, NULL
);
992 ok( !ret
, "SetColorProfileHeader() succeeded (%lu)\n", GetLastError() );
994 ret
= SetColorProfileHeader( NULL
, &header
);
995 ok( !ret
, "SetColorProfileHeader() succeeded (%lu)\n", GetLastError() );
997 /* Functional checks */
998 ret
= SetColorProfileHeader( handle
, &header
);
999 ok( ret
, "SetColorProfileHeader() failed (%lu)\n", GetLastError() );
1001 ret
= GetColorProfileHeader( handle
, &header
);
1002 ok( ret
, "GetColorProfileHeader() failed (%lu)\n", GetLastError() );
1003 ok( !memcmp( &header
, rgbheader
, sizeof(rgbheader
) ), "Unexpected header data\n" );
1004 CloseColorProfile( handle
);
1008 static void test_UninstallColorProfileA( char *testprofile
)
1012 /* Parameter checks */
1013 ret
= UninstallColorProfileA( NULL
, NULL
, FALSE
);
1014 ok( !ret
, "UninstallColorProfileA() succeeded (%lu)\n", GetLastError() );
1016 ret
= UninstallColorProfileA( machine
, NULL
, FALSE
);
1017 ok( !ret
, "UninstallColorProfileA() succeeded (%lu)\n", GetLastError() );
1019 /* Functional checks */
1022 CHAR dest
[MAX_PATH
], base
[MAX_PATH
];
1023 DWORD size
= sizeof(dest
);
1026 SetLastError(0xdeadbeef);
1027 ret
= InstallColorProfileA( NULL
, testprofile
);
1028 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
1030 skip("Not enough rights for InstallColorProfileA\n");
1033 ok( ret
, "InstallColorProfileA() failed (%lu)\n", GetLastError() );
1035 ret
= GetColorDirectoryA( NULL
, dest
, &size
);
1036 ok( ret
, "GetColorDirectoryA() failed (%lu)\n", GetLastError() );
1038 MSCMS_basenameA( testprofile
, base
);
1039 lstrcatA( dest
, "\\" );
1040 lstrcatA( dest
, base
);
1042 ret
= UninstallColorProfileA( NULL
, dest
, TRUE
);
1043 ok( ret
, "UninstallColorProfileA() failed (%lu)\n", GetLastError() );
1045 /* Check if the profile is really gone */
1046 handle
= CreateFileA( dest
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
1047 ok( handle
== INVALID_HANDLE_VALUE
, "Found the profile (%lu)\n", GetLastError() );
1048 CloseHandle( handle
);
1052 static void test_UninstallColorProfileW( WCHAR
*testprofileW
)
1056 /* Parameter checks */
1057 ret
= UninstallColorProfileW( NULL
, NULL
, FALSE
);
1058 ok( !ret
, "UninstallColorProfileW() succeeded (%lu)\n", GetLastError() );
1060 ret
= UninstallColorProfileW( machineW
, NULL
, FALSE
);
1061 ok( !ret
, "UninstallColorProfileW() succeeded (%lu)\n", GetLastError() );
1063 /* Functional checks */
1066 WCHAR dest
[MAX_PATH
], base
[MAX_PATH
];
1067 char destA
[MAX_PATH
];
1068 DWORD size
= sizeof(dest
);
1072 SetLastError(0xdeadbeef);
1073 ret
= InstallColorProfileW( NULL
, testprofileW
);
1074 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
1076 skip("Not enough rights for InstallColorProfileW\n");
1079 ok( ret
, "InstallColorProfileW() failed (%lu)\n", GetLastError() );
1081 ret
= GetColorDirectoryW( NULL
, dest
, &size
);
1082 ok( ret
, "GetColorDirectoryW() failed (%lu)\n", GetLastError() );
1084 MSCMS_basenameW( testprofileW
, base
);
1085 lstrcatW( dest
, L
"\\" );
1086 lstrcatW( dest
, base
);
1088 ret
= UninstallColorProfileW( NULL
, dest
, TRUE
);
1089 ok( ret
, "UninstallColorProfileW() failed (%lu)\n", GetLastError() );
1091 bytes_copied
= WideCharToMultiByte(CP_ACP
, 0, dest
, -1, destA
, MAX_PATH
, NULL
, NULL
);
1092 ok( bytes_copied
> 0 , "WideCharToMultiByte() returns %d\n", bytes_copied
);
1093 /* Check if the profile is really gone */
1094 handle
= CreateFileA( destA
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
1095 ok( handle
== INVALID_HANDLE_VALUE
, "Found the profile (%lu)\n", GetLastError() );
1096 CloseHandle( handle
);
1100 static void test_AssociateColorProfileWithDeviceA( char *testprofile
)
1103 char profile
[MAX_PATH
], basename
[MAX_PATH
];
1104 DWORD error
, size
= sizeof(profile
);
1105 DISPLAY_DEVICEA display
, monitor
;
1110 display
.cb
= sizeof( DISPLAY_DEVICEA
);
1111 res
= EnumDisplayDevicesA( NULL
, 0, &display
, 0 );
1112 ok( res
, "Can't get display info\n" );
1114 monitor
.cb
= sizeof( DISPLAY_DEVICEA
);
1115 res
= EnumDisplayDevicesA( display
.DeviceName
, 0, &monitor
, 0 );
1118 SetLastError(0xdeadbeef);
1119 ret
= AssociateColorProfileWithDeviceA( "machine", testprofile
, NULL
);
1120 error
= GetLastError();
1121 ok( !ret
, "AssociateColorProfileWithDevice() succeeded\n" );
1122 ok( error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %lu\n", error
);
1124 SetLastError(0xdeadbeef);
1125 ret
= AssociateColorProfileWithDeviceA( "machine", NULL
, monitor
.DeviceID
);
1126 error
= GetLastError();
1127 ok( !ret
, "AssociateColorProfileWithDevice() succeeded\n" );
1128 ok( error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %lu\n", error
);
1130 SetLastError(0xdeadbeef);
1131 ret
= AssociateColorProfileWithDeviceA( "machine", testprofile
, monitor
.DeviceID
);
1132 error
= GetLastError();
1133 ok( !ret
, "AssociateColorProfileWithDevice() succeeded\n" );
1134 ok( error
== ERROR_NOT_SUPPORTED
, "expected ERROR_NOT_SUPPORTED, got %lu\n", error
);
1136 ret
= InstallColorProfileA( NULL
, testprofile
);
1137 ok( ret
, "InstallColorProfileA() failed (%lu)\n", GetLastError() );
1139 ret
= GetColorDirectoryA( NULL
, profile
, &size
);
1140 ok( ret
, "GetColorDirectoryA() failed (%lu)\n", GetLastError() );
1142 MSCMS_basenameA( testprofile
, basename
);
1143 lstrcatA( profile
, "\\" );
1144 lstrcatA( profile
, basename
);
1146 ret
= AssociateColorProfileWithDeviceA( NULL
, profile
, monitor
.DeviceID
);
1147 ok( ret
, "AssociateColorProfileWithDevice() failed (%lu)\n", GetLastError() );
1149 SetLastError(0xdeadbeef);
1150 ret
= DisassociateColorProfileFromDeviceA( "machine", profile
, NULL
);
1151 error
= GetLastError();
1152 ok( !ret
, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1153 ok( error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %lu\n", error
);
1155 SetLastError(0xdeadbeef);
1156 ret
= DisassociateColorProfileFromDeviceA( "machine", NULL
, monitor
.DeviceID
);
1157 error
= GetLastError();
1158 ok( !ret
, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1159 ok( error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %lu\n", error
);
1161 SetLastError(0xdeadbeef);
1162 ret
= DisassociateColorProfileFromDeviceA( "machine", profile
, monitor
.DeviceID
);
1163 error
= GetLastError();
1164 ok( !ret
, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1165 ok( error
== ERROR_NOT_SUPPORTED
, "expected ERROR_NOT_SUPPORTED, got %lu\n", error
);
1167 ret
= DisassociateColorProfileFromDeviceA( NULL
, profile
, monitor
.DeviceID
);
1168 ok( ret
, "DisassociateColorProfileFromDeviceA() failed (%lu)\n", GetLastError() );
1170 ret
= UninstallColorProfileA( NULL
, profile
, TRUE
);
1171 ok( ret
, "UninstallColorProfileA() failed (%lu)\n", GetLastError() );
1174 skip("Unable to obtain monitor name\n");
1178 static BOOL
have_profile(void)
1180 char glob
[MAX_PATH
+ sizeof("\\*.icm")];
1181 DWORD size
= MAX_PATH
;
1183 WIN32_FIND_DATAA data
;
1185 if (!GetColorDirectoryA( NULL
, glob
, &size
)) return FALSE
;
1186 lstrcatA( glob
, "\\*.icm" );
1187 handle
= FindFirstFileA( glob
, &data
);
1188 if (handle
== INVALID_HANDLE_VALUE
) return FALSE
;
1189 FindClose( handle
);
1193 static void test_CreateMultiProfileTransform( char *standardprofile
, char *testprofile
)
1197 HTRANSFORM transform
;
1198 DWORD intents
[2] = { INTENT_PERCEPTUAL
, INTENT_PERCEPTUAL
};
1202 profile
.dwType
= PROFILE_FILENAME
;
1203 profile
.pProfileData
= standardprofile
;
1204 profile
.cbDataSize
= strlen(standardprofile
);
1206 handle
[0] = OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
1207 ok( handle
[0] != NULL
, "got %lu\n", GetLastError() );
1209 profile
.dwType
= PROFILE_FILENAME
;
1210 profile
.pProfileData
= testprofile
;
1211 profile
.cbDataSize
= strlen(testprofile
);
1213 handle
[1] = OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
1214 ok( handle
[1] != NULL
, "got %lu\n", GetLastError() );
1216 transform
= CreateMultiProfileTransform( handle
, 2, intents
, 2, 0, 0 );
1217 ok( transform
!= NULL
, "got %lu\n", GetLastError() );
1219 DeleteColorTransform( transform
);
1220 CloseColorProfile( handle
[0] );
1221 CloseColorProfile( handle
[1] );
1225 static void test_TranslateBitmapBits( char *standardprofile
, char *testprofile
)
1229 HTRANSFORM transform
;
1230 DWORD intent
= INTENT_PERCEPTUAL
;
1231 BYTE srcbits
[] = {0x00, 0x00, 0xff}, srcbits2
[] = {0xcc, 0x00, 0x00, 0xff}, destbits
[4];
1232 const BYTE expect_destbits
[] = {0xff, 0x00, 0x00, 0x00};
1233 const BYTE expect_destbits2
[] = {0x00, 0x00, 0xff, 0x00};
1234 const BYTE expect_destbits3
[] = {0xcc, 0x00, 0x00};
1235 const BYTE expect_destbits4
[] = {0x00, 0x00, 0xcc};
1238 if (!standardprofile
) return;
1240 profile
.dwType
= PROFILE_FILENAME
;
1241 profile
.pProfileData
= standardprofile
;
1242 profile
.cbDataSize
= strlen(standardprofile
);
1244 handle
[0] = OpenColorProfileA( &profile
, PROFILE_READ
, 1, OPEN_EXISTING
);
1245 ok( handle
[0] != NULL
, "got %lu\n", GetLastError() );
1247 profile
.dwType
= PROFILE_FILENAME
;
1248 profile
.pProfileData
= testprofile
;
1249 profile
.cbDataSize
= strlen(testprofile
);
1251 handle
[1] = OpenColorProfileA( &profile
, PROFILE_READ
, 1, OPEN_EXISTING
);
1252 ok( handle
[1] != NULL
, "got %lu\n", GetLastError() );
1254 transform
= CreateMultiProfileTransform( handle
, 2, &intent
, 1, 0, 0 );
1255 ok( transform
!= NULL
, "got %lu\n", GetLastError() );
1257 memset( destbits
, 0, sizeof(destbits
) );
1258 ret
= TranslateBitmapBits( transform
, srcbits
, BM_RGBTRIPLETS
, 1, 1, 3, destbits
, BM_xBGRQUADS
, 4, NULL
, 0 );
1259 ok( ret
, "got %lu\n", GetLastError() );
1260 ok( !memcmp(expect_destbits
, destbits
, sizeof(expect_destbits
)), "unexpected destbits\n" );
1262 memset( destbits
, 0, sizeof(destbits
) );
1263 ret
= TranslateBitmapBits( transform
, srcbits
, BM_RGBTRIPLETS
, 1, 1, 3, destbits
, BM_xRGBQUADS
, 4, NULL
, 0 );
1264 ok( ret
, "got %lu\n", GetLastError() );
1265 ok( !memcmp(expect_destbits2
, destbits
, sizeof(expect_destbits2
)), "unexpected destbits\n" );
1267 memset( destbits
, 0, sizeof(destbits
) );
1268 ret
= TranslateBitmapBits( transform
, srcbits2
, BM_xRGBQUADS
, 1, 1, 4, destbits
, BM_RGBTRIPLETS
, 3, NULL
, 0 );
1269 ok( ret
, "got %lu\n", GetLastError() );
1270 ok( !memcmp(expect_destbits3
, destbits
, sizeof(expect_destbits3
)), "unexpected destbits\n" );
1272 memset( destbits
, 0, sizeof(destbits
) );
1273 ret
= TranslateBitmapBits( transform
, srcbits2
, BM_xRGBQUADS
, 1, 1, 4, destbits
, BM_BGRTRIPLETS
, 3, NULL
, 0 );
1274 ok( ret
, "got %lu\n", GetLastError() );
1275 ok( !memcmp(expect_destbits4
, destbits
, sizeof(expect_destbits4
)), "unexpected destbits\n" );
1277 DeleteColorTransform( transform
);
1278 CloseColorProfile( handle
[0] );
1279 CloseColorProfile( handle
[1] );
1286 char path
[MAX_PATH
], file
[MAX_PATH
], profilefile1
[MAX_PATH
], profilefile2
[MAX_PATH
];
1287 WCHAR profilefile1W
[MAX_PATH
], profilefile2W
[MAX_PATH
], fileW
[MAX_PATH
];
1288 char *standardprofile
= NULL
, *testprofile
= NULL
;
1289 WCHAR
*standardprofileW
= NULL
, *testprofileW
= NULL
;
1292 /* See if we can find the standard color profile */
1293 ret
= GetSystemDirectoryA( profilefile1
, sizeof(profilefile1
) );
1294 ok( ret
> 0, "GetSystemDirectoryA() returns %d, LastError = %lu\n", ret
, GetLastError());
1295 ok(profilefile1
[0] && lstrlenA(profilefile1
) < MAX_PATH
,
1296 "Expected length between 0 and MAX_PATH, got %d\n", lstrlenA(profilefile1
));
1297 MultiByteToWideChar(CP_ACP
, 0, profilefile1
, -1, profilefile1W
, MAX_PATH
);
1298 ok(profilefile1W
[0] && lstrlenW(profilefile1W
) < MAX_PATH
,
1299 "Expected length between 0 and MAX_PATH, got %d\n", lstrlenW(profilefile1W
));
1300 lstrcpyA(profilefile2
, profilefile1
);
1301 lstrcpyW(profilefile2W
, profilefile1W
);
1303 lstrcatA( profilefile1
, profile1
);
1304 lstrcatW( profilefile1W
, profile1W
);
1305 handle
= CreateFileA( profilefile1
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
1307 if (handle
!= INVALID_HANDLE_VALUE
)
1309 standardprofile
= profilefile1
;
1310 standardprofileW
= profilefile1W
;
1311 CloseHandle( handle
);
1314 lstrcatA( profilefile2
, profile2
);
1315 lstrcatW( profilefile2W
, profile2W
);
1316 handle
= CreateFileA( profilefile2
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
1318 if (handle
!= INVALID_HANDLE_VALUE
)
1320 standardprofile
= profilefile2
;
1321 standardprofileW
= profilefile2W
;
1322 CloseHandle( handle
);
1325 /* If found, create a temporary copy for testing purposes */
1326 if (standardprofile
&& GetTempPathA( sizeof(path
), path
))
1328 if (GetTempFileNameA( path
, "rgb", 0, file
))
1330 if (CopyFileA( standardprofile
, file
, FALSE
))
1332 testprofile
= (LPSTR
)&file
;
1333 len
= MultiByteToWideChar( CP_ACP
, 0, testprofile
, -1, NULL
, 0 );
1334 MultiByteToWideChar( CP_ACP
, 0, testprofile
, -1, fileW
, len
);
1335 testprofileW
= (LPWSTR
)&fileW
;
1340 have_color_profile
= have_profile();
1342 test_GetColorDirectoryA();
1343 test_GetColorDirectoryW();
1345 test_GetColorProfileElement( standardprofile
);
1346 test_GetColorProfileElementTag( standardprofile
);
1348 test_GetColorProfileFromHandle( testprofile
);
1349 test_GetColorProfileHeader( testprofile
);
1351 test_GetCountColorProfileElements( standardprofile
);
1353 test_GetStandardColorSpaceProfileA( standardprofile
);
1354 test_GetStandardColorSpaceProfileW( standardprofileW
);
1356 test_EnumColorProfilesA( standardprofile
);
1357 test_EnumColorProfilesW( standardprofileW
);
1359 test_InstallColorProfileA( standardprofile
, testprofile
);
1360 test_InstallColorProfileW( standardprofileW
, testprofileW
);
1362 test_IsColorProfileTagPresent( standardprofile
);
1364 test_OpenColorProfileA( standardprofile
);
1365 test_OpenColorProfileW( standardprofileW
);
1367 test_SetColorProfileElement( testprofile
);
1368 test_SetColorProfileHeader( testprofile
);
1370 test_UninstallColorProfileA( testprofile
);
1371 test_UninstallColorProfileW( testprofileW
);
1373 test_AssociateColorProfileWithDeviceA( testprofile
);
1374 test_CreateMultiProfileTransform( standardprofile
, testprofile
);
1375 test_TranslateBitmapBits( standardprofile
, testprofile
);
1377 if (testprofile
) DeleteFileA( testprofile
);