2 * Tests for color profile functions
4 * Copyright 2004, 2005, 2006 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/test.h"
33 static HMODULE hmscms
;
34 static HMODULE huser32
;
36 static BOOL (WINAPI
*pAssociateColorProfileWithDeviceA
)(PCSTR
,PCSTR
,PCSTR
);
37 static BOOL (WINAPI
*pCloseColorProfile
)(HPROFILE
);
38 static HTRANSFORM (WINAPI
*pCreateMultiProfileTransform
)(PHPROFILE
,DWORD
,PDWORD
,DWORD
,DWORD
,DWORD
);
39 static BOOL (WINAPI
*pDeleteColorTransform
)(HTRANSFORM
);
40 static BOOL (WINAPI
*pDisassociateColorProfileFromDeviceA
)(PCSTR
,PCSTR
,PCSTR
);
41 static BOOL (WINAPI
*pGetColorDirectoryA
)(PCHAR
,PCHAR
,PDWORD
);
42 static BOOL (WINAPI
*pGetColorDirectoryW
)(PWCHAR
,PWCHAR
,PDWORD
);
43 static BOOL (WINAPI
*pGetColorProfileElement
)(HPROFILE
,TAGTYPE
,DWORD
,PDWORD
,PVOID
,PBOOL
);
44 static BOOL (WINAPI
*pGetColorProfileElementTag
)(HPROFILE
,DWORD
,PTAGTYPE
);
45 static BOOL (WINAPI
*pGetColorProfileFromHandle
)(HPROFILE
,PBYTE
,PDWORD
);
46 static BOOL (WINAPI
*pGetColorProfileHeader
)(HPROFILE
,PPROFILEHEADER
);
47 static BOOL (WINAPI
*pGetCountColorProfileElements
)(HPROFILE
,PDWORD
);
48 static BOOL (WINAPI
*pGetStandardColorSpaceProfileA
)(PCSTR
,DWORD
,PSTR
,PDWORD
);
49 static BOOL (WINAPI
*pGetStandardColorSpaceProfileW
)(PCWSTR
,DWORD
,PWSTR
,PDWORD
);
50 static BOOL (WINAPI
*pEnumColorProfilesA
)(PCSTR
,PENUMTYPEA
,PBYTE
,PDWORD
,PDWORD
);
51 static BOOL (WINAPI
*pEnumColorProfilesW
)(PCWSTR
,PENUMTYPEW
,PBYTE
,PDWORD
,PDWORD
);
52 static BOOL (WINAPI
*pInstallColorProfileA
)(PCSTR
,PCSTR
);
53 static BOOL (WINAPI
*pInstallColorProfileW
)(PCWSTR
,PCWSTR
);
54 static BOOL (WINAPI
*pIsColorProfileTagPresent
)(HPROFILE
,TAGTYPE
,PBOOL
);
55 static HPROFILE (WINAPI
*pOpenColorProfileA
)(PPROFILE
,DWORD
,DWORD
,DWORD
);
56 static HPROFILE (WINAPI
*pOpenColorProfileW
)(PPROFILE
,DWORD
,DWORD
,DWORD
);
57 static BOOL (WINAPI
*pSetColorProfileElement
)(HPROFILE
,TAGTYPE
,DWORD
,PDWORD
,PVOID
);
58 static BOOL (WINAPI
*pSetColorProfileHeader
)(HPROFILE
,PPROFILEHEADER
);
59 static BOOL (WINAPI
*pSetStandardColorSpaceProfileA
)(PCSTR
,DWORD
,PSTR
);
60 static BOOL (WINAPI
*pSetStandardColorSpaceProfileW
)(PCWSTR
,DWORD
,PWSTR
);
61 static BOOL (WINAPI
*pUninstallColorProfileA
)(PCSTR
,PCSTR
,BOOL
);
62 static BOOL (WINAPI
*pUninstallColorProfileW
)(PCWSTR
,PCWSTR
,BOOL
);
64 static BOOL (WINAPI
*pEnumDisplayDevicesA
)(LPCSTR
,DWORD
,PDISPLAY_DEVICEA
,DWORD
);
66 #define GETFUNCPTR(func) p##func = (void *)GetProcAddress( hmscms, #func ); \
67 if (!p##func) return FALSE;
69 static BOOL
init_function_ptrs( void )
71 GETFUNCPTR( AssociateColorProfileWithDeviceA
)
72 GETFUNCPTR( CloseColorProfile
)
73 GETFUNCPTR( CreateMultiProfileTransform
)
74 GETFUNCPTR( DeleteColorTransform
)
75 GETFUNCPTR( DisassociateColorProfileFromDeviceA
)
76 GETFUNCPTR( GetColorDirectoryA
)
77 GETFUNCPTR( GetColorDirectoryW
)
78 GETFUNCPTR( GetColorProfileElement
)
79 GETFUNCPTR( GetColorProfileElementTag
)
80 GETFUNCPTR( GetColorProfileFromHandle
)
81 GETFUNCPTR( GetColorProfileHeader
)
82 GETFUNCPTR( GetCountColorProfileElements
)
83 GETFUNCPTR( GetStandardColorSpaceProfileA
)
84 GETFUNCPTR( GetStandardColorSpaceProfileW
)
85 GETFUNCPTR( EnumColorProfilesA
)
86 GETFUNCPTR( EnumColorProfilesW
)
87 GETFUNCPTR( InstallColorProfileA
)
88 GETFUNCPTR( InstallColorProfileW
)
89 GETFUNCPTR( IsColorProfileTagPresent
)
90 GETFUNCPTR( OpenColorProfileA
)
91 GETFUNCPTR( OpenColorProfileW
)
92 GETFUNCPTR( SetColorProfileElement
)
93 GETFUNCPTR( SetColorProfileHeader
)
94 GETFUNCPTR( SetStandardColorSpaceProfileA
)
95 GETFUNCPTR( SetStandardColorSpaceProfileW
)
96 GETFUNCPTR( UninstallColorProfileA
)
97 GETFUNCPTR( UninstallColorProfileW
)
99 pEnumDisplayDevicesA
= (void *)GetProcAddress( huser32
, "EnumDisplayDevicesA" );
104 static const char machine
[] = "dummy";
105 static const WCHAR machineW
[] = { 'd','u','m','m','y',0 };
107 /* To do any real functionality testing with this suite you need a copy of
108 * the freely distributable standard RGB color space profile. It comes
109 * standard with Windows, but on Wine you probably need to install it yourself
110 * in one of the locations mentioned below.
113 /* Two common places to find the standard color space profile, relative
114 * to the system directory.
116 static const char profile1
[] =
117 "\\color\\srgb color space profile.icm";
118 static const char profile2
[] =
119 "\\spool\\drivers\\color\\srgb color space profile.icm";
121 static const WCHAR profile1W
[] =
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 };
124 static const WCHAR profile2W
[] =
125 { '\\','s','p','o','o','l','\\','d','r','i','v','e','r','s','\\',
126 'c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
127 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
129 static BOOL have_color_profile
;
131 static const unsigned char rgbheader
[] =
132 { 0x48, 0x0c, 0x00, 0x00, 0x6f, 0x6e, 0x69, 0x4c, 0x00, 0x00, 0x10, 0x02,
133 0x72, 0x74, 0x6e, 0x6d, 0x20, 0x42, 0x47, 0x52, 0x20, 0x5a, 0x59, 0x58,
134 0x02, 0x00, 0xce, 0x07, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, 0x31, 0x00,
135 0x70, 0x73, 0x63, 0x61, 0x54, 0x46, 0x53, 0x4d, 0x00, 0x00, 0x00, 0x00,
136 0x20, 0x43, 0x45, 0x49, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00,
137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xf6, 0x00, 0x00,
138 0x00, 0x00, 0x01, 0x00, 0x2d, 0xd3, 0x00, 0x00, 0x20, 0x20, 0x50, 0x48 };
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)
162 char buffer
[MAX_PATH
];
164 /* Parameter checks */
166 ret
= pGetColorDirectoryA( NULL
, NULL
, NULL
);
167 ok( !ret
, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
171 ret
= pGetColorDirectoryA( NULL
, NULL
, &size
);
172 ok( !ret
&& size
> 0, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
176 ret
= pGetColorDirectoryA( NULL
, buffer
, &size
);
177 ok( !ret
&& size
> 0, "GetColorDirectoryA() succeeded (%d)\n", GetLastError() );
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)
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() );
209 ret
= pGetColorDirectoryW( NULL
, NULL
, &size
);
210 ok( !ret
&& size
> 0, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
214 ret
= pGetColorDirectoryW( NULL
, buffer
, &size
);
215 ok( !ret
&& size
> 0, "GetColorDirectoryW() succeeded (%d)\n", GetLastError() );
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( char *standardprofile
)
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() );
263 ret
= pGetColorProfileElement( handle
, tag
, 0, &size
, NULL
, &ref
);
264 ok( !ret
, "GetColorProfileElement() succeeded\n" );
265 ok( size
> 0, "wrong size\n" );
267 /* Functional checks */
269 size
= sizeof(buffer
);
270 ret
= pGetColorProfileElement( handle
, tag
, 0, &size
, buffer
, &ref
);
271 ok( ret
, "GetColorProfileElement() failed %u\n", GetLastError() );
272 ok( size
> 0, "wrong size\n" );
273 ok( !memcmp( buffer
, expect
, sizeof(expect
) ), "Unexpected tag data\n" );
275 pCloseColorProfile( handle
);
279 static void test_GetColorProfileElementTag( char *standardprofile
)
287 TAGTYPE tag
, expect
= 0x63707274; /* 'cprt' */
289 profile
.dwType
= PROFILE_FILENAME
;
290 profile
.pProfileData
= standardprofile
;
291 profile
.cbDataSize
= strlen(standardprofile
);
293 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
294 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
296 /* Parameter checks */
298 ret
= pGetColorProfileElementTag( NULL
, index
, &tag
);
299 ok( !ret
, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
301 ret
= pGetColorProfileElementTag( handle
, 0, &tag
);
302 ok( !ret
, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
304 ret
= pGetColorProfileElementTag( handle
, index
, NULL
);
305 ok( !ret
, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
307 ret
= pGetColorProfileElementTag( handle
, 18, NULL
);
308 ok( !ret
, "GetColorProfileElementTag() succeeded (%d)\n", GetLastError() );
310 /* Functional checks */
312 ret
= pGetColorProfileElementTag( handle
, index
, &tag
);
313 ok( ret
&& tag
== expect
, "GetColorProfileElementTag() failed (%d)\n",
316 pCloseColorProfile( handle
);
320 static void test_GetColorProfileFromHandle( char *testprofile
)
328 static const unsigned char expect
[] =
329 { 0x00, 0x00, 0x0c, 0x48, 0x4c, 0x69, 0x6e, 0x6f, 0x02, 0x10, 0x00,
330 0x00, 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59,
331 0x5a, 0x20, 0x07, 0xce, 0x00, 0x02, 0x00, 0x09, 0x00, 0x06, 0x00,
332 0x31, 0x00, 0x00, 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54,
333 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47,
334 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
335 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00,
336 0x00, 0xd3, 0x2d, 0x48, 0x50, 0x20, 0x20 };
338 unsigned char *buffer
;
340 profile
.dwType
= PROFILE_FILENAME
;
341 profile
.pProfileData
= testprofile
;
342 profile
.cbDataSize
= strlen(testprofile
);
344 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
345 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
347 /* Parameter checks */
351 ret
= pGetColorProfileFromHandle( handle
, NULL
, &size
);
352 ok( !ret
&& size
> 0, "GetColorProfileFromHandle() failed (%d)\n", GetLastError() );
354 buffer
= HeapAlloc( GetProcessHeap(), 0, size
);
358 ret
= pGetColorProfileFromHandle( NULL
, buffer
, &size
);
359 ok( !ret
, "GetColorProfileFromHandle() succeeded (%d)\n", GetLastError() );
361 ret
= pGetColorProfileFromHandle( handle
, buffer
, NULL
);
362 ok( !ret
, "GetColorProfileFromHandle() succeeded (%d)\n", GetLastError() );
364 /* Functional checks */
366 ret
= pGetColorProfileFromHandle( handle
, buffer
, &size
);
367 ok( ret
&& size
> 0, "GetColorProfileFromHandle() failed (%d)\n", GetLastError() );
369 ok( !memcmp( buffer
, expect
, sizeof(expect
) ), "Unexpected header data\n" );
371 HeapFree( GetProcessHeap(), 0, buffer
);
374 pCloseColorProfile( handle
);
378 static void test_GetColorProfileHeader( char *testprofile
)
385 PROFILEHEADER header
;
387 profile
.dwType
= PROFILE_FILENAME
;
388 profile
.pProfileData
= testprofile
;
389 profile
.cbDataSize
= strlen(testprofile
);
391 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
392 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
394 /* Parameter checks */
396 ret
= pGetColorProfileHeader( NULL
, NULL
);
397 ok( !ret
, "GetColorProfileHeader() succeeded (%d)\n", GetLastError() );
399 ret
= pGetColorProfileHeader( NULL
, &header
);
400 ok( !ret
, "GetColorProfileHeader() succeeded (%d)\n", GetLastError() );
402 if (0) /* Crashes on Vista */
404 ret
= pGetColorProfileHeader( handle
, NULL
);
405 ok( !ret
, "GetColorProfileHeader() succeeded (%d)\n", GetLastError() );
408 /* Functional checks */
410 ret
= pGetColorProfileHeader( handle
, &header
);
411 ok( ret
, "GetColorProfileHeader() failed (%d)\n", GetLastError() );
413 ok( !memcmp( &header
, rgbheader
, sizeof(rgbheader
) ), "Unexpected header data\n" );
415 pCloseColorProfile( handle
);
419 static void test_GetCountColorProfileElements( char *standardprofile
)
426 DWORD count
, expect
= 17;
428 profile
.dwType
= PROFILE_FILENAME
;
429 profile
.pProfileData
= standardprofile
;
430 profile
.cbDataSize
= strlen(standardprofile
);
432 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
433 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
435 /* Parameter checks */
437 ret
= pGetCountColorProfileElements( NULL
, &count
);
438 ok( !ret
, "GetCountColorProfileElements() succeeded (%d)\n",
441 ret
= pGetCountColorProfileElements( handle
, NULL
);
442 ok( !ret
, "GetCountColorProfileElements() succeeded (%d)\n",
445 /* Functional checks */
447 ret
= pGetCountColorProfileElements( handle
, &count
);
448 ok( ret
&& count
== expect
,
449 "GetCountColorProfileElements() failed (%d)\n", GetLastError() );
451 pCloseColorProfile( handle
);
455 static void test_GetStandardColorSpaceProfileA( char *standardprofile
)
459 CHAR oldprofile
[MAX_PATH
];
460 CHAR newprofile
[MAX_PATH
];
462 /* Parameter checks */
464 /* Single invalid parameter checks: */
466 size
= sizeof(newprofile
);
467 SetLastError(0xfaceabee); /* 1st param, */
468 ret
= pGetStandardColorSpaceProfileA(machine
, LCS_sRGB
, newprofile
, &size
);
469 ok( !ret
&& GetLastError() == ERROR_NOT_SUPPORTED
, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
471 size
= sizeof(newprofile
);
472 SetLastError(0xfaceabee); /* 2nd param, */
473 ret
= pGetStandardColorSpaceProfileA(NULL
, (DWORD
)-1, newprofile
, &size
);
474 ok( !ret
&& GetLastError() == ERROR_FILE_NOT_FOUND
, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
476 size
= sizeof(newprofile
);
477 SetLastError(0xfaceabee); /* 4th param, */
478 ret
= pGetStandardColorSpaceProfileA(NULL
, LCS_sRGB
, newprofile
, NULL
);
479 ok( !ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
481 size
= sizeof(newprofile
);
482 SetLastError(0xfaceabee); /* 3rd param, */
483 ret
= pGetStandardColorSpaceProfileA(NULL
, LCS_sRGB
, NULL
, &size
);
484 ok( !ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
487 SetLastError(0xfaceabee); /* dereferenced 4th param, */
488 ret
= pGetStandardColorSpaceProfileA(NULL
, LCS_sRGB
, newprofile
, &size
);
489 ok( !ret
&& (GetLastError() == ERROR_MORE_DATA
|| GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
490 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
492 /* Several invalid parameter checks: */
495 SetLastError(0xfaceabee); /* 1st, maybe 2nd and then dereferenced 4th param, */
496 ret
= pGetStandardColorSpaceProfileA(machine
, 0, newprofile
, &size
);
497 ok( !ret
&& (GetLastError() == ERROR_INVALID_PARAMETER
|| GetLastError() == ERROR_NOT_SUPPORTED
),
498 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
500 SetLastError(0xfaceabee); /* maybe 2nd and then 4th param, */
501 ret
= pGetStandardColorSpaceProfileA(NULL
, 0, newprofile
, NULL
);
502 ok( !ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
505 SetLastError(0xfaceabee); /* maybe 2nd, then 3rd and dereferenced 4th param, */
506 ret
= pGetStandardColorSpaceProfileA(NULL
, 0, NULL
, &size
);
507 ok( !ret
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
|| GetLastError() == ERROR_FILE_NOT_FOUND
),
508 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
510 size
= sizeof(newprofile
);
511 SetLastError(0xfaceabee); /* maybe 2nd param. */
512 ret
= pGetStandardColorSpaceProfileA(NULL
, 0, newprofile
, &size
);
513 if (!ret
) ok( GetLastError() == ERROR_FILE_NOT_FOUND
, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
514 else ok( !lstrcmpiA( newprofile
, "" ) && GetLastError() == 0xfaceabee,
515 "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret
, GetLastError() );
517 /* Functional checks */
519 size
= sizeof(oldprofile
);
520 ret
= pGetStandardColorSpaceProfileA( NULL
, LCS_sRGB
, oldprofile
, &size
);
521 ok( ret
, "GetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
523 SetLastError(0xdeadbeef);
524 ret
= pSetStandardColorSpaceProfileA( NULL
, LCS_sRGB
, standardprofile
);
525 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
527 skip("Not enough rights for SetStandardColorSpaceProfileA\n");
530 ok( ret
, "SetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
532 size
= sizeof(newprofile
);
533 ret
= pGetStandardColorSpaceProfileA( NULL
, LCS_sRGB
, newprofile
, &size
);
534 ok( ret
, "GetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
536 ret
= pSetStandardColorSpaceProfileA( NULL
, LCS_sRGB
, oldprofile
);
537 ok( ret
, "SetStandardColorSpaceProfileA() failed (%d)\n", GetLastError() );
540 static void test_GetStandardColorSpaceProfileW( WCHAR
*standardprofileW
)
544 WCHAR oldprofile
[MAX_PATH
];
545 WCHAR newprofile
[MAX_PATH
];
546 CHAR newprofileA
[MAX_PATH
];
548 /* Parameter checks */
550 /* Single invalid parameter checks: */
552 size
= sizeof(newprofile
);
553 SetLastError(0xfaceabee); /* 1st param, */
554 ret
= pGetStandardColorSpaceProfileW(machineW
, LCS_sRGB
, newprofile
, &size
);
555 ok( !ret
&& GetLastError() == ERROR_NOT_SUPPORTED
, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret
, GetLastError() );
557 size
= sizeof(newprofile
);
558 SetLastError(0xfaceabee); /* 2nd param, */
559 ret
= pGetStandardColorSpaceProfileW(NULL
, (DWORD
)-1, newprofile
, &size
);
560 ok( !ret
&& GetLastError() == ERROR_FILE_NOT_FOUND
, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret
, GetLastError() );
562 size
= sizeof(newprofile
);
563 SetLastError(0xfaceabee); /* 2nd param, */
564 ret
= pGetStandardColorSpaceProfileW(NULL
, 0, newprofile
, &size
);
565 ok( (!ret
&& GetLastError() == ERROR_FILE_NOT_FOUND
) ||
566 broken(ret
), /* Win98 and WinME */
567 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret
, GetLastError() );
569 size
= sizeof(newprofile
);
570 SetLastError(0xfaceabee); /* 3rd param, */
571 ret
= pGetStandardColorSpaceProfileW(NULL
, LCS_sRGB
, NULL
, &size
);
572 ok( !ret
|| broken(ret
) /* win98 */, "GetStandardColorSpaceProfileW succeeded\n" );
573 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER
||
574 broken(GetLastError() == 0xfaceabee) /* win98 */,
575 "GetStandardColorSpaceProfileW() returns GLE=%u\n", GetLastError() );
577 size
= sizeof(newprofile
);
578 SetLastError(0xfaceabee); /* 4th param, */
579 ret
= pGetStandardColorSpaceProfileW(NULL
, LCS_sRGB
, newprofile
, NULL
);
580 ok( !ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret
, GetLastError() );
583 SetLastError(0xfaceabee); /* dereferenced 4th param. */
584 ret
= pGetStandardColorSpaceProfileW(NULL
, LCS_sRGB
, newprofile
, &size
);
585 ok( !ret
|| broken(ret
) /* win98 */, "GetStandardColorSpaceProfileW succeeded\n" );
586 ok( GetLastError() == ERROR_MORE_DATA
||
587 GetLastError() == ERROR_INSUFFICIENT_BUFFER
||
588 broken(GetLastError() == 0xfaceabee) /* win98 */,
589 "GetStandardColorSpaceProfileW() returns GLE=%u\n", GetLastError() );
591 /* Several invalid parameter checks: */
594 SetLastError(0xfaceabee); /* 1st, maybe 2nd and then dereferenced 4th param, */
595 ret
= pGetStandardColorSpaceProfileW(machineW
, 0, newprofile
, &size
);
596 ok( !ret
&& (GetLastError() == ERROR_INVALID_PARAMETER
|| GetLastError() == ERROR_NOT_SUPPORTED
),
597 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret
, GetLastError() );
599 SetLastError(0xfaceabee); /* maybe 2nd and then 4th param, */
600 ret
= pGetStandardColorSpaceProfileW(NULL
, 0, newprofile
, NULL
);
601 ok( !ret
&& GetLastError() == ERROR_INVALID_PARAMETER
, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret
, GetLastError() );
604 SetLastError(0xfaceabee); /* maybe 2nd, then 3rd and dereferenced 4th param, */
605 ret
= pGetStandardColorSpaceProfileW(NULL
, 0, NULL
, &size
);
606 ok( !ret
|| broken(ret
) /* win98 */, "GetStandardColorSpaceProfileW succeeded\n" );
607 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER
||
608 GetLastError() == ERROR_FILE_NOT_FOUND
||
609 broken(GetLastError() == 0xfaceabee) /* win98 */,
610 "GetStandardColorSpaceProfileW() returns GLE=%u\n", GetLastError() );
612 size
= sizeof(newprofile
);
613 SetLastError(0xfaceabee); /* maybe 2nd param. */
614 ret
= pGetStandardColorSpaceProfileW(NULL
, 0, newprofile
, &size
);
615 if (!ret
) ok( GetLastError() == ERROR_FILE_NOT_FOUND
, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret
, GetLastError() );
618 WideCharToMultiByte(CP_ACP
, 0, newprofile
, -1, newprofileA
, sizeof(newprofileA
), NULL
, NULL
);
619 ok( !lstrcmpiA( newprofileA
, "" ) && GetLastError() == 0xfaceabee,
620 "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret
, GetLastError() );
623 /* Functional checks */
625 size
= sizeof(oldprofile
);
626 ret
= pGetStandardColorSpaceProfileW( NULL
, LCS_sRGB
, oldprofile
, &size
);
627 ok( ret
, "GetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
629 SetLastError(0xdeadbeef);
630 ret
= pSetStandardColorSpaceProfileW( NULL
, LCS_sRGB
, standardprofileW
);
631 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
633 skip("Not enough rights for SetStandardColorSpaceProfileW\n");
636 ok( ret
, "SetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
638 size
= sizeof(newprofile
);
639 ret
= pGetStandardColorSpaceProfileW( NULL
, LCS_sRGB
, newprofile
, &size
);
640 ok( ret
, "GetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
642 ret
= pSetStandardColorSpaceProfileW( NULL
, LCS_sRGB
, oldprofile
);
643 ok( ret
, "SetStandardColorSpaceProfileW() failed (%d)\n", GetLastError() );
646 static void test_EnumColorProfilesA( char *standardprofile
)
649 DWORD total
, size
, number
;
653 /* Parameter checks */
655 memset( &record
, 0, sizeof(ENUMTYPEA
) );
657 record
.dwSize
= sizeof(ENUMTYPEA
);
658 record
.dwVersion
= ENUM_TYPE_VERSION
;
659 record
.dwFields
|= ET_DATACOLORSPACE
;
660 record
.dwDataColorSpace
= SPACE_RGB
;
663 ret
= pEnumColorProfilesA( NULL
, &record
, NULL
, &total
, &number
);
664 ok( !ret
, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
665 buffer
= HeapAlloc( GetProcessHeap(), 0, total
);
668 ret
= pEnumColorProfilesA( machine
, &record
, buffer
, &size
, &number
);
669 ok( !ret
, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
671 ret
= pEnumColorProfilesA( NULL
, NULL
, buffer
, &size
, &number
);
672 ok( !ret
, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
674 ret
= pEnumColorProfilesA( NULL
, &record
, buffer
, NULL
, &number
);
675 ok( !ret
, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
677 ret
= pEnumColorProfilesA( NULL
, &record
, buffer
, &size
, &number
);
678 if (have_color_profile
)
679 ok( ret
, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
681 todo_wine
ok( ret
, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
685 ret
= pEnumColorProfilesA( NULL
, &record
, buffer
, &size
, &number
);
686 ok( !ret
, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
688 /* Functional checks */
691 ret
= pEnumColorProfilesA( NULL
, &record
, buffer
, &size
, &number
);
692 if (have_color_profile
)
693 ok( ret
, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
695 todo_wine
ok( ret
, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
697 HeapFree( GetProcessHeap(), 0, buffer
);
700 static void test_EnumColorProfilesW( WCHAR
*standardprofileW
)
703 DWORD total
, size
, number
;
707 /* Parameter checks */
709 memset( &record
, 0, sizeof(ENUMTYPEW
) );
711 record
.dwSize
= sizeof(ENUMTYPEW
);
712 record
.dwVersion
= ENUM_TYPE_VERSION
;
713 record
.dwFields
|= ET_DATACOLORSPACE
;
714 record
.dwDataColorSpace
= SPACE_RGB
;
717 ret
= pEnumColorProfilesW( NULL
, &record
, NULL
, &total
, &number
);
718 ok( !ret
, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
719 buffer
= HeapAlloc( GetProcessHeap(), 0, total
* sizeof(WCHAR
) );
722 ret
= pEnumColorProfilesW( machineW
, &record
, buffer
, &size
, &number
);
723 ok( !ret
, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
725 ret
= pEnumColorProfilesW( NULL
, NULL
, buffer
, &size
, &number
);
726 ok( !ret
, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
728 ret
= pEnumColorProfilesW( NULL
, &record
, buffer
, NULL
, &number
);
729 ok( !ret
, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
731 ret
= pEnumColorProfilesW( NULL
, &record
, buffer
, &size
, &number
);
732 if (have_color_profile
)
733 ok( ret
, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
735 todo_wine
ok( ret
, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
738 ret
= pEnumColorProfilesW( NULL
, &record
, buffer
, &size
, &number
);
739 ok( !ret
, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
741 /* Functional checks */
744 ret
= pEnumColorProfilesW( NULL
, &record
, buffer
, &size
, &number
);
745 if (have_color_profile
)
746 ok( ret
, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
748 todo_wine
ok( ret
, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
750 HeapFree( GetProcessHeap(), 0, buffer
);
753 static void test_InstallColorProfileA( char *standardprofile
, char *testprofile
)
757 /* Parameter checks */
759 ret
= pInstallColorProfileA( NULL
, NULL
);
760 ok( !ret
, "InstallColorProfileA() succeeded (%d)\n", GetLastError() );
762 ret
= pInstallColorProfileA( machine
, NULL
);
763 ok( !ret
, "InstallColorProfileA() succeeded (%d)\n", GetLastError() );
765 ret
= pInstallColorProfileA( NULL
, machine
);
766 ok( !ret
, "InstallColorProfileA() succeeded (%d)\n", GetLastError() );
770 ret
= pInstallColorProfileA( NULL
, standardprofile
);
771 ok( ret
, "InstallColorProfileA() failed (%d)\n", GetLastError() );
774 /* Functional checks */
778 CHAR dest
[MAX_PATH
], base
[MAX_PATH
];
779 DWORD size
= sizeof(dest
);
783 SetLastError(0xdeadbeef);
784 ret
= pInstallColorProfileA( NULL
, testprofile
);
785 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
787 skip("Not enough rights for InstallColorProfileA\n");
790 ok( ret
, "InstallColorProfileA() failed (%d)\n", GetLastError() );
792 ret
= pGetColorDirectoryA( NULL
, dest
, &size
);
793 ok( ret
, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
795 MSCMS_basenameA( testprofile
, base
);
797 lstrcatA( dest
, slash
);
798 lstrcatA( dest
, base
);
800 /* Check if the profile is really there */
801 handle
= CreateFileA( dest
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
802 ok( handle
!= INVALID_HANDLE_VALUE
, "Couldn't find the profile (%d)\n", GetLastError() );
803 CloseHandle( handle
);
805 ret
= pUninstallColorProfileA( NULL
, dest
, TRUE
);
806 ok( ret
, "UninstallColorProfileA() failed (%d)\n", GetLastError() );
810 static void test_InstallColorProfileW( WCHAR
*standardprofileW
, WCHAR
*testprofileW
)
814 /* Parameter checks */
816 ret
= pInstallColorProfileW( NULL
, NULL
);
817 ok( !ret
, "InstallColorProfileW() succeeded (%d)\n", GetLastError() );
819 ret
= pInstallColorProfileW( machineW
, NULL
);
820 ok( !ret
, "InstallColorProfileW() succeeded (%d)\n", GetLastError() );
822 ret
= pInstallColorProfileW( NULL
, machineW
);
823 ok( !ret
, "InstallColorProfileW() failed (%d)\n", GetLastError() );
825 if (standardprofileW
)
827 ret
= pInstallColorProfileW( NULL
, standardprofileW
);
828 ok( ret
, "InstallColorProfileW() failed (%d)\n", GetLastError() );
831 /* Functional checks */
835 WCHAR dest
[MAX_PATH
], base
[MAX_PATH
];
836 DWORD size
= sizeof(dest
);
837 WCHAR slash
[] = { '\\', 0 };
840 SetLastError(0xdeadbeef);
841 ret
= pInstallColorProfileW( NULL
, testprofileW
);
842 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
844 skip("Not enough rights for InstallColorProfileW\n");
847 ok( ret
, "InstallColorProfileW() failed (%d)\n", GetLastError() );
849 ret
= pGetColorDirectoryW( NULL
, dest
, &size
);
850 ok( ret
, "GetColorDirectoryW() failed (%d)\n", GetLastError() );
852 MSCMS_basenameW( testprofileW
, base
);
854 lstrcatW( dest
, slash
);
855 lstrcatW( dest
, base
);
857 /* Check if the profile is really there */
858 handle
= CreateFileW( dest
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
859 ok( handle
!= INVALID_HANDLE_VALUE
, "Couldn't find the profile (%d)\n", GetLastError() );
860 CloseHandle( handle
);
862 ret
= pUninstallColorProfileW( NULL
, dest
, TRUE
);
863 ok( ret
, "UninstallColorProfileW() failed (%d)\n", GetLastError() );
867 static void test_IsColorProfileTagPresent( char *standardprofile
)
876 profile
.dwType
= PROFILE_FILENAME
;
877 profile
.pProfileData
= standardprofile
;
878 profile
.cbDataSize
= strlen(standardprofile
);
880 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
881 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
883 /* Parameter checks */
887 ret
= pIsColorProfileTagPresent( handle
, tag
, &present
);
888 ok( !(ret
&& present
), "IsColorProfileTagPresent() succeeded (%d)\n", GetLastError() );
890 tag
= 0x63707274; /* 'cprt' */
892 ret
= pIsColorProfileTagPresent( NULL
, tag
, &present
);
893 ok( !ret
, "IsColorProfileTagPresent() succeeded (%d)\n", GetLastError() );
895 ret
= pIsColorProfileTagPresent( handle
, tag
, NULL
);
896 ok( !ret
, "IsColorProfileTagPresent() succeeded (%d)\n", GetLastError() );
898 /* Functional checks */
900 ret
= pIsColorProfileTagPresent( handle
, tag
, &present
);
901 ok( ret
&& present
, "IsColorProfileTagPresent() failed (%d)\n", GetLastError() );
903 pCloseColorProfile( handle
);
907 static void test_OpenColorProfileA( char *standardprofile
)
913 profile
.dwType
= PROFILE_FILENAME
;
914 profile
.pProfileData
= NULL
;
915 profile
.cbDataSize
= 0;
917 /* Parameter checks */
919 handle
= pOpenColorProfileA( NULL
, 0, 0, 0 );
920 ok( handle
== NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
922 handle
= pOpenColorProfileA( &profile
, 0, 0, 0 );
923 ok( handle
== NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
925 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, 0 );
926 ok( handle
== NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
928 handle
= pOpenColorProfileA( &profile
, PROFILE_READWRITE
, 0, 0 );
929 ok( handle
== NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
931 ok ( !pCloseColorProfile( NULL
), "CloseColorProfile() succeeded\n" );
935 profile
.pProfileData
= standardprofile
;
936 profile
.cbDataSize
= strlen(standardprofile
);
938 handle
= pOpenColorProfileA( &profile
, 0, 0, 0 );
939 ok( handle
== NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
941 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, 0 );
942 ok( handle
== NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
944 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
|PROFILE_READWRITE
, 0, 0 );
945 ok( handle
== NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
947 /* Functional checks */
949 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
950 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
952 ret
= pCloseColorProfile( handle
);
953 ok( ret
, "CloseColorProfile() failed (%d)\n", GetLastError() );
955 profile
.dwType
= PROFILE_FILENAME
;
956 profile
.pProfileData
= (void *)"sRGB Color Space Profile.icm";
957 profile
.cbDataSize
= sizeof("sRGB Color Space Profile.icm");
959 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, FILE_SHARE_READ
, OPEN_EXISTING
);
960 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
962 ret
= pCloseColorProfile( handle
);
963 ok( ret
, "CloseColorProfile() failed (%d)\n", GetLastError() );
967 static void test_OpenColorProfileW( WCHAR
*standardprofileW
)
973 profile
.dwType
= PROFILE_FILENAME
;
974 profile
.pProfileData
= NULL
;
975 profile
.cbDataSize
= 0;
977 /* Parameter checks */
979 handle
= pOpenColorProfileW( NULL
, 0, 0, 0 );
980 ok( handle
== NULL
, "OpenColorProfileW() failed (%d)\n", GetLastError() );
982 handle
= pOpenColorProfileW( &profile
, 0, 0, 0 );
983 ok( handle
== NULL
, "OpenColorProfileW() failed (%d)\n", GetLastError() );
985 handle
= pOpenColorProfileW( &profile
, PROFILE_READ
, 0, 0 );
986 ok( handle
== NULL
, "OpenColorProfileW() failed (%d)\n", GetLastError() );
988 handle
= pOpenColorProfileW( &profile
, PROFILE_READWRITE
, 0, 0 );
989 ok( handle
== NULL
, "OpenColorProfileW() failed (%d)\n", GetLastError() );
991 ok ( !pCloseColorProfile( NULL
), "CloseColorProfile() succeeded\n" );
993 if (standardprofileW
)
995 profile
.pProfileData
= standardprofileW
;
996 profile
.cbDataSize
= lstrlenW(standardprofileW
) * sizeof(WCHAR
);
998 handle
= pOpenColorProfileW( &profile
, 0, 0, 0 );
999 ok( handle
== NULL
, "OpenColorProfileW() failed (%d)\n", GetLastError() );
1001 handle
= pOpenColorProfileW( &profile
, PROFILE_READ
, 0, 0 );
1002 ok( handle
== NULL
, "OpenColorProfileW() failed (%d)\n", GetLastError() );
1004 handle
= pOpenColorProfileW( &profile
, PROFILE_READ
|PROFILE_READWRITE
, 0, 0 );
1005 ok( handle
== NULL
, "OpenColorProfileW() failed (%d)\n", GetLastError() );
1007 /* Functional checks */
1009 handle
= pOpenColorProfileW( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
1010 ok( handle
!= NULL
, "OpenColorProfileW() failed (%d)\n", GetLastError() );
1012 ret
= pCloseColorProfile( handle
);
1013 ok( ret
, "CloseColorProfile() failed (%d)\n", GetLastError() );
1017 static void test_SetColorProfileElement( char *testprofile
)
1026 TAGTYPE tag
= 0x63707274; /* 'cprt' */
1027 static char data
[] = "(c) The Wine Project";
1028 static char buffer
[51];
1030 profile
.dwType
= PROFILE_FILENAME
;
1031 profile
.pProfileData
= testprofile
;
1032 profile
.cbDataSize
= strlen(testprofile
);
1034 /* Parameter checks */
1036 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
1037 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1039 ret
= pSetColorProfileElement( handle
, tag
, 0, &size
, data
);
1040 ok( !ret
, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1042 pCloseColorProfile( handle
);
1044 handle
= pOpenColorProfileA( &profile
, PROFILE_READWRITE
, 0, OPEN_EXISTING
);
1045 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1047 ret
= pSetColorProfileElement( NULL
, 0, 0, NULL
, NULL
);
1048 ok( !ret
, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1050 ret
= pSetColorProfileElement( handle
, 0, 0, NULL
, NULL
);
1051 ok( !ret
, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1053 ret
= pSetColorProfileElement( handle
, tag
, 0, NULL
, NULL
);
1054 ok( !ret
, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1056 ret
= pSetColorProfileElement( handle
, tag
, 0, &size
, NULL
);
1057 ok( !ret
, "SetColorProfileElement() succeeded (%d)\n", GetLastError() );
1059 /* Functional checks */
1061 size
= sizeof(data
);
1062 ret
= pSetColorProfileElement( handle
, tag
, 0, &size
, data
);
1063 ok( ret
, "SetColorProfileElement() failed %u\n", GetLastError() );
1065 size
= sizeof(buffer
);
1066 ret
= pGetColorProfileElement( handle
, tag
, 0, &size
, buffer
, &ref
);
1067 ok( ret
, "GetColorProfileElement() failed %u\n", GetLastError() );
1068 ok( size
> 0, "wrong size\n" );
1070 ok( !memcmp( data
, buffer
, sizeof(data
) ),
1071 "Unexpected tag data, expected %s, got %s (%u)\n", data
, buffer
, GetLastError() );
1073 pCloseColorProfile( handle
);
1077 static void test_SetColorProfileHeader( char *testprofile
)
1084 PROFILEHEADER header
;
1086 profile
.dwType
= PROFILE_FILENAME
;
1087 profile
.pProfileData
= testprofile
;
1088 profile
.cbDataSize
= strlen(testprofile
);
1090 header
.phSize
= 0x00000c48;
1091 header
.phCMMType
= 0x4c696e6f;
1092 header
.phVersion
= 0x02100000;
1093 header
.phClass
= 0x6d6e7472;
1094 header
.phDataColorSpace
= 0x52474220;
1095 header
.phConnectionSpace
= 0x58595a20;
1096 header
.phDateTime
[0] = 0x07ce0002;
1097 header
.phDateTime
[1] = 0x00090006;
1098 header
.phDateTime
[2] = 0x00310000;
1099 header
.phSignature
= 0x61637370;
1100 header
.phPlatform
= 0x4d534654;
1101 header
.phProfileFlags
= 0x00000000;
1102 header
.phManufacturer
= 0x49454320;
1103 header
.phModel
= 0x73524742;
1104 header
.phAttributes
[0] = 0x00000000;
1105 header
.phAttributes
[1] = 0x00000000;
1106 header
.phRenderingIntent
= 0x00000000;
1107 header
.phIlluminant
.ciexyzX
= 0x0000f6d6;
1108 header
.phIlluminant
.ciexyzY
= 0x00010000;
1109 header
.phIlluminant
.ciexyzZ
= 0x0000d32d;
1110 header
.phCreator
= 0x48502020;
1112 /* Parameter checks */
1114 handle
= pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
1115 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1117 ret
= pSetColorProfileHeader( handle
, &header
);
1118 ok( !ret
, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1120 pCloseColorProfile( handle
);
1122 handle
= pOpenColorProfileA( &profile
, PROFILE_READWRITE
, 0, OPEN_EXISTING
);
1123 ok( handle
!= NULL
, "OpenColorProfileA() failed (%d)\n", GetLastError() );
1125 ret
= pSetColorProfileHeader( NULL
, NULL
);
1126 ok( !ret
, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1128 ret
= pSetColorProfileHeader( handle
, NULL
);
1129 ok( !ret
, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1131 ret
= pSetColorProfileHeader( NULL
, &header
);
1132 ok( !ret
, "SetColorProfileHeader() succeeded (%d)\n", GetLastError() );
1134 /* Functional checks */
1136 ret
= pSetColorProfileHeader( handle
, &header
);
1137 ok( ret
, "SetColorProfileHeader() failed (%d)\n", GetLastError() );
1139 ret
= pGetColorProfileHeader( handle
, &header
);
1140 ok( ret
, "GetColorProfileHeader() failed (%d)\n", GetLastError() );
1142 ok( !memcmp( &header
, rgbheader
, sizeof(rgbheader
) ), "Unexpected header data\n" );
1144 pCloseColorProfile( handle
);
1148 static void test_UninstallColorProfileA( char *testprofile
)
1152 /* Parameter checks */
1154 ret
= pUninstallColorProfileA( NULL
, NULL
, FALSE
);
1155 ok( !ret
, "UninstallColorProfileA() succeeded (%d)\n", GetLastError() );
1157 ret
= pUninstallColorProfileA( machine
, NULL
, FALSE
);
1158 ok( !ret
, "UninstallColorProfileA() succeeded (%d)\n", GetLastError() );
1160 /* Functional checks */
1164 CHAR dest
[MAX_PATH
], base
[MAX_PATH
];
1165 DWORD size
= sizeof(dest
);
1166 CHAR slash
[] = "\\";
1169 SetLastError(0xdeadbeef);
1170 ret
= pInstallColorProfileA( NULL
, testprofile
);
1171 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
1173 skip("Not enough rights for InstallColorProfileA\n");
1176 ok( ret
, "InstallColorProfileA() failed (%d)\n", GetLastError() );
1178 ret
= pGetColorDirectoryA( NULL
, dest
, &size
);
1179 ok( ret
, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
1181 MSCMS_basenameA( testprofile
, base
);
1183 lstrcatA( dest
, slash
);
1184 lstrcatA( dest
, base
);
1186 ret
= pUninstallColorProfileA( NULL
, dest
, TRUE
);
1187 ok( ret
, "UninstallColorProfileA() failed (%d)\n", GetLastError() );
1189 /* Check if the profile is really gone */
1190 handle
= CreateFileA( dest
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
1191 ok( handle
== INVALID_HANDLE_VALUE
, "Found the profile (%d)\n", GetLastError() );
1192 CloseHandle( handle
);
1196 static void test_UninstallColorProfileW( WCHAR
*testprofileW
)
1200 /* Parameter checks */
1202 ret
= pUninstallColorProfileW( NULL
, NULL
, FALSE
);
1203 ok( !ret
, "UninstallColorProfileW() succeeded (%d)\n", GetLastError() );
1205 ret
= pUninstallColorProfileW( machineW
, NULL
, FALSE
);
1206 ok( !ret
, "UninstallColorProfileW() succeeded (%d)\n", GetLastError() );
1208 /* Functional checks */
1212 WCHAR dest
[MAX_PATH
], base
[MAX_PATH
];
1213 char destA
[MAX_PATH
];
1214 DWORD size
= sizeof(dest
);
1215 WCHAR slash
[] = { '\\', 0 };
1219 SetLastError(0xdeadbeef);
1220 ret
= pInstallColorProfileW( NULL
, testprofileW
);
1221 if (!ret
&& (GetLastError() == ERROR_ACCESS_DENIED
))
1223 skip("Not enough rights for InstallColorProfileW\n");
1226 ok( ret
, "InstallColorProfileW() failed (%d)\n", GetLastError() );
1228 ret
= pGetColorDirectoryW( NULL
, dest
, &size
);
1229 ok( ret
, "GetColorDirectoryW() failed (%d)\n", GetLastError() );
1231 MSCMS_basenameW( testprofileW
, base
);
1233 lstrcatW( dest
, slash
);
1234 lstrcatW( dest
, base
);
1236 ret
= pUninstallColorProfileW( NULL
, dest
, TRUE
);
1237 ok( ret
, "UninstallColorProfileW() failed (%d)\n", GetLastError() );
1239 bytes_copied
= WideCharToMultiByte(CP_ACP
, 0, dest
, -1, destA
, MAX_PATH
, NULL
, NULL
);
1240 ok( bytes_copied
> 0 , "WideCharToMultiByte() returns %d\n", bytes_copied
);
1241 /* Check if the profile is really gone */
1242 handle
= CreateFileA( destA
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
1243 ok( handle
== INVALID_HANDLE_VALUE
, "Found the profile (%d)\n", GetLastError() );
1244 CloseHandle( handle
);
1248 static void test_AssociateColorProfileWithDeviceA( char *testprofile
)
1251 char profile
[MAX_PATH
], basename
[MAX_PATH
];
1252 DWORD error
, size
= sizeof(profile
);
1253 DISPLAY_DEVICEA display
, monitor
;
1256 if (testprofile
&& pEnumDisplayDevicesA
)
1258 display
.cb
= sizeof( DISPLAY_DEVICEA
);
1259 res
= pEnumDisplayDevicesA( NULL
, 0, &display
, 0 );
1260 ok( res
, "Can't get display info\n" );
1262 monitor
.cb
= sizeof( DISPLAY_DEVICEA
);
1263 res
= pEnumDisplayDevicesA( display
.DeviceName
, 0, &monitor
, 0 );
1266 SetLastError(0xdeadbeef);
1267 ret
= pAssociateColorProfileWithDeviceA( "machine", testprofile
, NULL
);
1268 error
= GetLastError();
1269 ok( !ret
, "AssociateColorProfileWithDevice() succeeded\n" );
1270 ok( error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
1272 SetLastError(0xdeadbeef);
1273 ret
= pAssociateColorProfileWithDeviceA( "machine", NULL
, monitor
.DeviceID
);
1274 error
= GetLastError();
1275 ok( !ret
, "AssociateColorProfileWithDevice() succeeded\n" );
1276 ok( error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
1278 SetLastError(0xdeadbeef);
1279 ret
= pAssociateColorProfileWithDeviceA( "machine", testprofile
, monitor
.DeviceID
);
1280 error
= GetLastError();
1281 ok( !ret
, "AssociateColorProfileWithDevice() succeeded\n" );
1282 ok( error
== ERROR_NOT_SUPPORTED
, "expected ERROR_NOT_SUPPORTED, got %u\n", error
);
1284 ret
= pInstallColorProfileA( NULL
, testprofile
);
1285 ok( ret
, "InstallColorProfileA() failed (%u)\n", GetLastError() );
1287 ret
= pGetColorDirectoryA( NULL
, profile
, &size
);
1288 ok( ret
, "GetColorDirectoryA() failed (%d)\n", GetLastError() );
1290 MSCMS_basenameA( testprofile
, basename
);
1291 lstrcatA( profile
, "\\" );
1292 lstrcatA( profile
, basename
);
1294 ret
= pAssociateColorProfileWithDeviceA( NULL
, profile
, monitor
.DeviceID
);
1295 ok( ret
, "AssociateColorProfileWithDevice() failed (%u)\n", GetLastError() );
1297 SetLastError(0xdeadbeef);
1298 ret
= pDisassociateColorProfileFromDeviceA( "machine", profile
, NULL
);
1299 error
= GetLastError();
1300 ok( !ret
, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1301 ok( error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
1303 SetLastError(0xdeadbeef);
1304 ret
= pDisassociateColorProfileFromDeviceA( "machine", NULL
, monitor
.DeviceID
);
1305 error
= GetLastError();
1306 ok( !ret
, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1307 ok( error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", error
);
1309 SetLastError(0xdeadbeef);
1310 ret
= pDisassociateColorProfileFromDeviceA( "machine", profile
, monitor
.DeviceID
);
1311 error
= GetLastError();
1312 ok( !ret
, "DisassociateColorProfileFromDeviceA() succeeded\n" );
1313 ok( error
== ERROR_NOT_SUPPORTED
, "expected ERROR_NOT_SUPPORTED, got %u\n", error
);
1315 ret
= pDisassociateColorProfileFromDeviceA( NULL
, profile
, monitor
.DeviceID
);
1316 ok( ret
, "DisassociateColorProfileFromDeviceA() failed (%u)\n", GetLastError() );
1318 ret
= pUninstallColorProfileA( NULL
, profile
, TRUE
);
1319 ok( ret
, "UninstallColorProfileA() failed (%d)\n", GetLastError() );
1322 skip("Unable to obtain monitor name\n");
1326 static BOOL
have_profile(void)
1328 char glob
[MAX_PATH
+ sizeof("\\*.icm")];
1329 DWORD size
= MAX_PATH
;
1331 WIN32_FIND_DATAA data
;
1333 if (!pGetColorDirectoryA( NULL
, glob
, &size
)) return FALSE
;
1334 lstrcatA( glob
, "\\*.icm" );
1335 handle
= FindFirstFileA( glob
, &data
);
1336 if (handle
== INVALID_HANDLE_VALUE
) return FALSE
;
1337 FindClose( handle
);
1341 static void test_CreateMultiProfileTransform( char *standardprofile
, char *testprofile
)
1345 HTRANSFORM transform
;
1346 DWORD intents
[2] = { INTENT_PERCEPTUAL
, INTENT_PERCEPTUAL
};
1350 profile
.dwType
= PROFILE_FILENAME
;
1351 profile
.pProfileData
= standardprofile
;
1352 profile
.cbDataSize
= strlen(standardprofile
);
1354 handle
[0] = pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
1355 ok( handle
[0] != NULL
, "got %u\n", GetLastError() );
1357 profile
.dwType
= PROFILE_FILENAME
;
1358 profile
.pProfileData
= testprofile
;
1359 profile
.cbDataSize
= strlen(testprofile
);
1361 handle
[1] = pOpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
1362 ok( handle
[1] != NULL
, "got %u\n", GetLastError() );
1364 transform
= pCreateMultiProfileTransform( handle
, 2, intents
, 2, 0, 0 );
1365 ok( transform
!= NULL
, "got %u\n", GetLastError() );
1367 pDeleteColorTransform( transform
);
1368 pCloseColorProfile( handle
[0] );
1369 pCloseColorProfile( handle
[1] );
1377 char path
[MAX_PATH
], file
[MAX_PATH
], profilefile1
[MAX_PATH
], profilefile2
[MAX_PATH
];
1378 WCHAR profilefile1W
[MAX_PATH
], profilefile2W
[MAX_PATH
], fileW
[MAX_PATH
];
1379 char *standardprofile
= NULL
, *testprofile
= NULL
;
1380 WCHAR
*standardprofileW
= NULL
, *testprofileW
= NULL
;
1383 hmscms
= LoadLibraryA( "mscms.dll" );
1384 if (!hmscms
) return;
1386 huser32
= LoadLibraryA( "user32.dll" );
1389 FreeLibrary( hmscms
);
1393 if (!init_function_ptrs())
1395 FreeLibrary( huser32
);
1396 FreeLibrary( hmscms
);
1400 /* See if we can find the standard color profile */
1401 ret
= GetSystemDirectoryA( profilefile1
, sizeof(profilefile1
) );
1402 ok( ret
> 0, "GetSystemDirectoryA() returns %d, LastError = %d\n", ret
, GetLastError());
1403 ok(profilefile1
[0] && lstrlenA(profilefile1
) < MAX_PATH
,
1404 "Expected length between 0 and MAX_PATH, got %d\n", lstrlenA(profilefile1
));
1405 MultiByteToWideChar(CP_ACP
, 0, profilefile1
, -1, profilefile1W
, MAX_PATH
);
1406 ok(profilefile1W
[0] && lstrlenW(profilefile1W
) < MAX_PATH
,
1407 "Expected length between 0 and MAX_PATH, got %d\n", lstrlenW(profilefile1W
));
1408 lstrcpyA(profilefile2
, profilefile1
);
1409 lstrcpyW(profilefile2W
, profilefile1W
);
1411 lstrcatA( profilefile1
, profile1
);
1412 lstrcatW( profilefile1W
, profile1W
);
1413 handle
= CreateFileA( profilefile1
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
1415 if (handle
!= INVALID_HANDLE_VALUE
)
1417 standardprofile
= profilefile1
;
1418 standardprofileW
= profilefile1W
;
1419 CloseHandle( handle
);
1422 lstrcatA( profilefile2
, profile2
);
1423 lstrcatW( profilefile2W
, profile2W
);
1424 handle
= CreateFileA( profilefile2
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
1426 if (handle
!= INVALID_HANDLE_VALUE
)
1428 standardprofile
= profilefile2
;
1429 standardprofileW
= profilefile2W
;
1430 CloseHandle( handle
);
1433 /* If found, create a temporary copy for testing purposes */
1434 if (standardprofile
&& GetTempPathA( sizeof(path
), path
))
1436 if (GetTempFileNameA( path
, "rgb", 0, file
))
1438 if (CopyFileA( standardprofile
, file
, FALSE
))
1440 testprofile
= (LPSTR
)&file
;
1441 len
= MultiByteToWideChar( CP_ACP
, 0, testprofile
, -1, NULL
, 0 );
1442 MultiByteToWideChar( CP_ACP
, 0, testprofile
, -1, fileW
, len
);
1443 testprofileW
= (LPWSTR
)&fileW
;
1448 have_color_profile
= have_profile();
1450 test_GetColorDirectoryA();
1451 test_GetColorDirectoryW();
1453 test_GetColorProfileElement( standardprofile
);
1454 test_GetColorProfileElementTag( standardprofile
);
1456 test_GetColorProfileFromHandle( testprofile
);
1457 test_GetColorProfileHeader( testprofile
);
1459 test_GetCountColorProfileElements( standardprofile
);
1461 test_GetStandardColorSpaceProfileA( standardprofile
);
1462 test_GetStandardColorSpaceProfileW( standardprofileW
);
1464 test_EnumColorProfilesA( standardprofile
);
1465 test_EnumColorProfilesW( standardprofileW
);
1467 test_InstallColorProfileA( standardprofile
, testprofile
);
1468 test_InstallColorProfileW( standardprofileW
, testprofileW
);
1470 test_IsColorProfileTagPresent( standardprofile
);
1472 test_OpenColorProfileA( standardprofile
);
1473 test_OpenColorProfileW( standardprofileW
);
1475 test_SetColorProfileElement( testprofile
);
1476 test_SetColorProfileHeader( testprofile
);
1478 test_UninstallColorProfileA( testprofile
);
1479 test_UninstallColorProfileW( testprofileW
);
1481 test_AssociateColorProfileWithDeviceA( testprofile
);
1482 test_CreateMultiProfileTransform( standardprofile
, testprofile
);
1484 if (testprofile
) DeleteFileA( testprofile
);
1485 FreeLibrary( huser32
);
1486 FreeLibrary( hmscms
);