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 HMODULE hmscms;
34 static HMODULE huser32;
36 static BOOL (WINAPI *pAssociateColorProfileWithDeviceA)(PCSTR,PCSTR,PCSTR);
37 static BOOL (WINAPI *pCloseColorProfile)(HPROFILE);
38 static BOOL (WINAPI *pDisassociateColorProfileFromDeviceA)(PCSTR,PCSTR,PCSTR);
39 static BOOL (WINAPI *pGetColorDirectoryA)(PCHAR,PCHAR,PDWORD);
40 static BOOL (WINAPI *pGetColorDirectoryW)(PWCHAR,PWCHAR,PDWORD);
41 static BOOL (WINAPI *pGetColorProfileElement)(HPROFILE,TAGTYPE,DWORD,PDWORD,PVOID,PBOOL);
42 static BOOL (WINAPI *pGetColorProfileElementTag)(HPROFILE,DWORD,PTAGTYPE);
43 static BOOL (WINAPI *pGetColorProfileFromHandle)(HPROFILE,PBYTE,PDWORD);
44 static BOOL (WINAPI *pGetColorProfileHeader)(HPROFILE,PPROFILEHEADER);
45 static BOOL (WINAPI *pGetCountColorProfileElements)(HPROFILE,PDWORD);
46 static BOOL (WINAPI *pGetStandardColorSpaceProfileA)(PCSTR,DWORD,PSTR,PDWORD);
47 static BOOL (WINAPI *pGetStandardColorSpaceProfileW)(PCWSTR,DWORD,PWSTR,PDWORD);
48 static BOOL (WINAPI *pEnumColorProfilesA)(PCSTR,PENUMTYPEA,PBYTE,PDWORD,PDWORD);
49 static BOOL (WINAPI *pEnumColorProfilesW)(PCWSTR,PENUMTYPEW,PBYTE,PDWORD,PDWORD);
50 static BOOL (WINAPI *pInstallColorProfileA)(PCSTR,PCSTR);
51 static BOOL (WINAPI *pInstallColorProfileW)(PCWSTR,PCWSTR);
52 static BOOL (WINAPI *pIsColorProfileTagPresent)(HPROFILE,TAGTYPE,PBOOL);
53 static HPROFILE (WINAPI *pOpenColorProfileA)(PPROFILE,DWORD,DWORD,DWORD);
54 static HPROFILE (WINAPI *pOpenColorProfileW)(PPROFILE,DWORD,DWORD,DWORD);
55 static BOOL (WINAPI *pSetColorProfileElement)(HPROFILE,TAGTYPE,DWORD,PDWORD,PVOID);
56 static BOOL (WINAPI *pSetColorProfileHeader)(HPROFILE,PPROFILEHEADER);
57 static BOOL (WINAPI *pSetStandardColorSpaceProfileA)(PCSTR,DWORD,PSTR);
58 static BOOL (WINAPI *pSetStandardColorSpaceProfileW)(PCWSTR,DWORD,PWSTR);
59 static BOOL (WINAPI *pUninstallColorProfileA)(PCSTR,PCSTR,BOOL);
60 static BOOL (WINAPI *pUninstallColorProfileW)(PCWSTR,PCWSTR,BOOL);
62 static BOOL (WINAPI *pEnumDisplayDevicesA)(LPCSTR,DWORD,PDISPLAY_DEVICE,DWORD);
64 #define GETFUNCPTR(func) p##func = (void *)GetProcAddress( hmscms, #func ); \
65 if (!p##func) return FALSE;
67 static BOOL init_function_ptrs( void )
69 GETFUNCPTR( AssociateColorProfileWithDeviceA )
70 GETFUNCPTR( CloseColorProfile )
71 GETFUNCPTR( DisassociateColorProfileFromDeviceA )
72 GETFUNCPTR( GetColorDirectoryA )
73 GETFUNCPTR( GetColorDirectoryW )
74 GETFUNCPTR( GetColorProfileElement )
75 GETFUNCPTR( GetColorProfileElementTag )
76 GETFUNCPTR( GetColorProfileFromHandle )
77 GETFUNCPTR( GetColorProfileHeader )
78 GETFUNCPTR( GetCountColorProfileElements )
79 GETFUNCPTR( GetStandardColorSpaceProfileA )
80 GETFUNCPTR( GetStandardColorSpaceProfileW )
81 GETFUNCPTR( EnumColorProfilesA )
82 GETFUNCPTR( EnumColorProfilesW )
83 GETFUNCPTR( InstallColorProfileA )
84 GETFUNCPTR( InstallColorProfileW )
85 GETFUNCPTR( IsColorProfileTagPresent )
86 GETFUNCPTR( OpenColorProfileA )
87 GETFUNCPTR( OpenColorProfileW )
88 GETFUNCPTR( SetColorProfileElement )
89 GETFUNCPTR( SetColorProfileHeader )
90 GETFUNCPTR( SetStandardColorSpaceProfileA )
91 GETFUNCPTR( SetStandardColorSpaceProfileW )
92 GETFUNCPTR( UninstallColorProfileA )
93 GETFUNCPTR( UninstallColorProfileW )
95 pEnumDisplayDevicesA = (void *)GetProcAddress( huser32, "EnumDisplayDevicesA" );
100 static const char machine[] = "dummy";
101 static const WCHAR machineW[] = { 'd','u','m','m','y',0 };
103 /* To do any real functionality testing with this suite you need a copy of
104 * the freely distributable standard RGB color space profile. It comes
105 * standard with Windows, but on Wine you probably need to install it yourself
106 * in one of the locations mentioned below.
109 /* Two common places to find the standard color space profile, relative
110 * to the system directory.
112 static const char profile1[] =
113 "\\color\\srgb color space profile.icm";
114 static const char profile2[] =
115 "\\spool\\drivers\\color\\srgb color space profile.icm";
117 static const WCHAR profile1W[] =
118 { '\\','c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
119 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
120 static const WCHAR profile2W[] =
121 { '\\','s','p','o','o','l','\\','d','r','i','v','e','r','s','\\',
122 'c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
123 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
125 static const unsigned char rgbheader[] =
126 { 0x48, 0x0c, 0x00, 0x00, 0x6f, 0x6e, 0x69, 0x4c, 0x00, 0x00, 0x10, 0x02,
127 0x72, 0x74, 0x6e, 0x6d, 0x20, 0x42, 0x47, 0x52, 0x20, 0x5a, 0x59, 0x58,
128 0x02, 0x00, 0xce, 0x07, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, 0x31, 0x00,
129 0x70, 0x73, 0x63, 0x61, 0x54, 0x46, 0x53, 0x4d, 0x00, 0x00, 0x00, 0x00,
130 0x20, 0x43, 0x45, 0x49, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00,
131 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xf6, 0x00, 0x00,
132 0x00, 0x00, 0x01, 0x00, 0x2d, 0xd3, 0x00, 0x00, 0x20, 0x20, 0x50, 0x48 };
134 #define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
136 static void MSCMS_basenameA( LPCSTR path, LPSTR name )
138 INT i = strlen( path );
140 while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
141 strcpy( name, &path[i] );
144 static void MSCMS_basenameW( LPCWSTR path, LPWSTR name )
146 INT i = lstrlenW( path );
148 while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
149 lstrcpyW( name, &path[i] );
152 static void test_GetColorDirectoryA(void)
156 char buffer[MAX_PATH];
158 /* Parameter checks */
160 ret = pGetColorDirectoryA( NULL, NULL, NULL );
161 ok( !ret, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
165 ret = pGetColorDirectoryA( NULL, NULL, &size );
166 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
170 ret = pGetColorDirectoryA( NULL, buffer, &size );
171 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
175 ret = pGetColorDirectoryA( NULL, buffer, &size );
176 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
178 /* Functional checks */
180 size = sizeof(buffer);
182 ret = pGetColorDirectoryA( NULL, buffer, &size );
183 ok( ret && size > 0, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
186 static void test_GetColorDirectoryW(void)
190 WCHAR buffer[MAX_PATH];
192 /* Parameter checks */
194 /* This one crashes win2k
196 ret = pGetColorDirectoryW( NULL, NULL, NULL );
197 ok( !ret, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
203 ret = pGetColorDirectoryW( NULL, NULL, &size );
204 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
208 ret = pGetColorDirectoryW( NULL, buffer, &size );
209 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
213 ret = pGetColorDirectoryW( NULL, buffer, &size );
214 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
216 /* Functional checks */
218 size = sizeof(buffer);
220 ret = pGetColorDirectoryW( NULL, buffer, &size );
221 ok( ret && size > 0, "GetColorDirectoryW() failed (%d)\n", GetLastError() );
224 static void test_GetColorProfileElement( char *standardprofile )
232 TAGTYPE tag = 0x63707274; /* 'cprt' */
233 static char buffer[51];
234 static const char expect[] =
235 { 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x70,
236 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20,
237 0x31, 0x39, 0x39, 0x38, 0x20, 0x48, 0x65, 0x77, 0x6c, 0x65, 0x74,
238 0x74, 0x2d, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x72, 0x64, 0x20, 0x43,
239 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x00 };
241 profile.dwType = PROFILE_FILENAME;
242 profile.pProfileData = standardprofile;
243 profile.cbDataSize = strlen(standardprofile);
245 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
246 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
248 /* Parameter checks */
250 ret = pGetColorProfileElement( handle, tag, 0, NULL, NULL, &ref );
251 ok( !ret, "GetColorProfileElement() succeeded (%d)\n", GetLastError() );
253 ret = pGetColorProfileElement( handle, tag, 0, &size, NULL, NULL );
254 ok( !ret, "GetColorProfileElement() succeeded (%d)\n", GetLastError() );
258 ret = pGetColorProfileElement( handle, tag, 0, &size, NULL, &ref );
259 ok( !ret && size > 0, "GetColorProfileElement() succeeded (%d)\n", GetLastError() );
261 size = sizeof(buffer);
263 /* Functional checks */
265 ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
266 ok( ret && size > 0, "GetColorProfileElement() failed (%d)\n", GetLastError() );
268 ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected tag data\n" );
270 pCloseColorProfile( handle );
274 static void test_GetColorProfileElementTag( char *standardprofile )
282 TAGTYPE tag, expect = 0x63707274; /* 'cprt' */
284 profile.dwType = PROFILE_FILENAME;
285 profile.pProfileData = standardprofile;
286 profile.cbDataSize = strlen(standardprofile);
288 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
289 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
291 /* Parameter checks */
293 ret = pGetColorProfileElementTag( NULL, index, &tag );
294 ok( !ret, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
296 ret = pGetColorProfileElementTag( handle, 0, &tag );
297 ok( !ret, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
299 ret = pGetColorProfileElementTag( handle, index, NULL );
300 ok( !ret, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
302 ret = pGetColorProfileElementTag( handle, 18, NULL );
303 ok( !ret, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
305 /* Functional checks */
307 ret = pGetColorProfileElementTag( handle, index, &tag );
308 ok( ret && tag == expect, "GetColorProfileElementTag() failed (%d)\n",
311 pCloseColorProfile( handle );
315 static void test_GetColorProfileFromHandle( char *testprofile )
323 static const unsigned char expect[] =
324 { 0x00, 0x00, 0x0c, 0x48, 0x4c, 0x69, 0x6e, 0x6f, 0x02, 0x10, 0x00,
325 0x00, 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59,
326 0x5a, 0x20, 0x07, 0xce, 0x00, 0x02, 0x00, 0x09, 0x00, 0x06, 0x00,
327 0x31, 0x00, 0x00, 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54,
328 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47,
329 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
330 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00,
331 0x00, 0xd3, 0x2d, 0x48, 0x50, 0x20, 0x20 };
333 unsigned char *buffer;
335 profile.dwType = PROFILE_FILENAME;
336 profile.pProfileData = testprofile;
337 profile.cbDataSize = strlen(testprofile);
339 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
340 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
342 /* Parameter checks */
346 ret = pGetColorProfileFromHandle( handle, NULL, &size );
347 ok( !ret && size > 0, "GetColorProfileFromHandle() failed (%d)\n", GetLastError() );
349 buffer = HeapAlloc( GetProcessHeap(), 0, size );
353 ret = pGetColorProfileFromHandle( NULL, buffer, &size );
354 ok( !ret, "GetColorProfileFromHandle() succeeded (%d)\n", GetLastError() );
356 ret = pGetColorProfileFromHandle( handle, buffer, NULL );
357 ok( !ret, "GetColorProfileFromHandle() succeeded (%d)\n", GetLastError() );
359 /* Functional checks */
361 ret = pGetColorProfileFromHandle( handle, buffer, &size );
362 ok( ret && size > 0, "GetColorProfileFromHandle() failed (%d)\n", GetLastError() );
364 ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected header data\n" );
366 HeapFree( GetProcessHeap(), 0, buffer );
369 pCloseColorProfile( handle );
373 static void test_GetColorProfileHeader( char *testprofile )
380 PROFILEHEADER header;
382 profile.dwType = PROFILE_FILENAME;
383 profile.pProfileData = testprofile;
384 profile.cbDataSize = strlen(testprofile);
386 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
387 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
389 /* Parameter checks */
391 ret = pGetColorProfileHeader( NULL, NULL );
392 ok( !ret, "GetColorProfileHeader() succeeded (%d)\n", GetLastError() );
394 ret = pGetColorProfileHeader( NULL, &header );
395 ok( !ret, "GetColorProfileHeader() succeeded (%d)\n", GetLastError() );
397 if (0) /* Crashes on Vista */
399 ret = pGetColorProfileHeader( handle, NULL );
400 ok( !ret, "GetColorProfileHeader() succeeded (%d)\n", GetLastError() );
403 /* Functional checks */
405 ret = pGetColorProfileHeader( handle, &header );
406 ok( ret, "GetColorProfileHeader() failed (%d)\n", GetLastError() );
408 ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" );
410 pCloseColorProfile( handle );
414 static void test_GetCountColorProfileElements( char *standardprofile )
421 DWORD count, expect = 17;
423 profile.dwType = PROFILE_FILENAME;
424 profile.pProfileData = standardprofile;
425 profile.cbDataSize = strlen(standardprofile);
427 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
428 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
430 /* Parameter checks */
432 ret = pGetCountColorProfileElements( NULL, &count );
433 ok( !ret, "GetCountColorProfileElements() succeeded (%d)\n",
436 ret = pGetCountColorProfileElements( handle, NULL );
437 ok( !ret, "GetCountColorProfileElements() succeeded (%d)\n",
440 /* Functional checks */
442 ret = pGetCountColorProfileElements( handle, &count );
443 ok( ret && count == expect,
444 "GetCountColorProfileElements() failed (%d)\n", GetLastError() );
446 pCloseColorProfile( handle );
450 static void test_GetStandardColorSpaceProfileA( char *standardprofile )
454 CHAR oldprofile[MAX_PATH];
455 CHAR newprofile[MAX_PATH];
457 /* Parameter checks */
459 /* Single invalid parameter checks: */
461 size = sizeof(newprofile);
462 SetLastError(0xfaceabee); /* 1st param, */
463 ret = pGetStandardColorSpaceProfileA(machine, LCS_sRGB, newprofile, &size);
464 ok( !ret && GetLastError() == ERROR_NOT_SUPPORTED, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
466 size = sizeof(newprofile);
467 SetLastError(0xfaceabee); /* 2nd param, */
468 ret = pGetStandardColorSpaceProfileA(NULL, (DWORD)-1, newprofile, &size);
469 ok( !ret && GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
471 size = sizeof(newprofile);
472 SetLastError(0xfaceabee); /* 4th param, */
473 ret = pGetStandardColorSpaceProfileA(NULL, LCS_sRGB, newprofile, NULL);
474 ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
476 size = sizeof(newprofile);
477 SetLastError(0xfaceabee); /* 3rd param, */
478 ret = pGetStandardColorSpaceProfileA(NULL, LCS_sRGB, NULL, &size);
479 ok( !ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
482 SetLastError(0xfaceabee); /* dereferenced 4th param, */
483 ret = pGetStandardColorSpaceProfileA(NULL, LCS_sRGB, newprofile, &size);
484 ok( !ret && (GetLastError() == ERROR_MORE_DATA || GetLastError() == ERROR_INSUFFICIENT_BUFFER),
485 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
487 /* Several invalid parameter checks: */
490 SetLastError(0xfaceabee); /* 1st, maybe 2nd and then dereferenced 4th param, */
491 ret = pGetStandardColorSpaceProfileA(machine, 0, newprofile, &size);
492 ok( !ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_NOT_SUPPORTED),
493 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
495 SetLastError(0xfaceabee); /* maybe 2nd and then 4th param, */
496 ret = pGetStandardColorSpaceProfileA(NULL, 0, newprofile, NULL);
497 ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
500 SetLastError(0xfaceabee); /* maybe 2nd, then 3rd and dereferenced 4th param, */
501 ret = pGetStandardColorSpaceProfileA(NULL, 0, NULL, &size);
502 ok( !ret && (GetLastError() == ERROR_INSUFFICIENT_BUFFER || GetLastError() == ERROR_FILE_NOT_FOUND),
503 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
505 size = sizeof(newprofile);
506 SetLastError(0xfaceabee); /* maybe 2nd param. */
507 ret = pGetStandardColorSpaceProfileA(NULL, 0, newprofile, &size);
508 if (!ret) ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
509 else ok( !lstrcmpiA( newprofile, "" ) && GetLastError() == 0xfaceabee,
510 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
512 /* Functional checks */
514 size = sizeof(oldprofile);
515 ret = pGetStandardColorSpaceProfileA( NULL, LCS_sRGB, oldprofile, &size );
516 ok( ret, "GetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
518 SetLastError(0xdeadbeef);
519 ret = pSetStandardColorSpaceProfileA( NULL, LCS_sRGB, standardprofile );
520 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
522 skip("Not enough rights for SetStandardColorSpaceProfileA\n");
525 ok( ret, "SetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
527 size = sizeof(newprofile);
528 ret = pGetStandardColorSpaceProfileA( NULL, LCS_sRGB, newprofile, &size );
529 ok( ret, "GetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
531 ret = pSetStandardColorSpaceProfileA( NULL, LCS_sRGB, oldprofile );
532 ok( ret, "SetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
535 static void test_GetStandardColorSpaceProfileW( WCHAR *standardprofileW )
539 WCHAR oldprofile[MAX_PATH];
540 WCHAR newprofile[MAX_PATH];
541 CHAR newprofileA[MAX_PATH];
543 /* Parameter checks */
545 /* Single invalid parameter checks: */
547 size = sizeof(newprofile);
548 SetLastError(0xfaceabee); /* 1st param, */
549 ret = pGetStandardColorSpaceProfileW(machineW, LCS_sRGB, newprofile, &size);
550 ok( !ret && GetLastError() == ERROR_NOT_SUPPORTED, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
552 size = sizeof(newprofile);
553 SetLastError(0xfaceabee); /* 2nd param, */
554 ret = pGetStandardColorSpaceProfileW(NULL, (DWORD)-1, newprofile, &size);
555 ok( !ret && GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
557 size = sizeof(newprofile);
558 SetLastError(0xfaceabee); /* 2nd param, */
559 ret = pGetStandardColorSpaceProfileW(NULL, 0, newprofile, &size);
560 ok( (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) ||
561 broken(ret), /* Win98 and WinME */
562 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
564 size = sizeof(newprofile);
565 SetLastError(0xfaceabee); /* 3rd param, */
566 ret = pGetStandardColorSpaceProfileW(NULL, LCS_sRGB, NULL, &size);
567 ok( !ret || broken(ret) /* win98 */, "GetStandardColorSpaceProfileW succeeded\n" );
568 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
569 broken(GetLastError() == 0xfaceabee) /* win98 */,
570 "GetStandardColorSpaceProfileW() returns GLE=%u\n", GetLastError() );
572 size = sizeof(newprofile);
573 SetLastError(0xfaceabee); /* 4th param, */
574 ret = pGetStandardColorSpaceProfileW(NULL, LCS_sRGB, newprofile, NULL);
575 ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
578 SetLastError(0xfaceabee); /* dereferenced 4th param. */
579 ret = pGetStandardColorSpaceProfileW(NULL, LCS_sRGB, newprofile, &size);
580 ok( !ret || broken(ret) /* win98 */, "GetStandardColorSpaceProfileW succeeded\n" );
581 ok( GetLastError() == ERROR_MORE_DATA ||
582 GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
583 broken(GetLastError() == 0xfaceabee) /* win98 */,
584 "GetStandardColorSpaceProfileW() returns GLE=%u\n", GetLastError() );
586 /* Several invalid parameter checks: */
589 SetLastError(0xfaceabee); /* 1st, maybe 2nd and then dereferenced 4th param, */
590 ret = pGetStandardColorSpaceProfileW(machineW, 0, newprofile, &size);
591 ok( !ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_NOT_SUPPORTED),
592 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
594 SetLastError(0xfaceabee); /* maybe 2nd and then 4th param, */
595 ret = pGetStandardColorSpaceProfileW(NULL, 0, newprofile, NULL);
596 ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
599 SetLastError(0xfaceabee); /* maybe 2nd, then 3rd and dereferenced 4th param, */
600 ret = pGetStandardColorSpaceProfileW(NULL, 0, NULL, &size);
601 ok( !ret || broken(ret) /* win98 */, "GetStandardColorSpaceProfileW succeeded\n" );
602 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
603 GetLastError() == ERROR_FILE_NOT_FOUND ||
604 broken(GetLastError() == 0xfaceabee) /* win98 */,
605 "GetStandardColorSpaceProfileW() returns GLE=%u\n", GetLastError() );
607 size = sizeof(newprofile);
608 SetLastError(0xfaceabee); /* maybe 2nd param. */
609 ret = pGetStandardColorSpaceProfileW(NULL, 0, newprofile, &size);
610 if (!ret) ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
613 WideCharToMultiByte(CP_ACP, 0, newprofile, -1, newprofileA, sizeof(newprofileA), NULL, NULL);
614 ok( !lstrcmpiA( newprofileA, "" ) && GetLastError() == 0xfaceabee,
615 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
618 /* Functional checks */
620 size = sizeof(oldprofile);
621 ret = pGetStandardColorSpaceProfileW( NULL, LCS_sRGB, oldprofile, &size );
622 ok( ret, "GetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
624 SetLastError(0xdeadbeef);
625 ret = pSetStandardColorSpaceProfileW( NULL, LCS_sRGB, standardprofileW );
626 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
628 skip("Not enough rights for SetStandardColorSpaceProfileW\n");
631 ok( ret, "SetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
633 size = sizeof(newprofile);
634 ret = pGetStandardColorSpaceProfileW( NULL, LCS_sRGB, newprofile, &size );
635 ok( ret, "GetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
637 ret = pSetStandardColorSpaceProfileW( NULL, LCS_sRGB, oldprofile );
638 ok( ret, "SetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
641 static void test_EnumColorProfilesA( char *standardprofile )
644 DWORD total, size, number;
648 /* Parameter checks */
650 memset( &record, 0, sizeof(ENUMTYPEA) );
652 record.dwSize = sizeof(ENUMTYPEA);
653 record.dwVersion = ENUM_TYPE_VERSION;
654 record.dwFields |= ET_DATACOLORSPACE;
655 record.dwDataColorSpace = SPACE_RGB;
658 ret = pEnumColorProfilesA( NULL, &record, NULL, &total, &number );
659 ok( !ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
660 buffer = HeapAlloc( GetProcessHeap(), 0, total );
663 ret = pEnumColorProfilesA( machine, &record, buffer, &size, &number );
664 ok( !ret, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
666 ret = pEnumColorProfilesA( NULL, NULL, buffer, &size, &number );
667 ok( !ret, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
669 ret = pEnumColorProfilesA( NULL, &record, buffer, NULL, &number );
670 ok( !ret, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
672 ret = pEnumColorProfilesA( NULL, &record, buffer, &size, &number );
674 ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
676 todo_wine ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
680 ret = pEnumColorProfilesA( NULL, &record, buffer, &size, &number );
681 ok( !ret, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
683 /* Functional checks */
686 ret = pEnumColorProfilesA( NULL, &record, buffer, &size, &number );
688 ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
690 todo_wine ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
692 HeapFree( GetProcessHeap(), 0, buffer );
695 static void test_EnumColorProfilesW( WCHAR *standardprofileW )
698 DWORD total, size, number;
702 /* Parameter checks */
704 memset( &record, 0, sizeof(ENUMTYPEW) );
706 record.dwSize = sizeof(ENUMTYPEW);
707 record.dwVersion = ENUM_TYPE_VERSION;
708 record.dwFields |= ET_DATACOLORSPACE;
709 record.dwDataColorSpace = SPACE_RGB;
712 ret = pEnumColorProfilesW( NULL, &record, NULL, &total, &number );
713 ok( !ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
714 buffer = HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) );
717 ret = pEnumColorProfilesW( machineW, &record, buffer, &size, &number );
718 ok( !ret, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
720 ret = pEnumColorProfilesW( NULL, NULL, buffer, &size, &number );
721 ok( !ret, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
723 ret = pEnumColorProfilesW( NULL, &record, buffer, NULL, &number );
724 ok( !ret, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
726 ret = pEnumColorProfilesW( NULL, &record, buffer, &size, &number );
727 if (standardprofileW)
728 ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
730 todo_wine ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
733 ret = pEnumColorProfilesW( NULL, &record, buffer, &size, &number );
734 ok( !ret, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
736 /* Functional checks */
739 ret = pEnumColorProfilesW( NULL, &record, buffer, &size, &number );
740 if (standardprofileW)
741 ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
743 todo_wine ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
745 HeapFree( GetProcessHeap(), 0, buffer );
748 static void test_InstallColorProfileA( char *standardprofile, char *testprofile )
752 /* Parameter checks */
754 ret = pInstallColorProfileA( NULL, NULL );
755 ok( !ret, "InstallColorProfileA() succeeded (%d)\n", GetLastError() );
757 ret = pInstallColorProfileA( machine, NULL );
758 ok( !ret, "InstallColorProfileA() succeeded (%d)\n", GetLastError() );
760 ret = pInstallColorProfileA( NULL, machine );
761 ok( !ret, "InstallColorProfileA() succeeded (%d)\n", GetLastError() );
765 ret = pInstallColorProfileA( NULL, standardprofile );
766 ok( ret, "InstallColorProfileA() failed (%d)\n", GetLastError() );
769 /* Functional checks */
773 CHAR dest[MAX_PATH], base[MAX_PATH];
774 DWORD size = sizeof(dest);
778 SetLastError(0xdeadbeef);
779 ret = pInstallColorProfileA( NULL, testprofile );
780 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
782 skip("Not enough rights for InstallColorProfileA\n");
785 ok( ret, "InstallColorProfileA() failed (%d)\n", GetLastError() );
787 ret = pGetColorDirectoryA( NULL, dest, &size );
788 ok( ret, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
790 MSCMS_basenameA( testprofile, base );
792 lstrcatA( dest, slash );
793 lstrcatA( dest, base );
795 /* Check if the profile is really there */
796 handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
797 ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%d)\n", GetLastError() );
798 CloseHandle( handle );
800 ret = pUninstallColorProfileA( NULL, dest, TRUE );
801 ok( ret, "UninstallColorProfileA() failed (%d)\n", GetLastError() );
805 static void test_InstallColorProfileW( WCHAR *standardprofileW, WCHAR *testprofileW )
809 /* Parameter checks */
811 ret = pInstallColorProfileW( NULL, NULL );
812 ok( !ret, "InstallColorProfileW() succeeded (%d)\n", GetLastError() );
814 ret = pInstallColorProfileW( machineW, NULL );
815 ok( !ret, "InstallColorProfileW() succeeded (%d)\n", GetLastError() );
817 ret = pInstallColorProfileW( NULL, machineW );
818 ok( !ret, "InstallColorProfileW() failed (%d)\n", GetLastError() );
820 if (standardprofileW)
822 ret = pInstallColorProfileW( NULL, standardprofileW );
823 ok( ret, "InstallColorProfileW() failed (%d)\n", GetLastError() );
826 /* Functional checks */
830 WCHAR dest[MAX_PATH], base[MAX_PATH];
831 DWORD size = sizeof(dest);
832 WCHAR slash[] = { '\\', 0 };
835 SetLastError(0xdeadbeef);
836 ret = pInstallColorProfileW( NULL, testprofileW );
837 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
839 skip("Not enough rights for InstallColorProfileW\n");
842 ok( ret, "InstallColorProfileW() failed (%d)\n", GetLastError() );
844 ret = pGetColorDirectoryW( NULL, dest, &size );
845 ok( ret, "GetColorDirectoryW() failed (%d)\n", GetLastError() );
847 MSCMS_basenameW( testprofileW, base );
849 lstrcatW( dest, slash );
850 lstrcatW( dest, base );
852 /* Check if the profile is really there */
853 handle = CreateFileW( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
854 ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%d)\n", GetLastError() );
855 CloseHandle( handle );
857 ret = pUninstallColorProfileW( NULL, dest, TRUE );
858 ok( ret, "UninstallColorProfileW() failed (%d)\n", GetLastError() );
862 static void test_IsColorProfileTagPresent( char *standardprofile )
871 profile.dwType = PROFILE_FILENAME;
872 profile.pProfileData = standardprofile;
873 profile.cbDataSize = strlen(standardprofile);
875 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
876 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
878 /* Parameter checks */
882 ret = pIsColorProfileTagPresent( handle, tag, &present );
883 ok( !(ret && present), "IsColorProfileTagPresent() succeeded (%d)\n", GetLastError() );
885 tag = 0x63707274; /* 'cprt' */
887 ret = pIsColorProfileTagPresent( NULL, tag, &present );
888 ok( !ret, "IsColorProfileTagPresent() succeeded (%d)\n", GetLastError() );
890 ret = pIsColorProfileTagPresent( handle, tag, NULL );
891 ok( !ret, "IsColorProfileTagPresent() succeeded (%d)\n", GetLastError() );
893 /* Functional checks */
895 ret = pIsColorProfileTagPresent( handle, tag, &present );
896 ok( ret && present, "IsColorProfileTagPresent() failed (%d)\n", GetLastError() );
898 pCloseColorProfile( handle );
902 static void test_OpenColorProfileA( char *standardprofile )
908 profile.dwType = PROFILE_FILENAME;
909 profile.pProfileData = NULL;
910 profile.cbDataSize = 0;
912 /* Parameter checks */
914 handle = pOpenColorProfileA( NULL, 0, 0, 0 );
915 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
917 handle = pOpenColorProfileA( &profile, 0, 0, 0 );
918 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
920 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, 0 );
921 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
923 handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, 0 );
924 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
926 ok ( !pCloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" );
930 profile.pProfileData = standardprofile;
931 profile.cbDataSize = strlen(standardprofile);
933 handle = pOpenColorProfileA( &profile, 0, 0, 0 );
934 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
936 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, 0 );
937 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
939 handle = pOpenColorProfileA( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 );
940 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
942 /* Functional checks */
944 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
945 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
947 ret = pCloseColorProfile( handle );
948 ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
950 profile.dwType = PROFILE_FILENAME;
951 profile.pProfileData = (void *)"sRGB Color Space Profile.icm";
952 profile.cbDataSize = sizeof("sRGB Color Space Profile.icm");
954 handle = pOpenColorProfileA( &profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING );
955 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
957 ret = pCloseColorProfile( handle );
958 ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
962 static void test_OpenColorProfileW( WCHAR *standardprofileW )
968 profile.dwType = PROFILE_FILENAME;
969 profile.pProfileData = NULL;
970 profile.cbDataSize = 0;
972 /* Parameter checks */
974 handle = pOpenColorProfileW( NULL, 0, 0, 0 );
975 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
977 handle = pOpenColorProfileW( &profile, 0, 0, 0 );
978 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
980 handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, 0 );
981 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
983 handle = pOpenColorProfileW( &profile, PROFILE_READWRITE, 0, 0 );
984 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
986 ok ( !pCloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" );
988 if (standardprofileW)
990 profile.pProfileData = standardprofileW;
991 profile.cbDataSize = lstrlenW(standardprofileW) * sizeof(WCHAR);
993 handle = pOpenColorProfileW( &profile, 0, 0, 0 );
994 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
996 handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, 0 );
997 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
999 handle = pOpenColorProfileW( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 );
1000 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
1002 /* Functional checks */
1004 handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, OPEN_EXISTING );
1005 ok( handle != NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
1007 ret = pCloseColorProfile( handle );
1008 ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
1012 static void test_SetColorProfileElement( char *testprofile )
1021 TAGTYPE tag = 0x63707274; /* 'cprt' */
1022 static char data[] = "(c) The Wine Project";
1023 static char buffer[51];
1025 profile.dwType = PROFILE_FILENAME;
1026 profile.pProfileData = testprofile;
1027 profile.cbDataSize = strlen(testprofile);
1029 /* Parameter checks */
1031 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
1032 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1034 ret = pSetColorProfileElement( handle, tag, 0, &size, data );
1035 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1037 pCloseColorProfile( handle );
1039 handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING );
1040 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1042 ret = pSetColorProfileElement( NULL, 0, 0, NULL, NULL );
1043 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1045 ret = pSetColorProfileElement( handle, 0, 0, NULL, NULL );
1046 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1048 ret = pSetColorProfileElement( handle, tag, 0, NULL, NULL );
1049 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1051 ret = pSetColorProfileElement( handle, tag, 0, &size, NULL );
1052 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1054 /* Functional checks */
1056 size = sizeof(data);
1058 ret = pSetColorProfileElement( handle, tag, 0, &size, data );
1059 ok( ret, "SetColorProfileElement() failed (%d)\n", GetLastError() );
1061 size = sizeof(buffer);
1063 ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
1064 ok( ret && size > 0, "GetColorProfileElement() failed (%d)\n", GetLastError() );
1066 ok( !memcmp( data, buffer, sizeof(data) ),
1067 "Unexpected tag data, expected %s, got %s (%d)\n",
1068 data, buffer, GetLastError() );
1070 pCloseColorProfile( handle );
1074 static void test_SetColorProfileHeader( char *testprofile )
1081 PROFILEHEADER header;
1083 profile.dwType = PROFILE_FILENAME;
1084 profile.pProfileData = testprofile;
1085 profile.cbDataSize = strlen(testprofile);
1087 header.phSize = 0x00000c48;
1088 header.phCMMType = 0x4c696e6f;
1089 header.phVersion = 0x02100000;
1090 header.phClass = 0x6d6e7472;
1091 header.phDataColorSpace = 0x52474220;
1092 header.phConnectionSpace = 0x58595a20;
1093 header.phDateTime[0] = 0x07ce0002;
1094 header.phDateTime[1] = 0x00090006;
1095 header.phDateTime[2] = 0x00310000;
1096 header.phSignature = 0x61637370;
1097 header.phPlatform = 0x4d534654;
1098 header.phProfileFlags = 0x00000000;
1099 header.phManufacturer = 0x49454320;
1100 header.phModel = 0x73524742;
1101 header.phAttributes[0] = 0x00000000;
1102 header.phAttributes[1] = 0x00000000;
1103 header.phRenderingIntent = 0x00000000;
1104 header.phIlluminant.ciexyzX = 0x0000f6d6;
1105 header.phIlluminant.ciexyzY = 0x00010000;
1106 header.phIlluminant.ciexyzZ = 0x0000d32d;
1107 header.phCreator = 0x48502020;
1109 /* Parameter checks */
1111 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
1112 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1114 ret = pSetColorProfileHeader( handle, &header );
1115 ok( !ret, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1117 pCloseColorProfile( handle );
1119 handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING );
1120 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1122 ret = pSetColorProfileHeader( NULL, NULL );
1123 ok( !ret, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1125 ret = pSetColorProfileHeader( handle, NULL );
1126 ok( !ret, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1128 ret = pSetColorProfileHeader( NULL, &header );
1129 ok( !ret, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1131 /* Functional checks */
1133 ret = pSetColorProfileHeader( handle, &header );
1134 ok( ret, "SetColorProfileHeader() failed (%d)\n", GetLastError() );
1136 ret = pGetColorProfileHeader( handle, &header );
1137 ok( ret, "GetColorProfileHeader() failed (%d)\n", GetLastError() );
1139 ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" );
1141 pCloseColorProfile( handle );
1145 static void test_UninstallColorProfileA( char *testprofile )
1149 /* Parameter checks */
1151 ret = pUninstallColorProfileA( NULL, NULL, FALSE );
1152 ok( !ret, "UninstallColorProfileA() succeeded (%d)\n", GetLastError() );
1154 ret = pUninstallColorProfileA( machine, NULL, FALSE );
1155 ok( !ret, "UninstallColorProfileA() succeeded (%d)\n", GetLastError() );
1157 /* Functional checks */
1161 CHAR dest[MAX_PATH], base[MAX_PATH];
1162 DWORD size = sizeof(dest);
1163 CHAR slash[] = "\\";
1166 SetLastError(0xdeadbeef);
1167 ret = pInstallColorProfileA( NULL, testprofile );
1168 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
1170 skip("Not enough rights for InstallColorProfileA\n");
1173 ok( ret, "InstallColorProfileA() failed (%d)\n", GetLastError() );
1175 ret = pGetColorDirectoryA( NULL, dest, &size );
1176 ok( ret, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
1178 MSCMS_basenameA( testprofile, base );
1180 lstrcatA( dest, slash );
1181 lstrcatA( dest, base );
1183 ret = pUninstallColorProfileA( NULL, dest, TRUE );
1184 ok( ret, "UninstallColorProfileA() failed (%d)\n", GetLastError() );
1186 /* Check if the profile is really gone */
1187 handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1188 ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%d)\n", GetLastError() );
1189 CloseHandle( handle );
1193 static void test_UninstallColorProfileW( WCHAR *testprofileW )
1197 /* Parameter checks */
1199 ret = pUninstallColorProfileW( NULL, NULL, FALSE );
1200 ok( !ret, "UninstallColorProfileW() succeeded (%d)\n", GetLastError() );
1202 ret = pUninstallColorProfileW( machineW, NULL, FALSE );
1203 ok( !ret, "UninstallColorProfileW() succeeded (%d)\n", GetLastError() );
1205 /* Functional checks */
1209 WCHAR dest[MAX_PATH], base[MAX_PATH];
1210 char destA[MAX_PATH];
1211 DWORD size = sizeof(dest);
1212 WCHAR slash[] = { '\\', 0 };
1216 SetLastError(0xdeadbeef);
1217 ret = pInstallColorProfileW( NULL, testprofileW );
1218 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
1220 skip("Not enough rights for InstallColorProfileW\n");
1223 ok( ret, "InstallColorProfileW() failed (%d)\n", GetLastError() );
1225 ret = pGetColorDirectoryW( NULL, dest, &size );
1226 ok( ret, "GetColorDirectoryW() failed (%d)\n", GetLastError() );
1228 MSCMS_basenameW( testprofileW, base );
1230 lstrcatW( dest, slash );
1231 lstrcatW( dest, base );
1233 ret = pUninstallColorProfileW( NULL, dest, TRUE );
1234 ok( ret, "UninstallColorProfileW() failed (%d)\n", GetLastError() );
1236 bytes_copied = WideCharToMultiByte(CP_ACP, 0, dest, -1, destA, MAX_PATH, NULL, NULL);
1237 ok( bytes_copied > 0 , "WideCharToMultiByte() returns %d\n", bytes_copied);
1238 /* Check if the profile is really gone */
1239 handle = CreateFileA( destA, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1240 ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%d)\n", GetLastError() );
1241 CloseHandle( handle );
1245 static void test_AssociateColorProfileWithDeviceA( char *testprofile )
1248 char profile[MAX_PATH], basename[MAX_PATH];
1249 DWORD error, size = sizeof(profile);
1250 DISPLAY_DEVICE display;
1252 DISPLAY_DEVICE monitor;
1254 if (testprofile && pEnumDisplayDevicesA)
1256 display.cb = sizeof( DISPLAY_DEVICE );
1257 res = pEnumDisplayDevicesA( NULL, 0, &display, 0 );
1258 ok( res, "Can't get display info\n" );
1260 monitor.cb = sizeof( DISPLAY_DEVICE );
1261 res = pEnumDisplayDevicesA( display.DeviceName, 0, &monitor, 0 );
1264 SetLastError(0xdeadbeef);
1265 ret = pAssociateColorProfileWithDeviceA( "machine", testprofile, NULL );
1266 error = GetLastError();
1267 ok( !ret, "AssociateColorProfileWithDevice() succeeded\n" );
1268 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error );
1270 SetLastError(0xdeadbeef);
1271 ret = pAssociateColorProfileWithDeviceA( "machine", NULL, monitor.DeviceID );
1272 error = GetLastError();
1273 ok( !ret, "AssociateColorProfileWithDevice() succeeded\n" );
1274 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error );
1276 SetLastError(0xdeadbeef);
1277 ret = pAssociateColorProfileWithDeviceA( "machine", testprofile, monitor.DeviceID );
1278 error = GetLastError();
1279 ok( !ret, "AssociateColorProfileWithDevice() succeeded\n" );
1280 ok( error == ERROR_NOT_SUPPORTED, "expected ERROR_NOT_SUPPORTED, got %u\n", error );
1282 ret = pInstallColorProfileA( NULL, testprofile );
1283 ok( ret, "InstallColorProfileA() failed (%u)\n", GetLastError() );
1285 ret = pGetColorDirectoryA( NULL, profile, &size );
1286 ok( ret, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
1288 MSCMS_basenameA( testprofile, basename );
1289 lstrcatA( profile, "\\" );
1290 lstrcatA( profile, basename );
1292 ret = pAssociateColorProfileWithDeviceA( NULL, profile, monitor.DeviceID );
1293 ok( ret, "AssociateColorProfileWithDevice() failed (%u)\n", GetLastError() );
1295 SetLastError(0xdeadbeef);
1296 ret = pDisassociateColorProfileFromDeviceA( "machine", profile, NULL );
1297 error = GetLastError();
1298 ok( !ret, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1299 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error );
1301 SetLastError(0xdeadbeef);
1302 ret = pDisassociateColorProfileFromDeviceA( "machine", NULL, monitor.DeviceID );
1303 error = GetLastError();
1304 ok( !ret, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1305 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error );
1307 SetLastError(0xdeadbeef);
1308 ret = pDisassociateColorProfileFromDeviceA( "machine", profile, monitor.DeviceID );
1309 error = GetLastError();
1310 ok( !ret, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1311 ok( error == ERROR_NOT_SUPPORTED, "expected ERROR_NOT_SUPPORTED, got %u\n", error );
1313 ret = pDisassociateColorProfileFromDeviceA( NULL, profile, monitor.DeviceID );
1314 ok( ret, "DisassociateColorProfileFromDeviceA() failed (%u)\n", GetLastError() );
1316 ret = pUninstallColorProfileA( NULL, profile, TRUE );
1317 ok( ret, "UninstallColorProfileA() failed (%d)\n", GetLastError() );
1320 skip("Unable to obtain monitor name\n");
1328 char path[MAX_PATH], file[MAX_PATH], profilefile1[MAX_PATH], profilefile2[MAX_PATH];
1329 WCHAR profilefile1W[MAX_PATH], profilefile2W[MAX_PATH], fileW[MAX_PATH];
1330 char *standardprofile = NULL, *testprofile = NULL;
1331 WCHAR *standardprofileW = NULL, *testprofileW = NULL;
1334 hmscms = LoadLibraryA( "mscms.dll" );
1335 if (!hmscms) return;
1337 huser32 = LoadLibraryA( "user32.dll" );
1340 FreeLibrary( hmscms );
1344 if (!init_function_ptrs())
1346 FreeLibrary( huser32 );
1347 FreeLibrary( hmscms );
1351 /* See if we can find the standard color profile */
1352 ret = GetSystemDirectoryA( profilefile1, sizeof(profilefile1) );
1353 ok( ret > 0, "GetSystemDirectoryA() returns %d, LastError = %d\n", ret, GetLastError());
1354 ok( lstrlenA(profilefile1) > 0 && lstrlenA(profilefile1) < MAX_PATH,
1355 "Expected length between 0 and MAX_PATH, got %d\n", lstrlenA(profilefile1));
1356 MultiByteToWideChar(CP_ACP, 0, profilefile1, -1, profilefile1W, MAX_PATH);
1357 ok( lstrlenW(profilefile1W) > 0 && lstrlenW(profilefile1W) < MAX_PATH,
1358 "Expected length between 0 and MAX_PATH, got %d\n", lstrlenW(profilefile1W));
1359 lstrcpyA(profilefile2, profilefile1);
1360 lstrcpyW(profilefile2W, profilefile1W);
1362 lstrcatA( profilefile1, profile1 );
1363 lstrcatW( profilefile1W, profile1W );
1364 handle = CreateFileA( profilefile1, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1366 if (handle != INVALID_HANDLE_VALUE)
1368 standardprofile = profilefile1;
1369 standardprofileW = profilefile1W;
1370 CloseHandle( handle );
1373 lstrcatA( profilefile2, profile2 );
1374 lstrcatW( profilefile2W, profile2W );
1375 handle = CreateFileA( profilefile2, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1377 if (handle != INVALID_HANDLE_VALUE)
1379 standardprofile = profilefile2;
1380 standardprofileW = profilefile2W;
1381 CloseHandle( handle );
1384 /* If found, create a temporary copy for testing purposes */
1385 if (standardprofile && GetTempPath( sizeof(path), path ))
1387 if (GetTempFileName( path, "rgb", 0, file ))
1389 if (CopyFileA( standardprofile, file, FALSE ))
1391 testprofile = (LPSTR)&file;
1392 len = MultiByteToWideChar( CP_ACP, 0, testprofile, -1, NULL, 0 );
1393 MultiByteToWideChar( CP_ACP, 0, testprofile, -1, fileW, len );
1394 testprofileW = (LPWSTR)&fileW;
1399 test_GetColorDirectoryA();
1400 test_GetColorDirectoryW();
1402 test_GetColorProfileElement( standardprofile );
1403 test_GetColorProfileElementTag( standardprofile );
1405 test_GetColorProfileFromHandle( testprofile );
1406 test_GetColorProfileHeader( testprofile );
1408 test_GetCountColorProfileElements( standardprofile );
1410 test_GetStandardColorSpaceProfileA( standardprofile );
1411 test_GetStandardColorSpaceProfileW( standardprofileW );
1413 test_EnumColorProfilesA( standardprofile );
1414 test_EnumColorProfilesW( standardprofileW );
1416 test_InstallColorProfileA( standardprofile, testprofile );
1417 test_InstallColorProfileW( standardprofileW, testprofileW );
1419 test_IsColorProfileTagPresent( standardprofile );
1421 test_OpenColorProfileA( standardprofile );
1422 test_OpenColorProfileW( standardprofileW );
1424 test_SetColorProfileElement( testprofile );
1425 test_SetColorProfileHeader( testprofile );
1427 test_UninstallColorProfileA( testprofile );
1428 test_UninstallColorProfileW( testprofileW );
1430 test_AssociateColorProfileWithDeviceA( testprofile );
1432 if (testprofile) DeleteFileA( testprofile );
1433 FreeLibrary( huser32 );
1434 FreeLibrary( hmscms );