2 * Tests for color profile functions
4 * Copyright 2004 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 /* Two common places to find the standard color space profile */
36 static const char profile1
[] =
37 "c:\\windows\\system\\color\\srgb color space profile.icm";
38 static const char profile2
[] =
39 "c:\\windows\\system32\\spool\\drivers\\color\\srgb color space profile.icm";
41 static const WCHAR profile1W
[] =
42 { 'c',':','\\','w','i','n','d','o','w','s','\\', 's','y','s','t','e','m',
43 '\\','c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
44 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
45 static const WCHAR profile2W
[] =
46 { 'c',':','\\','w','i','n','d','o','w','s','\\', 's','y','s','t','e','m','3','2',
47 '\\','s','p','o','o','l','\\','d','r','i','v','e','r','s',
48 '\\','c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
49 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
51 static LPSTR standardprofile
= NULL
;
52 static LPWSTR standardprofileW
= NULL
;
54 static LPSTR testprofile
= NULL
;
55 static LPWSTR testprofileW
= NULL
;
57 static void test_GetColorDirectoryA()
61 char buffer
[MAX_PATH
];
63 /* Parameter checks */
67 ret
= GetColorDirectoryA( NULL
, NULL
, &size
);
68 ok( !ret
, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
72 ret
= GetColorDirectoryA( NULL
, buffer
, &size
);
73 ok( !ret
, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
77 ret
= GetColorDirectoryA( NULL
, buffer
, &size
);
78 ok( !ret
, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
80 size
= sizeof(buffer
);
82 ret
= GetColorDirectoryA( machine
, buffer
, &size
);
83 ok( !ret
, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() );
85 /* Functional checks */
87 size
= sizeof(buffer
);
89 ret
= GetColorDirectoryA( NULL
, buffer
, &size
);
90 ok( ret
, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
93 static void test_GetColorDirectoryW()
97 WCHAR buffer
[MAX_PATH
];
99 /* Parameter checks */
103 ret
= GetColorDirectoryW( NULL
, NULL
, &size
);
104 ok( !ret
, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
108 ret
= GetColorDirectoryW( NULL
, buffer
, &size
);
109 ok( !ret
, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
113 ret
= GetColorDirectoryW( NULL
, buffer
, &size
);
114 ok( !ret
, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
116 size
= sizeof(buffer
);
118 ret
= GetColorDirectoryW( machineW
, buffer
, &size
);
119 ok( !ret
, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() );
121 /* Functional checks */
123 size
= sizeof(buffer
);
125 ret
= GetColorDirectoryW( NULL
, buffer
, &size
);
126 ok( ret
, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
129 static void test_InstallColorProfileA()
133 /* Parameter checks */
135 ret
= InstallColorProfileA( NULL
, NULL
);
136 ok( !ret
, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
138 ret
= InstallColorProfileA( machine
, NULL
);
139 ok( !ret
, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
141 ret
= InstallColorProfileA( NULL
, machine
);
142 ok( !ret
, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
146 ret
= InstallColorProfileA( NULL
, standardprofile
);
147 ok( ret
, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
150 /* Functional checks */
154 ret
= InstallColorProfileA( NULL
, testprofile
);
155 ok( ret
, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
157 ret
= UninstallColorProfileA( NULL
, testprofile
, TRUE
);
158 ok( ret
, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
162 static void test_InstallColorProfileW()
166 /* Parameter checks */
168 ret
= InstallColorProfileW( NULL
, NULL
);
169 ok( !ret
, "InstallColorProfileW() succeeded (%ld)\n", GetLastError() );
171 ret
= InstallColorProfileW( machineW
, NULL
);
172 ok( !ret
, "InstallColorProfileW() succeeded (%ld)\n", GetLastError() );
174 ret
= InstallColorProfileW( NULL
, machineW
);
175 ok( !ret
, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
177 if (standardprofileW
)
179 ret
= InstallColorProfileW( NULL
, standardprofileW
);
180 ok( ret
, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
183 /* Functional checks */
187 ret
= InstallColorProfileW( NULL
, testprofileW
);
188 ok( ret
, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
190 ret
= UninstallColorProfileW( NULL
, testprofileW
, TRUE
);
191 ok( ret
, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
195 static void test_OpenColorProfileA()
200 profile
.dwType
= PROFILE_FILENAME
;
201 profile
.pProfileData
= NULL
;
202 profile
.cbDataSize
= 0;
204 /* Parameter checks */
206 handle
= OpenColorProfileA( NULL
, 0, 0, 0 );
207 ok( handle
== NULL
, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
209 handle
= OpenColorProfileA( &profile
, 0, 0, 0 );
210 ok( handle
== NULL
, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
212 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, 0 );
213 ok( handle
== NULL
, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
215 handle
= OpenColorProfileA( &profile
, PROFILE_READWRITE
, 0, 0 );
216 ok( handle
== NULL
, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
218 ok ( !CloseColorProfile( NULL
), "CloseColorProfile() succeeded" );
222 profile
.pProfileData
= standardprofile
;
223 profile
.cbDataSize
= strlen(standardprofile
);
225 handle
= OpenColorProfileA( &profile
, 0, 0, 0 );
226 ok( handle
== NULL
, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
228 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, 0 );
229 ok( handle
== NULL
, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
231 handle
= OpenColorProfileA( &profile
, PROFILE_READ
|PROFILE_READWRITE
, 0, 0 );
232 ok( handle
== NULL
, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
234 /* Functional checks */
236 handle
= OpenColorProfileA( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
237 ok( handle
!= NULL
, "OpenColorProfileA() failed (%ld)\n", GetLastError() );
239 ok( CloseColorProfile( handle
), "CloseColorProfile() failed (%ld)\n", GetLastError() );
243 static void test_OpenColorProfileW()
248 profile
.dwType
= PROFILE_FILENAME
;
249 profile
.pProfileData
= NULL
;
250 profile
.cbDataSize
= 0;
252 /* Parameter checks */
254 handle
= OpenColorProfileW( NULL
, 0, 0, 0 );
255 ok( handle
== NULL
, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
257 handle
= OpenColorProfileW( &profile
, 0, 0, 0 );
258 ok( handle
== NULL
, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
260 handle
= OpenColorProfileW( &profile
, PROFILE_READ
, 0, 0 );
261 ok( handle
== NULL
, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
263 handle
= OpenColorProfileW( &profile
, PROFILE_READWRITE
, 0, 0 );
264 ok( handle
== NULL
, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
266 ok ( !CloseColorProfile( NULL
), "CloseColorProfile() succeeded" );
268 if (standardprofileW
)
270 profile
.pProfileData
= standardprofileW
;
271 profile
.cbDataSize
= lstrlenW(standardprofileW
) * sizeof(WCHAR
);
273 handle
= OpenColorProfileW( &profile
, 0, 0, 0 );
274 ok( handle
== NULL
, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
276 handle
= OpenColorProfileW( &profile
, PROFILE_READ
, 0, 0 );
277 ok( handle
== NULL
, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
279 handle
= OpenColorProfileW( &profile
, PROFILE_READ
|PROFILE_READWRITE
, 0, 0 );
280 ok( handle
== NULL
, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
282 /* Functional checks */
284 handle
= OpenColorProfileW( &profile
, PROFILE_READ
, 0, OPEN_EXISTING
);
285 ok( handle
!= NULL
, "OpenColorProfileW() failed (%ld)\n", GetLastError() );
287 ok( CloseColorProfile( handle
), "CloseColorProfile() failed (%ld)\n", GetLastError() );
291 static void test_UninstallColorProfileA()
295 /* Parameter checks */
297 ret
= UninstallColorProfileA( NULL
, NULL
, FALSE
);
298 ok( !ret
, "UninstallColorProfileA() succeeded (%ld)\n", GetLastError() );
300 ret
= UninstallColorProfileA( machine
, NULL
, FALSE
);
301 ok( !ret
, "UninstallColorProfileA() succeeded (%ld)\n", GetLastError() );
303 /* Functional checks */
307 ret
= InstallColorProfileA( NULL
, testprofile
);
308 ok( ret
, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
310 ret
= UninstallColorProfileA( NULL
, testprofile
, TRUE
);
311 ok( ret
, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
315 static void test_UninstallColorProfileW()
319 /* Parameter checks */
321 ret
= UninstallColorProfileW( NULL
, NULL
, FALSE
);
322 ok( !ret
, "UninstallColorProfileW() succeeded (%ld)\n", GetLastError() );
324 ret
= UninstallColorProfileW( machineW
, NULL
, FALSE
);
325 ok( !ret
, "UninstallColorProfileW() succeeded (%ld)\n", GetLastError() );
327 /* Functional checks */
331 ret
= InstallColorProfileW( NULL
, testprofileW
);
332 ok( ret
, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
334 ret
= UninstallColorProfileW( NULL
, testprofileW
, TRUE
);
335 ok( ret
, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
343 char path
[MAX_PATH
], file
[MAX_PATH
];
344 WCHAR fileW
[MAX_PATH
];
346 /* See if we can find the standard color profile */
347 handle
= CreateFileA( (LPCSTR
)&profile1
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
349 if (handle
!= INVALID_HANDLE_VALUE
)
351 standardprofile
= (LPSTR
)&profile1
;
352 standardprofileW
= (LPWSTR
)&profile1W
;
353 CloseHandle( handle
);
356 handle
= CreateFileA( (LPCSTR
)&profile2
, 0 , 0, NULL
, OPEN_EXISTING
, 0, NULL
);
358 if (handle
!= INVALID_HANDLE_VALUE
)
360 standardprofile
= (LPSTR
)&profile2
;
361 standardprofileW
= (LPWSTR
)&profile2W
;
362 CloseHandle( handle
);
365 /* If found, create a temporary copy for testing purposes */
366 if (standardprofile
&& GetTempPath( sizeof(path
), path
))
368 if (GetTempFileName( path
, "rgb", 0, file
))
370 if (CopyFileA( standardprofile
, file
, FALSE
))
373 testprofile
= (LPSTR
)&file
;
375 len
= MultiByteToWideChar( CP_ACP
, 0, testprofile
, -1, NULL
, 0 );
376 MultiByteToWideChar( CP_ACP
, 0, testprofile
, -1, fileW
, len
);
378 testprofileW
= (LPWSTR
)&fileW
;
383 test_GetColorDirectoryA();
384 test_GetColorDirectoryW();
386 test_InstallColorProfileA();
387 test_InstallColorProfileW();
389 test_OpenColorProfileA();
390 test_OpenColorProfileW();
392 test_UninstallColorProfileA();
393 test_UninstallColorProfileW();
397 DeleteFileA( testprofile
);