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
30 #include "wine/test.h"
32 static const char machine[] = "dummy";
33 static const WCHAR machineW[] = { 'd','u','m','m','y',0 };
35 /* To do any real functionality testing with this suite you need a copy of
36 * the freely distributable standard RGB color space profile. It comes
37 * standard with Windows, but on Wine you probably need to install it yourself
38 * in one of the locations mentioned below. Here's a link to the profile in
39 * a self extracting zip file:
41 * http://download.microsoft.com/download/whistler/hwdev1/1.0/wxp/en-us/ColorProfile.exe
44 /* Two common places to find the standard color space profile */
45 static const char profile1[] =
46 "c:\\windows\\system\\color\\srgb color space profile.icm";
47 static const char profile2[] =
48 "c:\\windows\\system32\\spool\\drivers\\color\\srgb color space profile.icm";
50 static const WCHAR profile1W[] =
51 { 'c',':','\\','w','i','n','d','o','w','s','\\', 's','y','s','t','e','m',
52 '\\','c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
53 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
54 static const WCHAR profile2W[] =
55 { 'c',':','\\','w','i','n','d','o','w','s','\\', 's','y','s','t','e','m','3','2',
56 '\\','s','p','o','o','l','\\','d','r','i','v','e','r','s',
57 '\\','c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
58 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
60 static const unsigned char rgbheader[] =
61 { 0x48, 0x0c, 0x00, 0x00, 0x6f, 0x6e, 0x69, 0x4c, 0x00, 0x00, 0x10, 0x02,
62 0x72, 0x74, 0x6e, 0x6d, 0x20, 0x42, 0x47, 0x52, 0x20, 0x5a, 0x59, 0x58,
63 0x02, 0x00, 0xce, 0x07, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, 0x31, 0x00,
64 0x70, 0x73, 0x63, 0x61, 0x54, 0x46, 0x53, 0x4d, 0x00, 0x00, 0x00, 0x00,
65 0x20, 0x43, 0x45, 0x49, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00,
66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xf6, 0x00, 0x00,
67 0x00, 0x00, 0x01, 0x00, 0x2d, 0xd3, 0x00, 0x00, 0x20, 0x20, 0x50, 0x48 };
69 static LPSTR standardprofile;
70 static LPWSTR standardprofileW;
72 static LPSTR testprofile;
73 static LPWSTR testprofileW;
75 #define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
77 static void MSCMS_basenameA( LPCSTR path, LPSTR name )
79 INT i = strlen( path );
81 while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
82 strcpy( name, &path[i] );
85 static void MSCMS_basenameW( LPCWSTR path, LPWSTR name )
87 INT i = lstrlenW( path );
89 while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
90 lstrcpyW( name, &path[i] );
93 static void test_GetColorDirectoryA()
97 char buffer[MAX_PATH];
99 /* Parameter checks */
101 ret = GetColorDirectoryA( NULL, NULL, NULL );
102 ok( !ret, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
106 ret = GetColorDirectoryA( NULL, NULL, &size );
107 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
111 ret = GetColorDirectoryA( NULL, buffer, &size );
112 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
116 ret = GetColorDirectoryA( NULL, buffer, &size );
117 ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
119 /* Functional checks */
121 size = sizeof(buffer);
123 ret = GetColorDirectoryA( NULL, buffer, &size );
124 ok( ret && size > 0, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
127 static void test_GetColorDirectoryW()
131 WCHAR buffer[MAX_PATH];
133 /* Parameter checks */
135 /* This one crashes win2k
137 ret = GetColorDirectoryW( NULL, NULL, NULL );
138 ok( !ret, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
144 ret = GetColorDirectoryW( NULL, NULL, &size );
145 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
149 ret = GetColorDirectoryW( NULL, buffer, &size );
150 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
154 ret = GetColorDirectoryW( NULL, buffer, &size );
155 ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
157 /* Functional checks */
159 size = sizeof(buffer);
161 ret = GetColorDirectoryW( NULL, buffer, &size );
162 ok( ret && size > 0, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
163 ret = GetColorDirectoryW( NULL, buffer, &size );
166 static void test_GetColorProfileElement()
174 TAGTYPE tag = 0x63707274; /* 'cprt' */
175 static char buffer[51];
176 static const char expect[] =
177 { 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x70,
178 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20,
179 0x31, 0x39, 0x39, 0x38, 0x20, 0x48, 0x65, 0x77, 0x6c, 0x65, 0x74,
180 0x74, 0x2d, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x72, 0x64, 0x20, 0x43,
181 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x00 };
183 profile.dwType = PROFILE_FILENAME;
184 profile.pProfileData = standardprofile;
185 profile.cbDataSize = strlen(standardprofile);
187 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
188 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
190 /* Parameter checks */
192 ret = GetColorProfileElement( handle, tag, 0, NULL, NULL, &ref );
193 ok( !ret, "GetColorProfileElement() succeeded (%ld)\n", GetLastError() );
195 ret = GetColorProfileElement( handle, tag, 0, &size, NULL, NULL );
196 ok( !ret, "GetColorProfileElement() succeeded (%ld)\n", GetLastError() );
200 ret = GetColorProfileElement( handle, tag, 0, &size, NULL, &ref );
201 ok( !ret && size > 0, "GetColorProfileElement() succeeded (%ld)\n", GetLastError() );
203 size = sizeof(buffer);
205 /* Functional checks */
207 ret = GetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
208 ok( ret && size > 0, "GetColorProfileElement() failed (%ld)\n", GetLastError() );
210 ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected tag data\n" );
212 CloseColorProfile( handle );
216 static void test_GetColorProfileElementTag()
224 TAGTYPE tag, expect = 0x63707274; /* 'cprt' */
226 profile.dwType = PROFILE_FILENAME;
227 profile.pProfileData = standardprofile;
228 profile.cbDataSize = strlen(standardprofile);
230 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
231 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
233 /* Parameter checks */
235 ret = GetColorProfileElementTag( NULL, index, &tag );
236 ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() );
238 ret = GetColorProfileElementTag( handle, 0, &tag );
239 ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() );
241 ret = GetColorProfileElementTag( handle, index, NULL );
242 ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() );
244 ret = GetColorProfileElementTag( handle, 18, NULL );
245 ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() );
247 /* Functional checks */
249 ret = GetColorProfileElementTag( handle, index, &tag );
250 ok( ret && tag == expect, "GetColorProfileElementTag() failed (%ld)\n",
253 CloseColorProfile( handle );
257 static void test_GetColorProfileFromHandle()
265 static const unsigned char expect[] =
266 { 0x00, 0x00, 0x0c, 0x48, 0x4c, 0x69, 0x6e, 0x6f, 0x02, 0x10, 0x00,
267 0x00, 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59,
268 0x5a, 0x20, 0x07, 0xce, 0x00, 0x02, 0x00, 0x09, 0x00, 0x06, 0x00,
269 0x31, 0x00, 0x00, 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54,
270 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47,
271 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00,
273 0x00, 0xd3, 0x2d, 0x48, 0x50, 0x20, 0x20 };
275 unsigned char *buffer;
277 profile.dwType = PROFILE_FILENAME;
278 profile.pProfileData = testprofile;
279 profile.cbDataSize = strlen(testprofile);
281 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
282 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
284 /* Parameter checks */
288 ret = GetColorProfileFromHandle( handle, NULL, &size );
289 ok( !ret && size > 0, "GetColorProfileFromHandle() failed (%ld)\n", GetLastError() );
291 buffer = HeapAlloc( GetProcessHeap(), 0, size );
295 ret = GetColorProfileFromHandle( NULL, buffer, &size );
296 ok( !ret, "GetColorProfileFromHandle() succeeded (%ld)\n", GetLastError() );
298 ret = GetColorProfileFromHandle( handle, buffer, NULL );
299 ok( !ret, "GetColorProfileFromHandle() succeeded (%ld)\n", GetLastError() );
301 /* Functional checks */
303 ret = GetColorProfileFromHandle( handle, buffer, &size );
304 ok( ret && size > 0, "GetColorProfileFromHandle() failed (%ld)\n", GetLastError() );
306 ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected header data\n" );
308 HeapFree( GetProcessHeap(), 0, buffer );
311 CloseColorProfile( handle );
315 static void test_GetColorProfileHeader()
322 PROFILEHEADER header;
324 profile.dwType = PROFILE_FILENAME;
325 profile.pProfileData = testprofile;
326 profile.cbDataSize = strlen(testprofile);
328 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
329 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
331 /* Parameter checks */
333 ret = GetColorProfileHeader( NULL, NULL );
334 ok( !ret, "GetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
336 ret = GetColorProfileHeader( NULL, &header );
337 ok( !ret, "GetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
339 ret = GetColorProfileHeader( handle, NULL );
340 ok( !ret, "GetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
342 /* Functional checks */
344 ret = GetColorProfileHeader( handle, &header );
345 ok( ret, "GetColorProfileHeader() failed (%ld)\n", GetLastError() );
347 ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" );
349 CloseColorProfile( handle );
353 static void test_GetCountColorProfileElements()
360 DWORD count, expect = 17;
362 profile.dwType = PROFILE_FILENAME;
363 profile.pProfileData = standardprofile;
364 profile.cbDataSize = strlen(standardprofile);
366 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
367 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
369 /* Parameter checks */
371 ret = GetCountColorProfileElements( NULL, &count );
372 ok( !ret, "GetCountColorProfileElements() succeeded (%ld)\n",
375 ret = GetCountColorProfileElements( handle, NULL );
376 ok( !ret, "GetCountColorProfileElements() succeeded (%ld)\n",
379 /* Functional checks */
381 ret = GetCountColorProfileElements( handle, &count );
382 ok( ret && count == expect,
383 "GetCountColorProfileElements() failed (%ld)\n", GetLastError() );
385 CloseColorProfile( handle );
389 static void test_GetStandardColorSpaceProfileA()
393 CHAR oldprofile[MAX_PATH];
394 CHAR newprofile[MAX_PATH];
396 /* Parameter checks */
398 ret = GetStandardColorSpaceProfileA( NULL, 0, newprofile, NULL );
399 ok( !ret, "GetStandardColorSpaceProfileA() succeeded (%ld)\n", GetLastError() );
401 ret = GetStandardColorSpaceProfileA( machine, 0, newprofile, &size );
402 ok( !ret, "GetStandardColorSpaceProfileA() succeeded (%ld)\n", GetLastError() );
406 ret = GetStandardColorSpaceProfileA( NULL, 0, NULL, &size );
407 ok( !ret, "GetStandardColorSpaceProfileA() succeeded (%ld)\n", GetLastError() );
409 size = sizeof(newprofile);
411 ret = GetStandardColorSpaceProfileA( NULL, 0, newprofile, &size );
412 ok( !ret, "GetStandardColorSpaceProfileA() succeeded (%ld)\n", GetLastError() );
414 /* Functional checks */
418 size = sizeof(oldprofile);
420 ret = GetStandardColorSpaceProfileA( NULL, SPACE_RGB, oldprofile, &size );
421 ok( ret, "GetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() );
423 ret = SetStandardColorSpaceProfileA( NULL, SPACE_RGB, standardprofile );
424 ok( ret, "SetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() );
426 size = sizeof(newprofile);
428 ret = GetStandardColorSpaceProfileA( NULL, SPACE_RGB, newprofile, &size );
429 ok( ret, "GetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() );
431 ok( !lstrcmpiA( (LPSTR)&newprofile, standardprofile ), "Unexpected profile\n" );
433 ret = SetStandardColorSpaceProfileA( NULL, SPACE_RGB, oldprofile );
434 ok( ret, "SetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() );
438 static void test_GetStandardColorSpaceProfileW()
442 WCHAR oldprofile[MAX_PATH];
443 WCHAR newprofile[MAX_PATH];
445 /* Parameter checks */
447 ret = GetStandardColorSpaceProfileW( NULL, 0, newprofile, NULL );
448 ok( !ret, "GetStandardColorSpaceProfileW() succeeded (%ld)\n", GetLastError() );
450 ret = GetStandardColorSpaceProfileW( machineW, 0, newprofile, &size );
451 ok( !ret, "GetStandardColorSpaceProfileW() succeeded (%ld)\n", GetLastError() );
455 ret = GetStandardColorSpaceProfileW( NULL, 0, NULL, &size );
456 ok( !ret, "GetStandardColorSpaceProfileW() succeeded (%ld)\n", GetLastError() );
458 size = sizeof(newprofile);
460 ret = GetStandardColorSpaceProfileW( NULL, 0, newprofile, &size );
461 ok( !ret, "GetStandardColorSpaceProfileW() succeeded (%ld)\n", GetLastError() );
463 /* Functional checks */
465 if (standardprofileW)
467 size = sizeof(oldprofile);
469 ret = GetStandardColorSpaceProfileW( NULL, SPACE_RGB, oldprofile, &size );
470 ok( ret, "GetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() );
472 ret = SetStandardColorSpaceProfileW( NULL, SPACE_RGB, standardprofileW );
473 ok( ret, "SetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() );
475 size = sizeof(newprofile);
477 ret = GetStandardColorSpaceProfileW( NULL, SPACE_RGB, newprofile, &size );
478 ok( ret, "GetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() );
480 ok( !lstrcmpiW( (LPWSTR)&newprofile, standardprofileW ), "Unexpected profile\n" );
482 ret = SetStandardColorSpaceProfileW( NULL, SPACE_RGB, oldprofile );
483 ok( ret, "SetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() );
487 static void test_InstallColorProfileA()
491 /* Parameter checks */
493 ret = InstallColorProfileA( NULL, NULL );
494 ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
496 ret = InstallColorProfileA( machine, NULL );
497 ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
499 ret = InstallColorProfileA( NULL, machine );
500 ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
504 ret = InstallColorProfileA( NULL, standardprofile );
505 ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
508 /* Functional checks */
512 CHAR dest[MAX_PATH], base[MAX_PATH];
513 DWORD size = sizeof(dest);
517 ret = InstallColorProfileA( NULL, testprofile );
518 ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
520 ret = GetColorDirectoryA( NULL, dest, &size );
521 ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
523 MSCMS_basenameA( testprofile, base );
525 strcat( dest, slash );
526 strcat( dest, base );
528 /* Check if the profile is really there */
529 handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
530 ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() );
531 CloseHandle( handle );
533 ret = UninstallColorProfileA( NULL, dest, TRUE );
534 ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
538 static void test_InstallColorProfileW()
542 /* Parameter checks */
544 ret = InstallColorProfileW( NULL, NULL );
545 ok( !ret, "InstallColorProfileW() succeeded (%ld)\n", GetLastError() );
547 ret = InstallColorProfileW( machineW, NULL );
548 ok( !ret, "InstallColorProfileW() succeeded (%ld)\n", GetLastError() );
550 ret = InstallColorProfileW( NULL, machineW );
551 ok( !ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
553 if (standardprofileW)
555 ret = InstallColorProfileW( NULL, standardprofileW );
556 ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
559 /* Functional checks */
563 WCHAR dest[MAX_PATH], base[MAX_PATH];
564 DWORD size = sizeof(dest);
565 WCHAR slash[] = { '\\', 0 };
568 ret = InstallColorProfileW( NULL, testprofileW );
569 ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
571 ret = GetColorDirectoryW( NULL, dest, &size );
572 ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
574 MSCMS_basenameW( testprofileW, base );
576 lstrcatW( dest, slash );
577 lstrcatW( dest, base );
579 /* Check if the profile is really there */
580 handle = CreateFileW( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
581 ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() );
582 CloseHandle( handle );
584 ret = UninstallColorProfileW( NULL, dest, TRUE );
585 ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
589 static void test_IsColorProfileTagPresent()
598 profile.dwType = PROFILE_FILENAME;
599 profile.pProfileData = standardprofile;
600 profile.cbDataSize = strlen(standardprofile);
602 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
603 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
605 /* Parameter checks */
609 ret = IsColorProfileTagPresent( handle, tag, &present );
610 ok( !(ret && present), "IsColorProfileTagPresent() succeeded (%ld)\n", GetLastError() );
612 tag = 0x63707274; /* 'cprt' */
614 ret = IsColorProfileTagPresent( NULL, tag, &present );
615 ok( !ret, "IsColorProfileTagPresent() succeeded (%ld)\n", GetLastError() );
617 ret = IsColorProfileTagPresent( handle, tag, NULL );
618 ok( !ret, "IsColorProfileTagPresent() succeeded (%ld)\n", GetLastError() );
620 /* Functional checks */
622 ret = IsColorProfileTagPresent( handle, tag, &present );
623 ok( ret && present, "IsColorProfileTagPresent() failed (%ld)\n", GetLastError() );
625 CloseColorProfile( handle );
629 static void test_OpenColorProfileA()
635 profile.dwType = PROFILE_FILENAME;
636 profile.pProfileData = NULL;
637 profile.cbDataSize = 0;
639 /* Parameter checks */
641 handle = OpenColorProfileA( NULL, 0, 0, 0 );
642 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
644 handle = OpenColorProfileA( &profile, 0, 0, 0 );
645 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
647 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, 0 );
648 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
650 handle = OpenColorProfileA( &profile, PROFILE_READWRITE, 0, 0 );
651 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
653 ok ( !CloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" );
657 profile.pProfileData = standardprofile;
658 profile.cbDataSize = strlen(standardprofile);
660 handle = OpenColorProfileA( &profile, 0, 0, 0 );
661 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
663 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, 0 );
664 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
666 handle = OpenColorProfileA( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 );
667 ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
669 /* Functional checks */
671 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
672 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
674 ret = CloseColorProfile( handle );
675 ok( ret, "CloseColorProfile() failed (%ld)\n", GetLastError() );
679 static void test_OpenColorProfileW()
685 profile.dwType = PROFILE_FILENAME;
686 profile.pProfileData = NULL;
687 profile.cbDataSize = 0;
689 /* Parameter checks */
691 handle = OpenColorProfileW( NULL, 0, 0, 0 );
692 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
694 handle = OpenColorProfileW( &profile, 0, 0, 0 );
695 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
697 handle = OpenColorProfileW( &profile, PROFILE_READ, 0, 0 );
698 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
700 handle = OpenColorProfileW( &profile, PROFILE_READWRITE, 0, 0 );
701 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
703 ok ( !CloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" );
705 if (standardprofileW)
707 profile.pProfileData = standardprofileW;
708 profile.cbDataSize = lstrlenW(standardprofileW) * sizeof(WCHAR);
710 handle = OpenColorProfileW( &profile, 0, 0, 0 );
711 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
713 handle = OpenColorProfileW( &profile, PROFILE_READ, 0, 0 );
714 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
716 handle = OpenColorProfileW( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 );
717 ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
719 /* Functional checks */
721 handle = OpenColorProfileW( &profile, PROFILE_READ, 0, OPEN_EXISTING );
722 ok( handle != NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
724 ret = CloseColorProfile( handle );
725 ok( ret, "CloseColorProfile() failed (%ld)\n", GetLastError() );
729 static void test_SetColorProfileElement()
738 TAGTYPE tag = 0x63707274; /* 'cprt' */
739 static char data[] = "(c) The Wine Project";
740 static char buffer[51];
742 profile.dwType = PROFILE_FILENAME;
743 profile.pProfileData = testprofile;
744 profile.cbDataSize = strlen(testprofile);
746 /* Parameter checks */
748 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
749 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
751 ret = SetColorProfileElement( handle, tag, 0, &size, data );
752 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
754 CloseColorProfile( handle );
756 handle = OpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING );
757 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
759 ret = SetColorProfileElement( NULL, 0, 0, NULL, NULL );
760 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
762 ret = SetColorProfileElement( handle, 0, 0, NULL, NULL );
763 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
765 ret = SetColorProfileElement( handle, tag, 0, NULL, NULL );
766 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
768 ret = SetColorProfileElement( handle, tag, 0, &size, NULL );
769 ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() );
771 /* Functional checks */
773 ret = SetColorProfileElement( handle, tag, 0, &size, data );
774 ok( ret, "SetColorProfileElement() failed (%ld)\n", GetLastError() );
776 size = sizeof(buffer);
778 ret = GetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
779 ok( ret && size > 0, "GetColorProfileElement() failed (%ld)\n", GetLastError() );
781 ok( !memcmp( data, buffer, sizeof(data) ), "Unexpected tag data\n" );
783 CloseColorProfile( handle );
787 static void test_SetColorProfileHeader()
794 PROFILEHEADER header;
796 profile.dwType = PROFILE_FILENAME;
797 profile.pProfileData = testprofile;
798 profile.cbDataSize = strlen(testprofile);
800 header.phSize = 0x00000c48;
801 header.phCMMType = 0x4c696e6f;
802 header.phVersion = 0x02100000;
803 header.phClass = 0x6d6e7472;
804 header.phDataColorSpace = 0x52474220;
805 header.phConnectionSpace = 0x58595a20;
806 header.phDateTime[0] = 0x07ce0002;
807 header.phDateTime[1] = 0x00090006;
808 header.phDateTime[2] = 0x00310000;
809 header.phSignature = 0x61637370;
810 header.phPlatform = 0x4d534654;
811 header.phProfileFlags = 0x00000000;
812 header.phManufacturer = 0x49454320;
813 header.phModel = 0x73524742;
814 header.phAttributes[0] = 0x00000000;
815 header.phAttributes[1] = 0x00000000;
816 header.phRenderingIntent = 0x00000000;
817 header.phIlluminant.ciexyzX = 0x0000f6d6;
818 header.phIlluminant.ciexyzY = 0x00010000;
819 header.phIlluminant.ciexyzZ = 0x0000d32d;
820 header.phCreator = 0x48502020;
822 /* Parameter checks */
824 handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING );
825 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
827 ret = SetColorProfileHeader( handle, &header );
828 ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
830 CloseColorProfile( handle );
832 handle = OpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING );
833 ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
835 ret = SetColorProfileHeader( NULL, NULL );
836 ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
838 ret = SetColorProfileHeader( handle, NULL );
839 ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
841 ret = SetColorProfileHeader( NULL, &header );
842 ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() );
844 /* Functional checks */
846 ret = SetColorProfileHeader( handle, &header );
847 ok( ret, "SetColorProfileHeader() failed (%ld)\n", GetLastError() );
849 ret = GetColorProfileHeader( handle, &header );
850 ok( ret, "GetColorProfileHeader() failed (%ld)\n", GetLastError() );
852 ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" );
854 CloseColorProfile( handle );
858 static void test_UninstallColorProfileA()
862 /* Parameter checks */
864 ret = UninstallColorProfileA( NULL, NULL, FALSE );
865 ok( !ret, "UninstallColorProfileA() succeeded (%ld)\n", GetLastError() );
867 ret = UninstallColorProfileA( machine, NULL, FALSE );
868 ok( !ret, "UninstallColorProfileA() succeeded (%ld)\n", GetLastError() );
870 /* Functional checks */
874 CHAR dest[MAX_PATH], base[MAX_PATH];
875 DWORD size = sizeof(dest);
879 ret = InstallColorProfileA( NULL, testprofile );
880 ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
882 ret = GetColorDirectoryA( NULL, dest, &size );
883 ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
885 MSCMS_basenameA( testprofile, base );
887 strcat( dest, slash );
888 strcat( dest, base );
890 ret = UninstallColorProfileA( NULL, dest, TRUE );
891 ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
893 /* Check if the profile is really gone */
894 handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
895 ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%ld)\n", GetLastError() );
896 CloseHandle( handle );
900 static void test_UninstallColorProfileW()
904 /* Parameter checks */
906 ret = UninstallColorProfileW( NULL, NULL, FALSE );
907 ok( !ret, "UninstallColorProfileW() succeeded (%ld)\n", GetLastError() );
909 ret = UninstallColorProfileW( machineW, NULL, FALSE );
910 ok( !ret, "UninstallColorProfileW() succeeded (%ld)\n", GetLastError() );
912 /* Functional checks */
916 WCHAR dest[MAX_PATH], base[MAX_PATH];
917 DWORD size = sizeof(dest);
918 WCHAR slash[] = { '\\', 0 };
921 ret = InstallColorProfileW( NULL, testprofileW );
922 ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
924 ret = GetColorDirectoryW( NULL, dest, &size );
925 ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
927 MSCMS_basenameW( testprofileW, base );
929 lstrcatW( dest, slash );
930 lstrcatW( dest, base );
932 ret = UninstallColorProfileW( NULL, dest, TRUE );
933 ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
935 /* Check if the profile is really gone */
936 handle = CreateFileW( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
937 ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%ld)\n", GetLastError() );
938 CloseHandle( handle );
946 char path[MAX_PATH], file[MAX_PATH];
947 WCHAR fileW[MAX_PATH];
949 /* See if we can find the standard color profile */
950 handle = CreateFileA( profile1, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
952 if (handle != INVALID_HANDLE_VALUE)
954 standardprofile = (LPSTR)&profile1;
955 standardprofileW = (LPWSTR)&profile1W;
956 CloseHandle( handle );
959 handle = CreateFileA( profile2, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
961 if (handle != INVALID_HANDLE_VALUE)
963 standardprofile = (LPSTR)&profile2;
964 standardprofileW = (LPWSTR)&profile2W;
965 CloseHandle( handle );
968 /* If found, create a temporary copy for testing purposes */
969 if (standardprofile && GetTempPath( sizeof(path), path ))
971 if (GetTempFileName( path, "rgb", 0, file ))
973 if (CopyFileA( standardprofile, file, FALSE ))
975 testprofile = (LPSTR)&file;
977 len = MultiByteToWideChar( CP_ACP, 0, testprofile, -1, NULL, 0 );
978 MultiByteToWideChar( CP_ACP, 0, testprofile, -1, fileW, len );
980 testprofileW = (LPWSTR)&fileW;
985 test_GetColorDirectoryA();
986 test_GetColorDirectoryW();
988 test_GetColorProfileElement();
989 test_GetColorProfileElementTag();
991 test_GetColorProfileFromHandle();
992 test_GetColorProfileHeader();
994 test_GetCountColorProfileElements();
996 test_GetStandardColorSpaceProfileA();
997 test_GetStandardColorSpaceProfileW();
999 test_InstallColorProfileA();
1000 test_InstallColorProfileW();
1002 test_IsColorProfileTagPresent();
1004 test_OpenColorProfileA();
1005 test_OpenColorProfileW();
1007 test_SetColorProfileElement();
1008 test_SetColorProfileHeader();
1010 test_UninstallColorProfileA();
1011 test_UninstallColorProfileW();
1015 DeleteFileA( testprofile );