mscms: Branching fixes for some test routines
[wine/gsoc_dplay.git] / dlls / mscms / tests / profile.c
blob5714cb637211982c756db5d0457244b650318dd6
1 /*
2 * Tests for color profile functions
4 * Copyright 2004, 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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;
35 static BOOL (WINAPI *pCloseColorProfile)(HPROFILE);
36 static BOOL (WINAPI *pGetColorDirectoryA)(PCHAR,PCHAR,PDWORD);
37 static BOOL (WINAPI *pGetColorDirectoryW)(PWCHAR,PWCHAR,PDWORD);
38 static BOOL (WINAPI *pGetColorProfileElement)(HPROFILE,TAGTYPE,DWORD,PDWORD,PVOID,PBOOL);
39 static BOOL (WINAPI *pGetColorProfileElementTag)(HPROFILE,DWORD,PTAGTYPE);
40 static BOOL (WINAPI *pGetColorProfileFromHandle)(HPROFILE,PBYTE,PDWORD);
41 static BOOL (WINAPI *pGetColorProfileHeader)(HPROFILE,PPROFILEHEADER);
42 static BOOL (WINAPI *pGetCountColorProfileElements)(HPROFILE,PDWORD);
43 static BOOL (WINAPI *pGetStandardColorSpaceProfileA)(PCSTR,DWORD,PSTR,PDWORD);
44 static BOOL (WINAPI *pGetStandardColorSpaceProfileW)(PCWSTR,DWORD,PWSTR,PDWORD);
45 static BOOL (WINAPI *pInstallColorProfileA)(PCSTR,PCSTR);
46 static BOOL (WINAPI *pInstallColorProfileW)(PCWSTR,PCWSTR);
47 static BOOL (WINAPI *pIsColorProfileTagPresent)(HPROFILE,TAGTYPE,PBOOL);
48 static HPROFILE (WINAPI *pOpenColorProfileA)(PPROFILE,DWORD,DWORD,DWORD);
49 static HPROFILE (WINAPI *pOpenColorProfileW)(PPROFILE,DWORD,DWORD,DWORD);
50 static BOOL (WINAPI *pSetColorProfileElement)(HPROFILE,TAGTYPE,DWORD,PDWORD,PVOID);
51 static BOOL (WINAPI *pSetColorProfileHeader)(HPROFILE,PPROFILEHEADER);
52 static BOOL (WINAPI *pSetStandardColorSpaceProfileA)(PCSTR,DWORD,PSTR);
53 static BOOL (WINAPI *pSetStandardColorSpaceProfileW)(PCWSTR,DWORD,PWSTR);
54 static BOOL (WINAPI *pUninstallColorProfileA)(PCSTR,PCSTR,BOOL);
55 static BOOL (WINAPI *pUninstallColorProfileW)(PCWSTR,PCWSTR,BOOL);
57 #define GETFUNCPTR(func) p##func = (void *)GetProcAddress( hmscms, #func ); \
58 if (!p##func) return FALSE;
60 static BOOL init_function_ptrs( void )
62 GETFUNCPTR( CloseColorProfile )
63 GETFUNCPTR( GetColorDirectoryA )
64 GETFUNCPTR( GetColorDirectoryW )
65 GETFUNCPTR( GetColorProfileElement )
66 GETFUNCPTR( GetColorProfileElementTag )
67 GETFUNCPTR( GetColorProfileFromHandle )
68 GETFUNCPTR( GetColorProfileHeader )
69 GETFUNCPTR( GetCountColorProfileElements )
70 GETFUNCPTR( GetStandardColorSpaceProfileA )
71 GETFUNCPTR( GetStandardColorSpaceProfileW )
72 GETFUNCPTR( InstallColorProfileA )
73 GETFUNCPTR( InstallColorProfileW )
74 GETFUNCPTR( IsColorProfileTagPresent )
75 GETFUNCPTR( OpenColorProfileA )
76 GETFUNCPTR( OpenColorProfileW )
77 GETFUNCPTR( SetColorProfileElement )
78 GETFUNCPTR( SetColorProfileHeader )
79 GETFUNCPTR( SetStandardColorSpaceProfileA )
80 GETFUNCPTR( SetStandardColorSpaceProfileW )
81 GETFUNCPTR( UninstallColorProfileA )
82 GETFUNCPTR( UninstallColorProfileW )
84 return TRUE;
87 static const char machine[] = "dummy";
88 static const WCHAR machineW[] = { 'd','u','m','m','y',0 };
90 /* To do any real functionality testing with this suite you need a copy of
91 * the freely distributable standard RGB color space profile. It comes
92 * standard with Windows, but on Wine you probably need to install it yourself
93 * in one of the locations mentioned below. Here's a link to the profile in
94 * a self extracting zip file:
96 * http://download.microsoft.com/download/whistler/hwdev1/1.0/wxp/en-us/ColorProfile.exe
99 /* Two common places to find the standard color space profile, relative
100 * to the system directory.
102 static const char profile1[] =
103 "\\color\\srgb color space profile.icm";
104 static const char profile2[] =
105 "\\spool\\drivers\\color\\srgb color space profile.icm";
107 static const WCHAR profile1W[] =
108 { '\\','c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
109 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
110 static const WCHAR profile2W[] =
111 { '\\','s','p','o','o','l','\\','d','r','i','v','e','r','s','\\',
112 'c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
113 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
115 static const unsigned char rgbheader[] =
116 { 0x48, 0x0c, 0x00, 0x00, 0x6f, 0x6e, 0x69, 0x4c, 0x00, 0x00, 0x10, 0x02,
117 0x72, 0x74, 0x6e, 0x6d, 0x20, 0x42, 0x47, 0x52, 0x20, 0x5a, 0x59, 0x58,
118 0x02, 0x00, 0xce, 0x07, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, 0x31, 0x00,
119 0x70, 0x73, 0x63, 0x61, 0x54, 0x46, 0x53, 0x4d, 0x00, 0x00, 0x00, 0x00,
120 0x20, 0x43, 0x45, 0x49, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00,
121 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xf6, 0x00, 0x00,
122 0x00, 0x00, 0x01, 0x00, 0x2d, 0xd3, 0x00, 0x00, 0x20, 0x20, 0x50, 0x48 };
124 static LPSTR standardprofile;
125 static LPWSTR standardprofileW;
127 static LPSTR testprofile;
128 static LPWSTR testprofileW;
130 #define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
132 static void MSCMS_basenameA( LPCSTR path, LPSTR name )
134 INT i = strlen( path );
136 while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
137 strcpy( name, &path[i] );
140 static void MSCMS_basenameW( LPCWSTR path, LPWSTR name )
142 INT i = lstrlenW( path );
144 while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
145 lstrcpyW( name, &path[i] );
148 static void test_GetColorDirectoryA(void)
150 BOOL ret;
151 DWORD size;
152 char buffer[MAX_PATH];
154 /* Parameter checks */
156 ret = pGetColorDirectoryA( NULL, NULL, NULL );
157 ok( !ret, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
159 size = 0;
161 ret = pGetColorDirectoryA( NULL, NULL, &size );
162 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
164 size = 0;
166 ret = pGetColorDirectoryA( NULL, buffer, &size );
167 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
169 size = 1;
171 ret = pGetColorDirectoryA( NULL, buffer, &size );
172 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
174 /* Functional checks */
176 size = sizeof(buffer);
178 ret = pGetColorDirectoryA( NULL, buffer, &size );
179 ok( ret && size > 0, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
182 static void test_GetColorDirectoryW(void)
184 BOOL ret;
185 DWORD size;
186 WCHAR buffer[MAX_PATH];
188 /* Parameter checks */
190 /* This one crashes win2k
192 ret = pGetColorDirectoryW( NULL, NULL, NULL );
193 ok( !ret, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
197 size = 0;
199 ret = pGetColorDirectoryW( NULL, NULL, &size );
200 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
202 size = 0;
204 ret = pGetColorDirectoryW( NULL, buffer, &size );
205 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
207 size = 1;
209 ret = pGetColorDirectoryW( NULL, buffer, &size );
210 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
212 /* Functional checks */
214 size = sizeof(buffer);
216 ret = pGetColorDirectoryW( NULL, buffer, &size );
217 ok( ret && size > 0, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
220 static void test_GetColorProfileElement(void)
222 if (standardprofile)
224 PROFILE profile;
225 HPROFILE handle;
226 BOOL ret, ref;
227 DWORD size;
228 TAGTYPE tag = 0x63707274; /* 'cprt' */
229 static char buffer[51];
230 static const char expect[] =
231 { 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x70,
232 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20,
233 0x31, 0x39, 0x39, 0x38, 0x20, 0x48, 0x65, 0x77, 0x6c, 0x65, 0x74,
234 0x74, 0x2d, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x72, 0x64, 0x20, 0x43,
235 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x00 };
237 profile.dwType = PROFILE_FILENAME;
238 profile.pProfileData = standardprofile;
239 profile.cbDataSize = strlen(standardprofile);
241 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
242 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
244 /* Parameter checks */
246 ret = pGetColorProfileElement( handle, tag, 0, NULL, NULL, &ref );
247 ok( !ret, "GetColorProfileElement() succeeded (%ld)\n", GetLastError() );
249 ret = pGetColorProfileElement( handle, tag, 0, &size, NULL, NULL );
250 ok( !ret, "GetColorProfileElement() succeeded (%ld)\n", GetLastError() );
252 size = 0;
254 ret = pGetColorProfileElement( handle, tag, 0, &size, NULL, &ref );
255 ok( !ret && size > 0, "GetColorProfileElement() succeeded (%ld)\n", GetLastError() );
257 size = sizeof(buffer);
259 /* Functional checks */
261 ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
262 ok( ret && size > 0, "GetColorProfileElement() failed (%ld)\n", GetLastError() );
264 ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected tag data\n" );
266 pCloseColorProfile( handle );
270 static void test_GetColorProfileElementTag(void)
272 if (standardprofile)
274 PROFILE profile;
275 HPROFILE handle;
276 BOOL ret;
277 DWORD index = 1;
278 TAGTYPE tag, expect = 0x63707274; /* 'cprt' */
280 profile.dwType = PROFILE_FILENAME;
281 profile.pProfileData = standardprofile;
282 profile.cbDataSize = strlen(standardprofile);
284 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
285 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
287 /* Parameter checks */
289 ret = pGetColorProfileElementTag( NULL, index, &tag );
290 ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() );
292 ret = pGetColorProfileElementTag( handle, 0, &tag );
293 ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() );
295 ret = pGetColorProfileElementTag( handle, index, NULL );
296 ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() );
298 ret = pGetColorProfileElementTag( handle, 18, NULL );
299 ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() );
301 /* Functional checks */
303 ret = pGetColorProfileElementTag( handle, index, &tag );
304 ok( ret && tag == expect, "GetColorProfileElementTag() failed (%ld)\n",
305 GetLastError() );
307 pCloseColorProfile( handle );
311 static void test_GetColorProfileFromHandle(void)
313 if (testprofile)
315 PROFILE profile;
316 HPROFILE handle;
317 DWORD size;
318 BOOL ret;
319 static const unsigned char expect[] =
320 { 0x00, 0x00, 0x0c, 0x48, 0x4c, 0x69, 0x6e, 0x6f, 0x02, 0x10, 0x00,
321 0x00, 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59,
322 0x5a, 0x20, 0x07, 0xce, 0x00, 0x02, 0x00, 0x09, 0x00, 0x06, 0x00,
323 0x31, 0x00, 0x00, 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54,
324 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47,
325 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
326 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00,
327 0x00, 0xd3, 0x2d, 0x48, 0x50, 0x20, 0x20 };
329 unsigned char *buffer;
331 profile.dwType = PROFILE_FILENAME;
332 profile.pProfileData = testprofile;
333 profile.cbDataSize = strlen(testprofile);
335 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
336 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
338 /* Parameter checks */
340 size = 0;
342 ret = pGetColorProfileFromHandle( handle, NULL, &size );
343 ok( !ret && size > 0, "GetColorProfileFromHandle() failed (%ld)\n", GetLastError() );
345 buffer = HeapAlloc( GetProcessHeap(), 0, size );
347 if (buffer)
349 ret = pGetColorProfileFromHandle( NULL, buffer, &size );
350 ok( !ret, "GetColorProfileFromHandle() succeeded (%ld)\n", GetLastError() );
352 ret = pGetColorProfileFromHandle( handle, buffer, NULL );
353 ok( !ret, "GetColorProfileFromHandle() succeeded (%ld)\n", GetLastError() );
355 /* Functional checks */
357 ret = pGetColorProfileFromHandle( handle, buffer, &size );
358 ok( ret && size > 0, "GetColorProfileFromHandle() failed (%ld)\n", GetLastError() );
360 ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected header data\n" );
362 HeapFree( GetProcessHeap(), 0, buffer );
365 pCloseColorProfile( handle );
369 static void test_GetColorProfileHeader(void)
371 if (testprofile)
373 PROFILE profile;
374 HPROFILE handle;
375 BOOL ret;
376 PROFILEHEADER header;
378 profile.dwType = PROFILE_FILENAME;
379 profile.pProfileData = testprofile;
380 profile.cbDataSize = strlen(testprofile);
382 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
383 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
385 /* Parameter checks */
387 ret = pGetColorProfileHeader( NULL, NULL );
388 ok( !ret, "GetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
390 ret = pGetColorProfileHeader( NULL, &header );
391 ok( !ret, "GetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
393 ret = pGetColorProfileHeader( handle, NULL );
394 ok( !ret, "GetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
396 /* Functional checks */
398 ret = pGetColorProfileHeader( handle, &header );
399 ok( ret, "GetColorProfileHeader() failed (%ld)\n", GetLastError() );
401 ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" );
403 pCloseColorProfile( handle );
407 static void test_GetCountColorProfileElements(void)
409 if (standardprofile)
411 PROFILE profile;
412 HPROFILE handle;
413 BOOL ret;
414 DWORD count, expect = 17;
416 profile.dwType = PROFILE_FILENAME;
417 profile.pProfileData = standardprofile;
418 profile.cbDataSize = strlen(standardprofile);
420 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
421 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
423 /* Parameter checks */
425 ret = pGetCountColorProfileElements( NULL, &count );
426 ok( !ret, "GetCountColorProfileElements() succeeded (%ld)\n",
427 GetLastError() );
429 ret = pGetCountColorProfileElements( handle, NULL );
430 ok( !ret, "GetCountColorProfileElements() succeeded (%ld)\n",
431 GetLastError() );
433 /* Functional checks */
435 ret = pGetCountColorProfileElements( handle, &count );
436 ok( ret && count == expect,
437 "GetCountColorProfileElements() failed (%ld)\n", GetLastError() );
439 pCloseColorProfile( handle );
443 typedef struct colorspace_description_struct {
444 DWORD dwID;
445 char *szName;
446 BOOL registered;
447 char filename[MAX_PATH];
448 } colorspace_descr;
450 #define describe_colorspace(id) {id, #id, FALSE, ""}
452 colorspace_descr known_colorspaces[] = {
453 describe_colorspace(SPACE_XYZ),
454 describe_colorspace(SPACE_Lab),
455 describe_colorspace(SPACE_Luv),
456 describe_colorspace(SPACE_YCbCr),
457 describe_colorspace(SPACE_Yxy),
458 describe_colorspace(SPACE_RGB),
459 describe_colorspace(SPACE_GRAY),
460 describe_colorspace(SPACE_HSV),
461 describe_colorspace(SPACE_HLS),
462 describe_colorspace(SPACE_CMYK),
463 describe_colorspace(SPACE_CMY),
464 describe_colorspace(SPACE_2_CHANNEL),
465 describe_colorspace(SPACE_3_CHANNEL),
466 describe_colorspace(SPACE_4_CHANNEL),
467 describe_colorspace(SPACE_5_CHANNEL),
468 describe_colorspace(SPACE_6_CHANNEL),
469 describe_colorspace(SPACE_7_CHANNEL),
470 describe_colorspace(SPACE_8_CHANNEL)
473 static void enum_registered_color_profiles(void)
475 BOOL ret;
476 DWORD size, count, i, present;
477 CHAR profile[MAX_PATH];
479 size = sizeof(profile);
480 count = sizeof(known_colorspaces)/sizeof(known_colorspaces[0]);
482 present = 0;
483 trace("\n");
484 trace("Querying registered standard colorspace profiles via GetStandardColorSpaceProfileA():\n");
485 for (i=0; i<count; i++)
487 ret = pGetStandardColorSpaceProfileA(NULL, known_colorspaces[i].dwID, profile, &size);
488 if (ret)
490 lstrcpynA(known_colorspaces[i].filename, profile, MAX_PATH);
491 known_colorspaces[i].registered = TRUE;
492 present++;
493 trace(" found %s, pointing to '%s' (%d chars)\n", known_colorspaces[i].szName, profile, strlen(profile));
496 trace("Total profiles found: %ld.\n", present);
497 trace("\n");
500 static colorspace_descr *query_colorspace(DWORD dwID)
502 DWORD count, i;
504 count = sizeof(known_colorspaces)/sizeof(known_colorspaces[0]);
506 for (i=0; i<count; i++)
507 if (known_colorspaces[i].dwID == dwID)
509 if (!known_colorspaces[i].registered) break;
510 return &known_colorspaces[i];
512 return NULL;
515 static HKEY reg_open_mscms_key(void)
517 char win9x[] = "SOFTWARE\\Microsoft\\Windows";
518 char winNT[] = "SOFTWARE\\Microsoft\\Windows NT";
519 char ICM[] = "CurrentVersion\\ICM\\RegisteredProfiles";
520 HKEY win9x_key, winNT_key, ICM_key;
522 RegOpenKeyExA( HKEY_LOCAL_MACHINE, win9x, 0, KEY_READ, &win9x_key );
523 RegOpenKeyExA( HKEY_LOCAL_MACHINE, winNT, 0, KEY_READ, &winNT_key );
525 if (RegOpenKeyExA( winNT_key, ICM, 0, KEY_READ, &ICM_key ))
526 RegOpenKeyExA( win9x_key, ICM, 0, KEY_READ, &ICM_key );
527 RegCloseKey( win9x_key );
528 RegCloseKey( winNT_key );
530 return ICM_key;
533 static void check_registry(void)
535 HKEY hkIcmKey;
536 LONG res;
537 DWORD i, dwValCount;
538 char szName[16383];
539 char szData[MAX_PATH+1];
540 DWORD dwNameLen, dwDataLen, dwType;
542 hkIcmKey = reg_open_mscms_key();
543 if (!hkIcmKey)
545 trace("Key 'HKLM\\SOFTWARE\\Microsoft\\Windows*\\CurrentVersion\\ICM\\RegisteredProfiles' not found\n" );
546 return;
549 res = RegQueryInfoKeyA(hkIcmKey, NULL, NULL, NULL, NULL, NULL, NULL, &dwValCount, NULL, NULL, NULL, NULL);
550 if (!res)
552 trace("RegQueryInfoKeyA() failed\n");
553 return;
556 trace("Count of profile entries found directly in the registry: %ld\n", dwValCount);
558 for (i = 0; i<dwValCount; i++)
560 dwNameLen = sizeof(szName);
561 dwDataLen = sizeof(szData);
562 res = RegEnumValueA( hkIcmKey, i, szName, &dwNameLen, NULL, &dwType, (LPBYTE)szData, &dwDataLen );
563 if (res != ERROR_SUCCESS)
565 trace("RegEnumValueA() failed (%ld), cannot enumerate profiles\n", res);
566 break;
568 ok( dwType == REG_SZ, "RegEnumValueA() returned unexpected value type (%ld)\n", dwType );
569 if (dwType != REG_SZ) break;
570 trace(" found '%s' value containing '%s' (%d chars)\n", szName, szData, strlen(szData));
573 RegCloseKey( hkIcmKey );
576 #define fail_GSCSP(AW, pMachName, dwProfID, pProfName, pdwSz, dwSz, bCanSucceed, GLE_MATCHES)\
577 do { \
578 size = dwSz; \
579 SetLastError(0xfaceabad); \
580 ret = pGetStandardColorSpaceProfile##AW(pMachName, dwProfID, pProfName, pdwSz); \
581 GLE = GetLastError(); \
582 ok( (!ret && GLE_MATCHES) || \
583 (bCanSucceed && ret && !lstrcmpi##AW( pProfName, empty##AW ) && GLE == 0xfaceabad), \
584 "GetStandardColorSpaceProfile%s() returns %d (GLE=%ld)\n", #AW, ret, GLE ); \
585 } while (0)
587 static void test_GetStandardColorSpaceProfileA(void)
589 BOOL ret;
590 DWORD size, sizeP, GLE;
591 CHAR oldprofile[MAX_PATH];
592 CHAR newprofile[MAX_PATH];
593 CHAR emptyA[] = "";
595 sizeP = sizeof(newprofile);
597 /* Parameter checks */
599 #define A
600 /* Single invalid parameter checks */
601 fail_GSCSP(A, machine, SPACE_RGB, newprofile, &size, sizeP, FALSE, (GLE == ERROR_NOT_SUPPORTED));
602 todo_wine
603 fail_GSCSP(A, NULL, (DWORD)-1, newprofile, &size, sizeP, FALSE, (GLE == ERROR_FILE_NOT_FOUND));
604 todo_wine
605 fail_GSCSP(A, NULL, SPACE_RGB, newprofile, NULL, sizeP, FALSE, (GLE == ERROR_INVALID_PARAMETER));
607 if (query_colorspace(SPACE_RGB))
609 todo_wine
610 fail_GSCSP(A, NULL, SPACE_RGB, NULL, &size, sizeP, FALSE, (GLE == ERROR_INSUFFICIENT_BUFFER));
611 todo_wine
612 fail_GSCSP(A, NULL, SPACE_RGB, newprofile, &size, 0, FALSE, (GLE == ERROR_MORE_DATA || GLE == ERROR_INSUFFICIENT_BUFFER));
613 } else {
614 todo_wine
615 fail_GSCSP(A, NULL, SPACE_RGB, NULL, &size, sizeP, FALSE, (GLE == ERROR_FILE_NOT_FOUND));
616 todo_wine
617 fail_GSCSP(A, NULL, SPACE_RGB, newprofile, &size, 0, FALSE, (GLE == ERROR_FILE_NOT_FOUND));
620 /* Several invalid parameter checks */
621 fail_GSCSP(A, machine, 0, newprofile, &size, 0, FALSE, (GLE == ERROR_INVALID_PARAMETER || GLE == ERROR_NOT_SUPPORTED));
622 todo_wine
623 fail_GSCSP(A, NULL, 0, newprofile, NULL, 0, FALSE, (GLE == ERROR_INVALID_PARAMETER));
624 todo_wine
625 fail_GSCSP(A, NULL, 0, NULL, &size, 0, FALSE, (GLE == ERROR_INSUFFICIENT_BUFFER || GLE == ERROR_FILE_NOT_FOUND));
626 todo_wine
627 fail_GSCSP(A, NULL, 0, newprofile, &size, sizeP, TRUE, (GLE == ERROR_FILE_NOT_FOUND));
628 #undef A
630 /* Functional checks */
632 if (standardprofile)
634 size = sizeof(oldprofile);
636 ret = pGetStandardColorSpaceProfileA( NULL, SPACE_RGB, oldprofile, &size );
637 ok( ret, "GetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() );
639 ret = pSetStandardColorSpaceProfileA( NULL, SPACE_RGB, standardprofile );
640 ok( ret, "SetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() );
642 size = sizeof(newprofile);
644 ret = pGetStandardColorSpaceProfileA( NULL, SPACE_RGB, newprofile, &size );
645 ok( ret, "GetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() );
647 ok( !lstrcmpiA( (LPSTR)&newprofile, standardprofile ), "Unexpected profile\n" );
649 ret = pSetStandardColorSpaceProfileA( NULL, SPACE_RGB, oldprofile );
650 ok( ret, "SetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() );
654 static void test_GetStandardColorSpaceProfileW(void)
656 BOOL ret;
657 DWORD size, sizeP, GLE;
658 WCHAR oldprofile[MAX_PATH];
659 WCHAR newprofile[MAX_PATH];
660 WCHAR emptyW[] = {0};
662 sizeP = sizeof(newprofile);
664 /* Parameter checks */
666 #define W
667 /* Single invalid parameter checks */
668 fail_GSCSP(W, machineW, SPACE_RGB, newprofile, &size, sizeP, FALSE, (GLE == ERROR_NOT_SUPPORTED));
669 todo_wine
670 fail_GSCSP(W, NULL, (DWORD)-1, newprofile, &size, sizeP, FALSE, (GLE == ERROR_FILE_NOT_FOUND));
671 todo_wine
672 fail_GSCSP(W, NULL, SPACE_RGB, NULL, &size, sizeP, FALSE, (GLE == ERROR_INSUFFICIENT_BUFFER));
673 todo_wine
674 fail_GSCSP(W, NULL, SPACE_RGB, newprofile, NULL, sizeP, FALSE, (GLE == ERROR_INVALID_PARAMETER));
675 todo_wine
676 fail_GSCSP(W, NULL, SPACE_RGB, newprofile, &size, 0, FALSE, (GLE == ERROR_MORE_DATA || GLE == ERROR_INSUFFICIENT_BUFFER));
678 /* Several invalid parameter checks */
679 fail_GSCSP(W, machineW, 0, newprofile, &size, 0, FALSE, (GLE == ERROR_INVALID_PARAMETER || GLE == ERROR_NOT_SUPPORTED));
680 todo_wine
681 fail_GSCSP(W, NULL, 0, newprofile, NULL, 0, FALSE, (GLE == ERROR_INVALID_PARAMETER));
682 todo_wine
683 fail_GSCSP(W, NULL, 0, NULL, &size, 0, FALSE, (GLE == ERROR_INSUFFICIENT_BUFFER || GLE == ERROR_FILE_NOT_FOUND));
684 todo_wine
685 fail_GSCSP(W, NULL, 0, newprofile, &size, sizeP, TRUE, (GLE == ERROR_FILE_NOT_FOUND));
686 #undef W
688 /* Functional checks */
690 if (standardprofileW)
692 size = sizeof(oldprofile);
694 ret = pGetStandardColorSpaceProfileW( NULL, SPACE_RGB, oldprofile, &size );
695 ok( ret, "GetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() );
697 ret = pSetStandardColorSpaceProfileW( NULL, SPACE_RGB, standardprofileW );
698 ok( ret, "SetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() );
700 size = sizeof(newprofile);
702 ret = pGetStandardColorSpaceProfileW( NULL, SPACE_RGB, newprofile, &size );
703 ok( ret, "GetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() );
705 ok( !lstrcmpiW( (LPWSTR)&newprofile, standardprofileW ), "Unexpected profile\n" );
707 ret = pSetStandardColorSpaceProfileW( NULL, SPACE_RGB, oldprofile );
708 ok( ret, "SetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() );
712 static void test_InstallColorProfileA(void)
714 BOOL ret;
716 /* Parameter checks */
718 ret = pInstallColorProfileA( NULL, NULL );
719 ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
721 ret = pInstallColorProfileA( machine, NULL );
722 ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
724 ret = pInstallColorProfileA( NULL, machine );
725 ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
727 if (standardprofile)
729 ret = pInstallColorProfileA( NULL, standardprofile );
730 ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
733 /* Functional checks */
735 if (testprofile)
737 CHAR dest[MAX_PATH], base[MAX_PATH];
738 DWORD size = sizeof(dest);
739 CHAR slash[] = "\\";
740 HANDLE handle;
742 ret = pInstallColorProfileA( NULL, testprofile );
743 ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
745 ret = pGetColorDirectoryA( NULL, dest, &size );
746 ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
748 MSCMS_basenameA( testprofile, base );
750 lstrcatA( dest, slash );
751 lstrcatA( dest, base );
753 /* Check if the profile is really there */
754 handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
755 ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() );
756 CloseHandle( handle );
758 ret = pUninstallColorProfileA( NULL, dest, TRUE );
759 ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
763 static void test_InstallColorProfileW(void)
765 BOOL ret;
767 /* Parameter checks */
769 ret = pInstallColorProfileW( NULL, NULL );
770 ok( !ret, "InstallColorProfileW() succeeded (%ld)\n", GetLastError() );
772 ret = pInstallColorProfileW( machineW, NULL );
773 ok( !ret, "InstallColorProfileW() succeeded (%ld)\n", GetLastError() );
775 ret = pInstallColorProfileW( NULL, machineW );
776 ok( !ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
778 if (standardprofileW)
780 ret = pInstallColorProfileW( NULL, standardprofileW );
781 ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
784 /* Functional checks */
786 if (testprofileW)
788 WCHAR dest[MAX_PATH], base[MAX_PATH];
789 DWORD size = sizeof(dest);
790 WCHAR slash[] = { '\\', 0 };
791 HANDLE handle;
793 ret = pInstallColorProfileW( NULL, testprofileW );
794 ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
796 ret = pGetColorDirectoryW( NULL, dest, &size );
797 ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
799 MSCMS_basenameW( testprofileW, base );
801 lstrcatW( dest, slash );
802 lstrcatW( dest, base );
804 /* Check if the profile is really there */
805 handle = CreateFileW( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
806 ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() );
807 CloseHandle( handle );
809 ret = pUninstallColorProfileW( NULL, dest, TRUE );
810 ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
814 static void test_IsColorProfileTagPresent(void)
816 if (standardprofile)
818 PROFILE profile;
819 HPROFILE handle;
820 BOOL ret, present;
821 TAGTYPE tag;
823 profile.dwType = PROFILE_FILENAME;
824 profile.pProfileData = standardprofile;
825 profile.cbDataSize = strlen(standardprofile);
827 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
828 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
830 /* Parameter checks */
832 tag = 0;
834 ret = pIsColorProfileTagPresent( handle, tag, &present );
835 ok( !(ret && present), "IsColorProfileTagPresent() succeeded (%ld)\n", GetLastError() );
837 tag = 0x63707274; /* 'cprt' */
839 ret = pIsColorProfileTagPresent( NULL, tag, &present );
840 ok( !ret, "IsColorProfileTagPresent() succeeded (%ld)\n", GetLastError() );
842 ret = pIsColorProfileTagPresent( handle, tag, NULL );
843 ok( !ret, "IsColorProfileTagPresent() succeeded (%ld)\n", GetLastError() );
845 /* Functional checks */
847 ret = pIsColorProfileTagPresent( handle, tag, &present );
848 ok( ret && present, "IsColorProfileTagPresent() failed (%ld)\n", GetLastError() );
850 pCloseColorProfile( handle );
854 static void test_OpenColorProfileA(void)
856 PROFILE profile;
857 HPROFILE handle;
858 BOOL ret;
860 profile.dwType = PROFILE_FILENAME;
861 profile.pProfileData = NULL;
862 profile.cbDataSize = 0;
864 /* Parameter checks */
866 handle = pOpenColorProfileA( NULL, 0, 0, 0 );
867 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
869 handle = pOpenColorProfileA( &profile, 0, 0, 0 );
870 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
872 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, 0 );
873 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
875 handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, 0 );
876 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
878 ok ( !pCloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" );
880 if (standardprofile)
882 profile.pProfileData = standardprofile;
883 profile.cbDataSize = strlen(standardprofile);
885 handle = pOpenColorProfileA( &profile, 0, 0, 0 );
886 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
888 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, 0 );
889 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
891 handle = pOpenColorProfileA( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 );
892 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
894 /* Functional checks */
896 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
897 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
899 ret = pCloseColorProfile( handle );
900 ok( ret, "CloseColorProfile() failed (%ld)\n", GetLastError() );
904 static void test_OpenColorProfileW(void)
906 PROFILE profile;
907 HPROFILE handle;
908 BOOL ret;
910 profile.dwType = PROFILE_FILENAME;
911 profile.pProfileData = NULL;
912 profile.cbDataSize = 0;
914 /* Parameter checks */
916 handle = pOpenColorProfileW( NULL, 0, 0, 0 );
917 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
919 handle = pOpenColorProfileW( &profile, 0, 0, 0 );
920 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
922 handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, 0 );
923 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
925 handle = pOpenColorProfileW( &profile, PROFILE_READWRITE, 0, 0 );
926 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
928 ok ( !pCloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" );
930 if (standardprofileW)
932 profile.pProfileData = standardprofileW;
933 profile.cbDataSize = lstrlenW(standardprofileW) * sizeof(WCHAR);
935 handle = pOpenColorProfileW( &profile, 0, 0, 0 );
936 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
938 handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, 0 );
939 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
941 handle = pOpenColorProfileW( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 );
942 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
944 /* Functional checks */
946 handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, OPEN_EXISTING );
947 ok( handle != NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
949 ret = pCloseColorProfile( handle );
950 ok( ret, "CloseColorProfile() failed (%ld)\n", GetLastError() );
954 static void test_SetColorProfileElement(void)
956 if (testprofile)
958 PROFILE profile;
959 HPROFILE handle;
960 DWORD size;
961 BOOL ret, ref;
963 TAGTYPE tag = 0x63707274; /* 'cprt' */
964 static char data[] = "(c) The Wine Project";
965 static char buffer[51];
967 profile.dwType = PROFILE_FILENAME;
968 profile.pProfileData = testprofile;
969 profile.cbDataSize = strlen(testprofile);
971 /* Parameter checks */
973 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
974 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
976 ret = pSetColorProfileElement( handle, tag, 0, &size, data );
977 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
979 pCloseColorProfile( handle );
981 handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING );
982 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
984 ret = pSetColorProfileElement( NULL, 0, 0, NULL, NULL );
985 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
987 ret = pSetColorProfileElement( handle, 0, 0, NULL, NULL );
988 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
990 ret = pSetColorProfileElement( handle, tag, 0, NULL, NULL );
991 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
993 ret = pSetColorProfileElement( handle, tag, 0, &size, NULL );
994 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
996 /* Functional checks */
998 size = sizeof(data);
1000 ret = pSetColorProfileElement( handle, tag, 0, &size, data );
1001 ok( ret, "SetColorProfileElement() failed (%ld)\n", GetLastError() );
1003 size = sizeof(buffer);
1005 ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
1006 ok( ret && size > 0, "GetColorProfileElement() failed (%ld)\n", GetLastError() );
1008 ok( !memcmp( data, buffer, sizeof(data) ),
1009 "Unexpected tag data, expected %s, got %s (%ld)\n",
1010 data, buffer, GetLastError() );
1012 pCloseColorProfile( handle );
1016 static void test_SetColorProfileHeader(void)
1018 if (testprofile)
1020 PROFILE profile;
1021 HPROFILE handle;
1022 BOOL ret;
1023 PROFILEHEADER header;
1025 profile.dwType = PROFILE_FILENAME;
1026 profile.pProfileData = testprofile;
1027 profile.cbDataSize = strlen(testprofile);
1029 header.phSize = 0x00000c48;
1030 header.phCMMType = 0x4c696e6f;
1031 header.phVersion = 0x02100000;
1032 header.phClass = 0x6d6e7472;
1033 header.phDataColorSpace = 0x52474220;
1034 header.phConnectionSpace = 0x58595a20;
1035 header.phDateTime[0] = 0x07ce0002;
1036 header.phDateTime[1] = 0x00090006;
1037 header.phDateTime[2] = 0x00310000;
1038 header.phSignature = 0x61637370;
1039 header.phPlatform = 0x4d534654;
1040 header.phProfileFlags = 0x00000000;
1041 header.phManufacturer = 0x49454320;
1042 header.phModel = 0x73524742;
1043 header.phAttributes[0] = 0x00000000;
1044 header.phAttributes[1] = 0x00000000;
1045 header.phRenderingIntent = 0x00000000;
1046 header.phIlluminant.ciexyzX = 0x0000f6d6;
1047 header.phIlluminant.ciexyzY = 0x00010000;
1048 header.phIlluminant.ciexyzZ = 0x0000d32d;
1049 header.phCreator = 0x48502020;
1051 /* Parameter checks */
1053 handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
1054 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
1056 ret = pSetColorProfileHeader( handle, &header );
1057 ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
1059 pCloseColorProfile( handle );
1061 handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING );
1062 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
1064 ret = pSetColorProfileHeader( NULL, NULL );
1065 ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
1067 ret = pSetColorProfileHeader( handle, NULL );
1068 ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
1070 ret = pSetColorProfileHeader( NULL, &header );
1071 ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
1073 /* Functional checks */
1075 ret = pSetColorProfileHeader( handle, &header );
1076 ok( ret, "SetColorProfileHeader() failed (%ld)\n", GetLastError() );
1078 ret = pGetColorProfileHeader( handle, &header );
1079 ok( ret, "GetColorProfileHeader() failed (%ld)\n", GetLastError() );
1081 ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" );
1083 pCloseColorProfile( handle );
1087 static void test_UninstallColorProfileA(void)
1089 BOOL ret;
1091 /* Parameter checks */
1093 ret = pUninstallColorProfileA( NULL, NULL, FALSE );
1094 ok( !ret, "UninstallColorProfileA() succeeded (%ld)\n", GetLastError() );
1096 ret = pUninstallColorProfileA( machine, NULL, FALSE );
1097 ok( !ret, "UninstallColorProfileA() succeeded (%ld)\n", GetLastError() );
1099 /* Functional checks */
1101 if (testprofile)
1103 CHAR dest[MAX_PATH], base[MAX_PATH];
1104 DWORD size = sizeof(dest);
1105 CHAR slash[] = "\\";
1106 HANDLE handle;
1108 ret = pInstallColorProfileA( NULL, testprofile );
1109 ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
1111 ret = pGetColorDirectoryA( NULL, dest, &size );
1112 ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
1114 MSCMS_basenameA( testprofile, base );
1116 lstrcatA( dest, slash );
1117 lstrcatA( dest, base );
1119 ret = pUninstallColorProfileA( NULL, dest, TRUE );
1120 ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
1122 /* Check if the profile is really gone */
1123 handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1124 ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%ld)\n", GetLastError() );
1125 CloseHandle( handle );
1129 static void test_UninstallColorProfileW(void)
1131 BOOL ret;
1133 /* Parameter checks */
1135 ret = pUninstallColorProfileW( NULL, NULL, FALSE );
1136 ok( !ret, "UninstallColorProfileW() succeeded (%ld)\n", GetLastError() );
1138 ret = pUninstallColorProfileW( machineW, NULL, FALSE );
1139 ok( !ret, "UninstallColorProfileW() succeeded (%ld)\n", GetLastError() );
1141 /* Functional checks */
1143 if (testprofileW)
1145 WCHAR dest[MAX_PATH], base[MAX_PATH];
1146 char destA[MAX_PATH];
1147 DWORD size = sizeof(dest);
1148 WCHAR slash[] = { '\\', 0 };
1149 HANDLE handle;
1150 int bytes_copied;
1152 ret = pInstallColorProfileW( NULL, testprofileW );
1153 ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
1155 ret = pGetColorDirectoryW( NULL, dest, &size );
1156 ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
1158 MSCMS_basenameW( testprofileW, base );
1160 lstrcatW( dest, slash );
1161 lstrcatW( dest, base );
1163 ret = pUninstallColorProfileW( NULL, dest, TRUE );
1164 ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
1166 bytes_copied = WideCharToMultiByte(CP_ACP, 0, dest, -1, destA, MAX_PATH, NULL, NULL);
1167 ok( bytes_copied > 0 , "WideCharToMultiByte() returns %d\n", bytes_copied);
1168 /* Check if the profile is really gone */
1169 handle = CreateFileA( destA, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1170 ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%ld)\n", GetLastError() );
1171 CloseHandle( handle );
1175 START_TEST(profile)
1177 UINT len;
1178 HANDLE handle;
1179 char path[MAX_PATH], file[MAX_PATH];
1180 char profilefile1[MAX_PATH], profilefile2[MAX_PATH];
1181 WCHAR profilefile1W[MAX_PATH], profilefile2W[MAX_PATH];
1182 WCHAR fileW[MAX_PATH];
1183 UINT ret;
1185 hmscms = LoadLibraryA( "mscms.dll" );
1186 if (!hmscms) return;
1188 if (!init_function_ptrs())
1190 FreeLibrary( hmscms );
1191 return;
1194 /* See if we can find the standard color profile */
1195 ret = GetSystemDirectoryA( profilefile1, sizeof(profilefile1) );
1196 ok( ret > 0, "GetSystemDirectoryA() returns %d, LastError = %ld\n", ret, GetLastError());
1197 ok( lstrlenA(profilefile1) > 0 && lstrlenA(profilefile1) < MAX_PATH,
1198 "GetSystemDirectoryA() returns %d, LastError = %ld\n", ret, GetLastError());
1199 MultiByteToWideChar(CP_ACP, 0, profilefile1, -1, profilefile1W, MAX_PATH);
1200 ok( lstrlenW(profilefile1W) > 0 && lstrlenW(profilefile1W) < MAX_PATH,
1201 "GetSystemDirectoryA() returns %d, LastError = %ld\n", ret, GetLastError());
1202 lstrcpyA(profilefile2, profilefile1);
1203 lstrcpyW(profilefile2W, profilefile1W);
1205 lstrcatA( profilefile1, profile1 );
1206 lstrcatW( profilefile1W, profile1W );
1207 handle = CreateFileA( profilefile1, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1209 if (handle != INVALID_HANDLE_VALUE)
1211 standardprofile = profilefile1;
1212 standardprofileW = profilefile1W;
1213 CloseHandle( handle );
1216 lstrcatA( profilefile2, profile2 );
1217 lstrcatW( profilefile2W, profile2W );
1218 handle = CreateFileA( profilefile2, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
1220 if (handle != INVALID_HANDLE_VALUE)
1222 standardprofile = profilefile2;
1223 standardprofileW = profilefile2W;
1224 CloseHandle( handle );
1227 /* If found, create a temporary copy for testing purposes */
1228 if (standardprofile && GetTempPath( sizeof(path), path ))
1230 if (GetTempFileName( path, "rgb", 0, file ))
1232 if (CopyFileA( standardprofile, file, FALSE ))
1234 testprofile = (LPSTR)&file;
1236 len = MultiByteToWideChar( CP_ACP, 0, testprofile, -1, NULL, 0 );
1237 MultiByteToWideChar( CP_ACP, 0, testprofile, -1, fileW, len );
1239 testprofileW = (LPWSTR)&fileW;
1244 test_GetColorDirectoryA();
1245 test_GetColorDirectoryW();
1247 test_GetColorProfileElement();
1248 test_GetColorProfileElementTag();
1250 test_GetColorProfileFromHandle();
1251 test_GetColorProfileHeader();
1253 test_GetCountColorProfileElements();
1255 enum_registered_color_profiles();
1256 check_registry();
1258 test_GetStandardColorSpaceProfileA();
1259 test_GetStandardColorSpaceProfileW();
1261 test_InstallColorProfileA();
1262 test_InstallColorProfileW();
1264 test_IsColorProfileTagPresent();
1266 test_OpenColorProfileA();
1267 test_OpenColorProfileW();
1269 test_SetColorProfileElement();
1270 test_SetColorProfileHeader();
1272 test_UninstallColorProfileA();
1273 test_UninstallColorProfileW();
1275 /* Clean up */
1276 if (testprofile)
1277 DeleteFileA( testprofile );
1279 FreeLibrary( hmscms );