mscms/tests: Remove code that mixes up color space IDs and standard color space IDs.
[wine.git] / dlls / mscms / tests / profile.c
blob894d33c7a9ce2b7f3022d287f27a2d3b559a1551
1 /*
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
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winreg.h"
26 #include "winnls.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "icm.h"
31 #include "wine/test.h"
33 HMODULE hmscms;
34 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" );
97 return TRUE;
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 static LPSTR standardprofile;
135 static LPWSTR standardprofileW;
137 static LPSTR testprofile;
138 static LPWSTR testprofileW;
140 #define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
142 static void MSCMS_basenameA( LPCSTR path, LPSTR name )
144 INT i = strlen( path );
146 while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
147 strcpy( name, &path[i] );
150 static void MSCMS_basenameW( LPCWSTR path, LPWSTR name )
152 INT i = lstrlenW( path );
154 while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
155 lstrcpyW( name, &path[i] );
158 static void test_GetColorDirectoryA(void)
160 BOOL ret;
161 DWORD size;
162 char buffer[MAX_PATH];
164 /* Parameter checks */
166 ret = pGetColorDirectoryA( NULL, NULL, NULL );
167 ok( !ret, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
169 size = 0;
171 ret = pGetColorDirectoryA( NULL, NULL, &size );
172 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
174 size = 0;
176 ret = pGetColorDirectoryA( NULL, buffer, &size );
177 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
179 size = 1;
181 ret = pGetColorDirectoryA( NULL, buffer, &size );
182 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
184 /* Functional checks */
186 size = sizeof(buffer);
188 ret = pGetColorDirectoryA( NULL, buffer, &size );
189 ok( ret && size > 0, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
192 static void test_GetColorDirectoryW(void)
194 BOOL ret;
195 DWORD size;
196 WCHAR buffer[MAX_PATH];
198 /* Parameter checks */
200 /* This one crashes win2k
202 ret = pGetColorDirectoryW( NULL, NULL, NULL );
203 ok( !ret, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
207 size = 0;
209 ret = pGetColorDirectoryW( NULL, NULL, &size );
210 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
212 size = 0;
214 ret = pGetColorDirectoryW( NULL, buffer, &size );
215 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
217 size = 1;
219 ret = pGetColorDirectoryW( NULL, buffer, &size );
220 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
222 /* Functional checks */
224 size = sizeof(buffer);
226 ret = pGetColorDirectoryW( NULL, buffer, &size );
227 ok( ret && size > 0, "GetColorDirectoryW() failed (%d)\n", GetLastError() );
230 static void test_GetColorProfileElement(void)
232 if (standardprofile)
234 PROFILE profile;
235 HPROFILE handle;
236 BOOL ret, ref;
237 DWORD size;
238 TAGTYPE tag = 0x63707274; /* 'cprt' */
239 static char buffer[51];
240 static const char expect[] =
241 { 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x70,
242 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20,
243 0x31, 0x39, 0x39, 0x38, 0x20, 0x48, 0x65, 0x77, 0x6c, 0x65, 0x74,
244 0x74, 0x2d, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x72, 0x64, 0x20, 0x43,
245 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x00 };
247 profile.dwType = PROFILE_FILENAME;
248 profile.pProfileData = standardprofile;
249 profile.cbDataSize = strlen(standardprofile);
251 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
252 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
254 /* Parameter checks */
256 ret = pGetColorProfileElement( handle, tag, 0, NULL, NULL, &ref );
257 ok( !ret, "GetColorProfileElement() succeeded (%d)\n", GetLastError() );
259 ret = pGetColorProfileElement( handle, tag, 0, &size, NULL, NULL );
260 ok( !ret, "GetColorProfileElement() succeeded (%d)\n", GetLastError() );
262 size = 0;
264 ret = pGetColorProfileElement( handle, tag, 0, &size, NULL, &ref );
265 ok( !ret && size > 0, "GetColorProfileElement() succeeded (%d)\n", GetLastError() );
267 size = sizeof(buffer);
269 /* Functional checks */
271 ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
272 ok( ret && size > 0, "GetColorProfileElement() failed (%d)\n", GetLastError() );
274 ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected tag data\n" );
276 pCloseColorProfile( handle );
280 static void test_GetColorProfileElementTag(void)
282 if (standardprofile)
284 PROFILE profile;
285 HPROFILE handle;
286 BOOL ret;
287 DWORD index = 1;
288 TAGTYPE tag, expect = 0x63707274; /* 'cprt' */
290 profile.dwType = PROFILE_FILENAME;
291 profile.pProfileData = standardprofile;
292 profile.cbDataSize = strlen(standardprofile);
294 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
295 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
297 /* Parameter checks */
299 ret = pGetColorProfileElementTag( NULL, index, &tag );
300 ok( !ret, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
302 ret = pGetColorProfileElementTag( handle, 0, &tag );
303 ok( !ret, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
305 ret = pGetColorProfileElementTag( handle, index, NULL );
306 ok( !ret, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
308 ret = pGetColorProfileElementTag( handle, 18, NULL );
309 ok( !ret, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
311 /* Functional checks */
313 ret = pGetColorProfileElementTag( handle, index, &tag );
314 ok( ret && tag == expect, "GetColorProfileElementTag() failed (%d)\n",
315 GetLastError() );
317 pCloseColorProfile( handle );
321 static void test_GetColorProfileFromHandle(void)
323 if (testprofile)
325 PROFILE profile;
326 HPROFILE handle;
327 DWORD size;
328 BOOL ret;
329 static const unsigned char expect[] =
330 { 0x00, 0x00, 0x0c, 0x48, 0x4c, 0x69, 0x6e, 0x6f, 0x02, 0x10, 0x00,
331 0x00, 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59,
332 0x5a, 0x20, 0x07, 0xce, 0x00, 0x02, 0x00, 0x09, 0x00, 0x06, 0x00,
333 0x31, 0x00, 0x00, 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54,
334 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47,
335 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
336 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00,
337 0x00, 0xd3, 0x2d, 0x48, 0x50, 0x20, 0x20 };
339 unsigned char *buffer;
341 profile.dwType = PROFILE_FILENAME;
342 profile.pProfileData = testprofile;
343 profile.cbDataSize = strlen(testprofile);
345 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
346 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
348 /* Parameter checks */
350 size = 0;
352 ret = pGetColorProfileFromHandle( handle, NULL, &size );
353 ok( !ret && size > 0, "GetColorProfileFromHandle() failed (%d)\n", GetLastError() );
355 buffer = HeapAlloc( GetProcessHeap(), 0, size );
357 if (buffer)
359 ret = pGetColorProfileFromHandle( NULL, buffer, &size );
360 ok( !ret, "GetColorProfileFromHandle() succeeded (%d)\n", GetLastError() );
362 ret = pGetColorProfileFromHandle( handle, buffer, NULL );
363 ok( !ret, "GetColorProfileFromHandle() succeeded (%d)\n", GetLastError() );
365 /* Functional checks */
367 ret = pGetColorProfileFromHandle( handle, buffer, &size );
368 ok( ret && size > 0, "GetColorProfileFromHandle() failed (%d)\n", GetLastError() );
370 ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected header data\n" );
372 HeapFree( GetProcessHeap(), 0, buffer );
375 pCloseColorProfile( handle );
379 static void test_GetColorProfileHeader(void)
381 if (testprofile)
383 PROFILE profile;
384 HPROFILE handle;
385 BOOL ret;
386 PROFILEHEADER header;
388 profile.dwType = PROFILE_FILENAME;
389 profile.pProfileData = testprofile;
390 profile.cbDataSize = strlen(testprofile);
392 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
393 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
395 /* Parameter checks */
397 ret = pGetColorProfileHeader( NULL, NULL );
398 ok( !ret, "GetColorProfileHeader() succeeded (%d)\n", GetLastError() );
400 ret = pGetColorProfileHeader( NULL, &header );
401 ok( !ret, "GetColorProfileHeader() succeeded (%d)\n", GetLastError() );
403 if (0) /* Crashes on Vista */
405 ret = pGetColorProfileHeader( handle, NULL );
406 ok( !ret, "GetColorProfileHeader() succeeded (%d)\n", GetLastError() );
409 /* Functional checks */
411 ret = pGetColorProfileHeader( handle, &header );
412 ok( ret, "GetColorProfileHeader() failed (%d)\n", GetLastError() );
414 ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" );
416 pCloseColorProfile( handle );
420 static void test_GetCountColorProfileElements(void)
422 if (standardprofile)
424 PROFILE profile;
425 HPROFILE handle;
426 BOOL ret;
427 DWORD count, expect = 17;
429 profile.dwType = PROFILE_FILENAME;
430 profile.pProfileData = standardprofile;
431 profile.cbDataSize = strlen(standardprofile);
433 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
434 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
436 /* Parameter checks */
438 ret = pGetCountColorProfileElements( NULL, &count );
439 ok( !ret, "GetCountColorProfileElements() succeeded (%d)\n",
440 GetLastError() );
442 ret = pGetCountColorProfileElements( handle, NULL );
443 ok( !ret, "GetCountColorProfileElements() succeeded (%d)\n",
444 GetLastError() );
446 /* Functional checks */
448 ret = pGetCountColorProfileElements( handle, &count );
449 ok( ret && count == expect,
450 "GetCountColorProfileElements() failed (%d)\n", GetLastError() );
452 pCloseColorProfile( handle );
456 static void test_GetStandardColorSpaceProfileA()
458 BOOL ret;
459 DWORD size;
460 CHAR oldprofile[MAX_PATH];
461 CHAR newprofile[MAX_PATH];
462 const CHAR emptyA[] = "";
463 DWORD zero = 0;
464 DWORD sizeP = sizeof(newprofile);
466 /* Parameter checks */
468 /* Single invalid parameter checks: */
470 SetLastError(0xfaceabee); /* 1st param, */
471 ret = pGetStandardColorSpaceProfileA(machine, LCS_sRGB, newprofile, &sizeP);
472 ok( !ret && GetLastError() == ERROR_NOT_SUPPORTED, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
474 SetLastError(0xfaceabee); /* 2nd param, */
475 ret = pGetStandardColorSpaceProfileA(NULL, (DWORD)-1, newprofile, &sizeP);
476 ok( !ret && GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
478 SetLastError(0xfaceabee); /* 4th param, */
479 ret = pGetStandardColorSpaceProfileA(NULL, LCS_sRGB, newprofile, NULL);
480 ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
482 SetLastError(0xfaceabee); /* 3rd param, */
483 ret = pGetStandardColorSpaceProfileA(NULL, LCS_sRGB, NULL, &sizeP);
484 ok( !ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
486 SetLastError(0xfaceabee); /* dereferenced 4th param, */
487 ret = pGetStandardColorSpaceProfileA(NULL, LCS_sRGB, newprofile, &zero);
488 ok( !ret && (GetLastError() == ERROR_MORE_DATA || GetLastError() == ERROR_INSUFFICIENT_BUFFER),
489 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
491 /* Several invalid parameter checks: */
493 SetLastError(0xfaceabee); /* 1st, maybe 2nd and then dereferenced 4th param, */
494 ret = pGetStandardColorSpaceProfileA(machine, 0, newprofile, &zero);
495 ok( !ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_NOT_SUPPORTED),
496 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
498 SetLastError(0xfaceabee); /* maybe 2nd and then 4th param, */
499 ret = pGetStandardColorSpaceProfileA(NULL, 0, newprofile, NULL);
500 ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
502 SetLastError(0xfaceabee); /* maybe 2nd, then 3rd and dereferenced 4th param, */
503 ret = pGetStandardColorSpaceProfileA(NULL, 0, NULL, &zero);
504 ok( !ret && (GetLastError() == ERROR_INSUFFICIENT_BUFFER || GetLastError() == ERROR_FILE_NOT_FOUND),
505 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
507 SetLastError(0xfaceabee); /* maybe 2nd param. */
508 ret = pGetStandardColorSpaceProfileA(NULL, 0, newprofile, &sizeP);
509 if (!ret) ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
510 else ok( !lstrcmpiA( newprofile, emptyA ) && GetLastError() == 0xfaceabee,
511 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
513 /* Functional checks */
515 size = sizeof(oldprofile);
516 ret = pGetStandardColorSpaceProfileA( NULL, LCS_sRGB, oldprofile, &size );
517 ok( ret, "GetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
519 SetLastError(0xdeadbeef);
520 ret = pSetStandardColorSpaceProfileA( NULL, LCS_sRGB, standardprofile );
521 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
523 skip("Not enough rights for SetStandardColorSpaceProfileA\n");
524 return;
526 ok( ret, "SetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
528 size = sizeof(newprofile);
529 ret = pGetStandardColorSpaceProfileA( NULL, LCS_sRGB, newprofile, &size );
530 ok( ret, "GetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
532 ret = pSetStandardColorSpaceProfileA( NULL, LCS_sRGB, oldprofile );
533 ok( ret, "SetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
536 static void test_GetStandardColorSpaceProfileW()
538 BOOL ret;
539 DWORD size;
540 WCHAR oldprofile[MAX_PATH];
541 WCHAR newprofile[MAX_PATH];
542 const WCHAR emptyW[] = {0};
543 DWORD zero = 0;
544 DWORD sizeP = sizeof(newprofile);
546 /* Parameter checks */
548 /* Single invalid parameter checks: */
550 SetLastError(0xfaceabee); /* 1st param, */
551 ret = pGetStandardColorSpaceProfileW(machineW, LCS_sRGB, newprofile, &sizeP);
552 ok( !ret && GetLastError() == ERROR_NOT_SUPPORTED, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
554 SetLastError(0xfaceabee); /* 2nd param, */
555 ret = pGetStandardColorSpaceProfileW(NULL, (DWORD)-1, newprofile, &sizeP);
556 ok( !ret && GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
558 SetLastError(0xfaceabee); /* 2nd param, */
559 ret = pGetStandardColorSpaceProfileW(NULL, 0, newprofile, &sizeP);
560 ok( !ret && GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
562 SetLastError(0xfaceabee); /* 3rd param, */
563 ret = pGetStandardColorSpaceProfileW(NULL, LCS_sRGB, NULL, &sizeP);
564 ok( !ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
566 SetLastError(0xfaceabee); /* 4th param, */
567 ret = pGetStandardColorSpaceProfileW(NULL, LCS_sRGB, newprofile, NULL);
568 ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
570 SetLastError(0xfaceabee); /* dereferenced 4th param. */
571 ret = pGetStandardColorSpaceProfileW(NULL, LCS_sRGB, newprofile, &zero);
572 ok( !ret && (GetLastError() == ERROR_MORE_DATA || GetLastError() == ERROR_INSUFFICIENT_BUFFER),
573 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
575 /* Several invalid parameter checks: */
577 SetLastError(0xfaceabee); /* 1st, maybe 2nd and then dereferenced 4th param, */
578 ret = pGetStandardColorSpaceProfileW(machineW, 0, newprofile, &zero);
579 ok( !ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_NOT_SUPPORTED),
580 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
582 SetLastError(0xfaceabee); /* maybe 2nd and then 4th param, */
583 ret = pGetStandardColorSpaceProfileW(NULL, 0, newprofile, NULL);
584 ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
586 SetLastError(0xfaceabee); /* maybe 2nd, then 3rd and dereferenced 4th param, */
587 ret = pGetStandardColorSpaceProfileW(NULL, 0, NULL, &zero);
588 ok( !ret && (GetLastError() == ERROR_INSUFFICIENT_BUFFER || GetLastError() == ERROR_FILE_NOT_FOUND),
589 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
591 SetLastError(0xfaceabee); /* maybe 2nd param. */
592 ret = pGetStandardColorSpaceProfileW(NULL, 0, newprofile, &sizeP);
593 if (!ret) ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
594 else ok( !lstrcmpiW( newprofile, emptyW ) && GetLastError() == 0xfaceabee,
595 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
597 /* Functional checks */
599 size = sizeof(oldprofile);
600 ret = pGetStandardColorSpaceProfileW( NULL, LCS_sRGB, oldprofile, &size );
601 ok( ret, "GetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
603 SetLastError(0xdeadbeef);
604 ret = pSetStandardColorSpaceProfileW( NULL, LCS_sRGB, standardprofileW );
605 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
607 skip("Not enough rights for SetStandardColorSpaceProfileW\n");
608 return;
610 ok( ret, "SetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
612 size = sizeof(newprofile);
613 ret = pGetStandardColorSpaceProfileW( NULL, LCS_sRGB, newprofile, &size );
614 ok( ret, "GetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
616 ret = pSetStandardColorSpaceProfileW( NULL, LCS_sRGB, oldprofile );
617 ok( ret, "SetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
620 static void test_EnumColorProfilesA(void)
622 BOOL ret;
623 DWORD total, size, number;
624 ENUMTYPEA record;
625 BYTE *buffer;
627 /* Parameter checks */
629 memset( &record, 0, sizeof(ENUMTYPEA) );
631 record.dwSize = sizeof(ENUMTYPEA);
632 record.dwVersion = ENUM_TYPE_VERSION;
633 record.dwFields |= ET_DATACOLORSPACE;
634 record.dwDataColorSpace = SPACE_RGB;
636 total = 0;
637 ret = pEnumColorProfilesA( NULL, &record, NULL, &total, &number );
638 ok( !ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
639 buffer = HeapAlloc( GetProcessHeap(), 0, total );
641 size = total;
642 ret = pEnumColorProfilesA( machine, &record, buffer, &size, &number );
643 ok( !ret, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
645 ret = pEnumColorProfilesA( NULL, NULL, buffer, &size, &number );
646 ok( !ret, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
648 ret = pEnumColorProfilesA( NULL, &record, buffer, NULL, &number );
649 ok( !ret, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
651 ret = pEnumColorProfilesA( NULL, &record, buffer, &size, &number );
652 if (standardprofile)
653 ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
654 else
655 todo_wine ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
657 size = 0;
659 ret = pEnumColorProfilesA( NULL, &record, buffer, &size, &number );
660 ok( !ret, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
662 /* Functional checks */
664 size = total;
665 ret = pEnumColorProfilesA( NULL, &record, buffer, &size, &number );
666 if (standardprofile)
667 ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
668 else
669 todo_wine ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
671 HeapFree( GetProcessHeap(), 0, buffer );
674 static void test_EnumColorProfilesW(void)
676 BOOL ret;
677 DWORD total, size, number;
678 ENUMTYPEW record;
679 BYTE *buffer;
681 /* Parameter checks */
683 memset( &record, 0, sizeof(ENUMTYPEW) );
685 record.dwSize = sizeof(ENUMTYPEW);
686 record.dwVersion = ENUM_TYPE_VERSION;
687 record.dwFields |= ET_DATACOLORSPACE;
688 record.dwDataColorSpace = SPACE_RGB;
690 total = 0;
691 ret = pEnumColorProfilesW( NULL, &record, NULL, &total, &number );
692 ok( !ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
693 buffer = HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) );
695 size = total;
696 ret = pEnumColorProfilesW( machineW, &record, buffer, &size, &number );
697 ok( !ret, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
699 ret = pEnumColorProfilesW( NULL, NULL, buffer, &size, &number );
700 ok( !ret, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
702 ret = pEnumColorProfilesW( NULL, &record, buffer, NULL, &number );
703 ok( !ret, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
705 ret = pEnumColorProfilesW( NULL, &record, buffer, &size, &number );
706 if (standardprofileW)
707 ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
708 else
709 todo_wine ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
711 size = 0;
712 ret = pEnumColorProfilesW( NULL, &record, buffer, &size, &number );
713 ok( !ret, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
715 /* Functional checks */
717 size = total;
718 ret = pEnumColorProfilesW( NULL, &record, buffer, &size, &number );
719 if (standardprofileW)
720 ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
721 else
722 todo_wine ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
724 HeapFree( GetProcessHeap(), 0, buffer );
727 static void test_InstallColorProfileA(void)
729 BOOL ret;
731 /* Parameter checks */
733 ret = pInstallColorProfileA( NULL, NULL );
734 ok( !ret, "InstallColorProfileA() succeeded (%d)\n", GetLastError() );
736 ret = pInstallColorProfileA( machine, NULL );
737 ok( !ret, "InstallColorProfileA() succeeded (%d)\n", GetLastError() );
739 ret = pInstallColorProfileA( NULL, machine );
740 ok( !ret, "InstallColorProfileA() succeeded (%d)\n", GetLastError() );
742 if (standardprofile)
744 ret = pInstallColorProfileA( NULL, standardprofile );
745 ok( ret, "InstallColorProfileA() failed (%d)\n", GetLastError() );
748 /* Functional checks */
750 if (testprofile)
752 CHAR dest[MAX_PATH], base[MAX_PATH];
753 DWORD size = sizeof(dest);
754 CHAR slash[] = "\\";
755 HANDLE handle;
757 SetLastError(0xdeadbeef);
758 ret = pInstallColorProfileA( NULL, testprofile );
759 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
761 skip("Not enough rights for InstallColorProfileA\n");
762 return;
764 ok( ret, "InstallColorProfileA() failed (%d)\n", GetLastError() );
766 ret = pGetColorDirectoryA( NULL, dest, &size );
767 ok( ret, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
769 MSCMS_basenameA( testprofile, base );
771 lstrcatA( dest, slash );
772 lstrcatA( dest, base );
774 /* Check if the profile is really there */
775 handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
776 ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%d)\n", GetLastError() );
777 CloseHandle( handle );
779 ret = pUninstallColorProfileA( NULL, dest, TRUE );
780 ok( ret, "UninstallColorProfileA() failed (%d)\n", GetLastError() );
784 static void test_InstallColorProfileW(void)
786 BOOL ret;
788 /* Parameter checks */
790 ret = pInstallColorProfileW( NULL, NULL );
791 ok( !ret, "InstallColorProfileW() succeeded (%d)\n", GetLastError() );
793 ret = pInstallColorProfileW( machineW, NULL );
794 ok( !ret, "InstallColorProfileW() succeeded (%d)\n", GetLastError() );
796 ret = pInstallColorProfileW( NULL, machineW );
797 ok( !ret, "InstallColorProfileW() failed (%d)\n", GetLastError() );
799 if (standardprofileW)
801 ret = pInstallColorProfileW( NULL, standardprofileW );
802 ok( ret, "InstallColorProfileW() failed (%d)\n", GetLastError() );
805 /* Functional checks */
807 if (testprofileW)
809 WCHAR dest[MAX_PATH], base[MAX_PATH];
810 DWORD size = sizeof(dest);
811 WCHAR slash[] = { '\\', 0 };
812 HANDLE handle;
814 SetLastError(0xdeadbeef);
815 ret = pInstallColorProfileW( NULL, testprofileW );
816 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
818 skip("Not enough rights for InstallColorProfileW\n");
819 return;
821 ok( ret, "InstallColorProfileW() failed (%d)\n", GetLastError() );
823 ret = pGetColorDirectoryW( NULL, dest, &size );
824 ok( ret, "GetColorDirectoryW() failed (%d)\n", GetLastError() );
826 MSCMS_basenameW( testprofileW, base );
828 lstrcatW( dest, slash );
829 lstrcatW( dest, base );
831 /* Check if the profile is really there */
832 handle = CreateFileW( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
833 ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%d)\n", GetLastError() );
834 CloseHandle( handle );
836 ret = pUninstallColorProfileW( NULL, dest, TRUE );
837 ok( ret, "UninstallColorProfileW() failed (%d)\n", GetLastError() );
841 static void test_IsColorProfileTagPresent(void)
843 if (standardprofile)
845 PROFILE profile;
846 HPROFILE handle;
847 BOOL ret, present;
848 TAGTYPE tag;
850 profile.dwType = PROFILE_FILENAME;
851 profile.pProfileData = standardprofile;
852 profile.cbDataSize = strlen(standardprofile);
854 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
855 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
857 /* Parameter checks */
859 tag = 0;
861 ret = pIsColorProfileTagPresent( handle, tag, &present );
862 ok( !(ret && present), "IsColorProfileTagPresent() succeeded (%d)\n", GetLastError() );
864 tag = 0x63707274; /* 'cprt' */
866 ret = pIsColorProfileTagPresent( NULL, tag, &present );
867 ok( !ret, "IsColorProfileTagPresent() succeeded (%d)\n", GetLastError() );
869 ret = pIsColorProfileTagPresent( handle, tag, NULL );
870 ok( !ret, "IsColorProfileTagPresent() succeeded (%d)\n", GetLastError() );
872 /* Functional checks */
874 ret = pIsColorProfileTagPresent( handle, tag, &present );
875 ok( ret && present, "IsColorProfileTagPresent() failed (%d)\n", GetLastError() );
877 pCloseColorProfile( handle );
881 static void test_OpenColorProfileA(void)
883 PROFILE profile;
884 HPROFILE handle;
885 BOOL ret;
887 profile.dwType = PROFILE_FILENAME;
888 profile.pProfileData = NULL;
889 profile.cbDataSize = 0;
891 /* Parameter checks */
893 handle = pOpenColorProfileA( NULL, 0, 0, 0 );
894 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
896 handle = pOpenColorProfileA( &profile, 0, 0, 0 );
897 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
899 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, 0 );
900 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
902 handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, 0 );
903 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
905 ok ( !pCloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" );
907 if (standardprofile)
909 profile.pProfileData = standardprofile;
910 profile.cbDataSize = strlen(standardprofile);
912 handle = pOpenColorProfileA( &profile, 0, 0, 0 );
913 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
915 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, 0 );
916 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
918 handle = pOpenColorProfileA( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 );
919 ok( handle == NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
921 /* Functional checks */
923 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
924 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
926 ret = pCloseColorProfile( handle );
927 ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
931 static void test_OpenColorProfileW(void)
933 PROFILE profile;
934 HPROFILE handle;
935 BOOL ret;
937 profile.dwType = PROFILE_FILENAME;
938 profile.pProfileData = NULL;
939 profile.cbDataSize = 0;
941 /* Parameter checks */
943 handle = pOpenColorProfileW( NULL, 0, 0, 0 );
944 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
946 handle = pOpenColorProfileW( &profile, 0, 0, 0 );
947 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
949 handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, 0 );
950 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
952 handle = pOpenColorProfileW( &profile, PROFILE_READWRITE, 0, 0 );
953 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
955 ok ( !pCloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" );
957 if (standardprofileW)
959 profile.pProfileData = standardprofileW;
960 profile.cbDataSize = lstrlenW(standardprofileW) * sizeof(WCHAR);
962 handle = pOpenColorProfileW( &profile, 0, 0, 0 );
963 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
965 handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, 0 );
966 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
968 handle = pOpenColorProfileW( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 );
969 ok( handle == NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
971 /* Functional checks */
973 handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, OPEN_EXISTING );
974 ok( handle != NULL, "OpenColorProfileW() failed (%d)\n", GetLastError() );
976 ret = pCloseColorProfile( handle );
977 ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
981 static void test_SetColorProfileElement(void)
983 if (testprofile)
985 PROFILE profile;
986 HPROFILE handle;
987 DWORD size;
988 BOOL ret, ref;
990 TAGTYPE tag = 0x63707274; /* 'cprt' */
991 static char data[] = "(c) The Wine Project";
992 static char buffer[51];
994 profile.dwType = PROFILE_FILENAME;
995 profile.pProfileData = testprofile;
996 profile.cbDataSize = strlen(testprofile);
998 /* Parameter checks */
1000 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
1001 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1003 ret = pSetColorProfileElement( handle, tag, 0, &size, data );
1004 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1006 pCloseColorProfile( handle );
1008 handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING );
1009 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1011 ret = pSetColorProfileElement( NULL, 0, 0, NULL, NULL );
1012 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1014 ret = pSetColorProfileElement( handle, 0, 0, NULL, NULL );
1015 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1017 ret = pSetColorProfileElement( handle, tag, 0, NULL, NULL );
1018 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1020 ret = pSetColorProfileElement( handle, tag, 0, &size, NULL );
1021 ok( !ret, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1023 /* Functional checks */
1025 size = sizeof(data);
1027 ret = pSetColorProfileElement( handle, tag, 0, &size, data );
1028 ok( ret, "SetColorProfileElement() failed (%d)\n", GetLastError() );
1030 size = sizeof(buffer);
1032 ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
1033 ok( ret && size > 0, "GetColorProfileElement() failed (%d)\n", GetLastError() );
1035 ok( !memcmp( data, buffer, sizeof(data) ),
1036 "Unexpected tag data, expected %s, got %s (%d)\n",
1037 data, buffer, GetLastError() );
1039 pCloseColorProfile( handle );
1043 static void test_SetColorProfileHeader(void)
1045 if (testprofile)
1047 PROFILE profile;
1048 HPROFILE handle;
1049 BOOL ret;
1050 PROFILEHEADER header;
1052 profile.dwType = PROFILE_FILENAME;
1053 profile.pProfileData = testprofile;
1054 profile.cbDataSize = strlen(testprofile);
1056 header.phSize = 0x00000c48;
1057 header.phCMMType = 0x4c696e6f;
1058 header.phVersion = 0x02100000;
1059 header.phClass = 0x6d6e7472;
1060 header.phDataColorSpace = 0x52474220;
1061 header.phConnectionSpace = 0x58595a20;
1062 header.phDateTime[0] = 0x07ce0002;
1063 header.phDateTime[1] = 0x00090006;
1064 header.phDateTime[2] = 0x00310000;
1065 header.phSignature = 0x61637370;
1066 header.phPlatform = 0x4d534654;
1067 header.phProfileFlags = 0x00000000;
1068 header.phManufacturer = 0x49454320;
1069 header.phModel = 0x73524742;
1070 header.phAttributes[0] = 0x00000000;
1071 header.phAttributes[1] = 0x00000000;
1072 header.phRenderingIntent = 0x00000000;
1073 header.phIlluminant.ciexyzX = 0x0000f6d6;
1074 header.phIlluminant.ciexyzY = 0x00010000;
1075 header.phIlluminant.ciexyzZ = 0x0000d32d;
1076 header.phCreator = 0x48502020;
1078 /* Parameter checks */
1080 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
1081 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1083 ret = pSetColorProfileHeader( handle, &header );
1084 ok( !ret, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1086 pCloseColorProfile( handle );
1088 handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING );
1089 ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1091 ret = pSetColorProfileHeader( NULL, NULL );
1092 ok( !ret, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1094 ret = pSetColorProfileHeader( handle, NULL );
1095 ok( !ret, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1097 ret = pSetColorProfileHeader( NULL, &header );
1098 ok( !ret, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1100 /* Functional checks */
1102 ret = pSetColorProfileHeader( handle, &header );
1103 ok( ret, "SetColorProfileHeader() failed (%d)\n", GetLastError() );
1105 ret = pGetColorProfileHeader( handle, &header );
1106 ok( ret, "GetColorProfileHeader() failed (%d)\n", GetLastError() );
1108 ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" );
1110 pCloseColorProfile( handle );
1114 static void test_UninstallColorProfileA(void)
1116 BOOL ret;
1118 /* Parameter checks */
1120 ret = pUninstallColorProfileA( NULL, NULL, FALSE );
1121 ok( !ret, "UninstallColorProfileA() succeeded (%d)\n", GetLastError() );
1123 ret = pUninstallColorProfileA( machine, NULL, FALSE );
1124 ok( !ret, "UninstallColorProfileA() succeeded (%d)\n", GetLastError() );
1126 /* Functional checks */
1128 if (testprofile)
1130 CHAR dest[MAX_PATH], base[MAX_PATH];
1131 DWORD size = sizeof(dest);
1132 CHAR slash[] = "\\";
1133 HANDLE handle;
1135 SetLastError(0xdeadbeef);
1136 ret = pInstallColorProfileA( NULL, testprofile );
1137 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
1139 skip("Not enough rights for InstallColorProfileA\n");
1140 return;
1142 ok( ret, "InstallColorProfileA() failed (%d)\n", GetLastError() );
1144 ret = pGetColorDirectoryA( NULL, dest, &size );
1145 ok( ret, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
1147 MSCMS_basenameA( testprofile, base );
1149 lstrcatA( dest, slash );
1150 lstrcatA( dest, base );
1152 ret = pUninstallColorProfileA( NULL, dest, TRUE );
1153 ok( ret, "UninstallColorProfileA() failed (%d)\n", GetLastError() );
1155 /* Check if the profile is really gone */
1156 handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1157 ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%d)\n", GetLastError() );
1158 CloseHandle( handle );
1162 static void test_UninstallColorProfileW(void)
1164 BOOL ret;
1166 /* Parameter checks */
1168 ret = pUninstallColorProfileW( NULL, NULL, FALSE );
1169 ok( !ret, "UninstallColorProfileW() succeeded (%d)\n", GetLastError() );
1171 ret = pUninstallColorProfileW( machineW, NULL, FALSE );
1172 ok( !ret, "UninstallColorProfileW() succeeded (%d)\n", GetLastError() );
1174 /* Functional checks */
1176 if (testprofileW)
1178 WCHAR dest[MAX_PATH], base[MAX_PATH];
1179 char destA[MAX_PATH];
1180 DWORD size = sizeof(dest);
1181 WCHAR slash[] = { '\\', 0 };
1182 HANDLE handle;
1183 int bytes_copied;
1185 SetLastError(0xdeadbeef);
1186 ret = pInstallColorProfileW( NULL, testprofileW );
1187 if (!ret && (GetLastError() == ERROR_ACCESS_DENIED))
1189 skip("Not enough rights for InstallColorProfileW\n");
1190 return;
1192 ok( ret, "InstallColorProfileW() failed (%d)\n", GetLastError() );
1194 ret = pGetColorDirectoryW( NULL, dest, &size );
1195 ok( ret, "GetColorDirectoryW() failed (%d)\n", GetLastError() );
1197 MSCMS_basenameW( testprofileW, base );
1199 lstrcatW( dest, slash );
1200 lstrcatW( dest, base );
1202 ret = pUninstallColorProfileW( NULL, dest, TRUE );
1203 ok( ret, "UninstallColorProfileW() failed (%d)\n", GetLastError() );
1205 bytes_copied = WideCharToMultiByte(CP_ACP, 0, dest, -1, destA, MAX_PATH, NULL, NULL);
1206 ok( bytes_copied > 0 , "WideCharToMultiByte() returns %d\n", bytes_copied);
1207 /* Check if the profile is really gone */
1208 handle = CreateFileA( destA, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1209 ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%d)\n", GetLastError() );
1210 CloseHandle( handle );
1214 static void test_AssociateColorProfileWithDeviceA(void)
1216 BOOL ret;
1217 char profile[MAX_PATH], basename[MAX_PATH];
1218 DWORD error, size = sizeof(profile);
1219 DISPLAY_DEVICE display;
1220 BOOL res;
1221 DISPLAY_DEVICE monitor;
1223 if (testprofile && pEnumDisplayDevicesA)
1225 display.cb = sizeof( DISPLAY_DEVICE );
1226 res = pEnumDisplayDevicesA( NULL, 0, &display, 0 );
1227 ok( res, "Can't get display info\n" );
1229 monitor.cb = sizeof( DISPLAY_DEVICE );
1230 res = pEnumDisplayDevicesA( display.DeviceName, 0, &monitor, 0 );
1231 if (res)
1233 SetLastError(0xdeadbeef);
1234 ret = pAssociateColorProfileWithDeviceA( "machine", testprofile, NULL );
1235 error = GetLastError();
1236 ok( !ret, "AssociateColorProfileWithDevice() succeeded\n" );
1237 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error );
1239 SetLastError(0xdeadbeef);
1240 ret = pAssociateColorProfileWithDeviceA( "machine", NULL, monitor.DeviceID );
1241 error = GetLastError();
1242 ok( !ret, "AssociateColorProfileWithDevice() succeeded\n" );
1243 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error );
1245 SetLastError(0xdeadbeef);
1246 ret = pAssociateColorProfileWithDeviceA( "machine", testprofile, monitor.DeviceID );
1247 error = GetLastError();
1248 ok( !ret, "AssociateColorProfileWithDevice() succeeded\n" );
1249 ok( error == ERROR_NOT_SUPPORTED, "expected ERROR_NOT_SUPPORTED, got %u\n", error );
1251 ret = pInstallColorProfileA( NULL, testprofile );
1252 ok( ret, "InstallColorProfileA() failed (%u)\n", GetLastError() );
1254 ret = pGetColorDirectoryA( NULL, profile, &size );
1255 ok( ret, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
1257 MSCMS_basenameA( testprofile, basename );
1258 lstrcatA( profile, "\\" );
1259 lstrcatA( profile, basename );
1261 ret = pAssociateColorProfileWithDeviceA( NULL, profile, monitor.DeviceID );
1262 ok( ret, "AssociateColorProfileWithDevice() failed (%u)\n", GetLastError() );
1264 SetLastError(0xdeadbeef);
1265 ret = pDisassociateColorProfileFromDeviceA( "machine", profile, NULL );
1266 error = GetLastError();
1267 ok( !ret, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1268 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error );
1270 SetLastError(0xdeadbeef);
1271 ret = pDisassociateColorProfileFromDeviceA( "machine", NULL, monitor.DeviceID );
1272 error = GetLastError();
1273 ok( !ret, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1274 ok( error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error );
1276 SetLastError(0xdeadbeef);
1277 ret = pDisassociateColorProfileFromDeviceA( "machine", profile, monitor.DeviceID );
1278 error = GetLastError();
1279 ok( !ret, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1280 ok( error == ERROR_NOT_SUPPORTED, "expected ERROR_NOT_SUPPORTED, got %u\n", error );
1282 ret = pDisassociateColorProfileFromDeviceA( NULL, profile, monitor.DeviceID );
1283 ok( ret, "DisassociateColorProfileFromDeviceA() failed (%u)\n", GetLastError() );
1285 ret = pUninstallColorProfileA( NULL, profile, TRUE );
1286 ok( ret, "UninstallColorProfileA() failed (%d)\n", GetLastError() );
1288 else
1289 skip("Unable to obtain monitor name\n");
1293 START_TEST(profile)
1295 UINT len;
1296 HANDLE handle;
1297 char path[MAX_PATH], file[MAX_PATH];
1298 char profilefile1[MAX_PATH], profilefile2[MAX_PATH];
1299 WCHAR profilefile1W[MAX_PATH], profilefile2W[MAX_PATH];
1300 WCHAR fileW[MAX_PATH];
1301 UINT ret;
1303 hmscms = LoadLibraryA( "mscms.dll" );
1304 if (!hmscms) return;
1306 huser32 = LoadLibraryA( "user32.dll" );
1307 if (!huser32)
1309 FreeLibrary( hmscms );
1310 return;
1313 if (!init_function_ptrs())
1315 FreeLibrary( huser32 );
1316 FreeLibrary( hmscms );
1317 return;
1320 /* See if we can find the standard color profile */
1321 ret = GetSystemDirectoryA( profilefile1, sizeof(profilefile1) );
1322 ok( ret > 0, "GetSystemDirectoryA() returns %d, LastError = %d\n", ret, GetLastError());
1323 ok( lstrlenA(profilefile1) > 0 && lstrlenA(profilefile1) < MAX_PATH,
1324 "GetSystemDirectoryA() returns %d, LastError = %d\n", ret, GetLastError());
1325 MultiByteToWideChar(CP_ACP, 0, profilefile1, -1, profilefile1W, MAX_PATH);
1326 ok( lstrlenW(profilefile1W) > 0 && lstrlenW(profilefile1W) < MAX_PATH,
1327 "GetSystemDirectoryA() returns %d, LastError = %d\n", ret, GetLastError());
1328 lstrcpyA(profilefile2, profilefile1);
1329 lstrcpyW(profilefile2W, profilefile1W);
1331 lstrcatA( profilefile1, profile1 );
1332 lstrcatW( profilefile1W, profile1W );
1333 handle = CreateFileA( profilefile1, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1335 if (handle != INVALID_HANDLE_VALUE)
1337 standardprofile = profilefile1;
1338 standardprofileW = profilefile1W;
1339 CloseHandle( handle );
1342 lstrcatA( profilefile2, profile2 );
1343 lstrcatW( profilefile2W, profile2W );
1344 handle = CreateFileA( profilefile2, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1346 if (handle != INVALID_HANDLE_VALUE)
1348 standardprofile = profilefile2;
1349 standardprofileW = profilefile2W;
1350 CloseHandle( handle );
1353 /* If found, create a temporary copy for testing purposes */
1354 if (standardprofile && GetTempPath( sizeof(path), path ))
1356 if (GetTempFileName( path, "rgb", 0, file ))
1358 if (CopyFileA( standardprofile, file, FALSE ))
1360 testprofile = (LPSTR)&file;
1362 len = MultiByteToWideChar( CP_ACP, 0, testprofile, -1, NULL, 0 );
1363 MultiByteToWideChar( CP_ACP, 0, testprofile, -1, fileW, len );
1365 testprofileW = (LPWSTR)&fileW;
1370 test_GetColorDirectoryA();
1371 test_GetColorDirectoryW();
1373 test_GetColorProfileElement();
1374 test_GetColorProfileElementTag();
1376 test_GetColorProfileFromHandle();
1377 test_GetColorProfileHeader();
1379 test_GetCountColorProfileElements();
1381 test_GetStandardColorSpaceProfileA();
1382 test_GetStandardColorSpaceProfileW();
1384 test_EnumColorProfilesA();
1385 test_EnumColorProfilesW();
1387 test_InstallColorProfileA();
1388 test_InstallColorProfileW();
1390 test_IsColorProfileTagPresent();
1392 test_OpenColorProfileA();
1393 test_OpenColorProfileW();
1395 test_SetColorProfileElement();
1396 test_SetColorProfileHeader();
1398 test_UninstallColorProfileA();
1399 test_UninstallColorProfileW();
1401 test_AssociateColorProfileWithDeviceA();
1403 /* Clean up */
1404 if (testprofile)
1405 DeleteFileA( testprofile );
1407 FreeLibrary( huser32 );
1408 FreeLibrary( hmscms );