ReactOS 0.4.17-dev-116-ga4b6fe9
icm.c
Go to the documentation of this file.
1/*
2 * Tests for ICM functions
3 *
4 * Copyright (C) 2005, 2008 Hans Leidekker
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include <stdarg.h>
22
23#include "windef.h"
24#include "winbase.h"
25#include "winuser.h"
26#include "wingdi.h"
27
28#include "wine/test.h"
29
31{
32 BOOL ret;
34 char filename[MAX_PATH];
35
36 SetLastError( 0xdeadbeef );
39 {
40 win_skip( "GetICMProfileA is not implemented\n" );
41 return;
42 }
43 ok( !ret, "GetICMProfileA succeeded\n" );
44
46 ok( !ret, "GetICMProfileA succeeded\n" );
47
48 size = MAX_PATH;
50 ok( !ret, "GetICMProfileA succeeded\n" );
51 ok( size > 0, "got %lu\n", size );
52
53 size = 0;
55 ok( !ret, "GetICMProfileA succeeded\n" );
56 ok( size > 0, "got %lu\n", size );
57
58 size = MAX_PATH;
60 ok( !ret, "GetICMProfileA succeeded\n" );
61
62 size = 0;
63 filename[0] = 0;
64 SetLastError(0xdeadbeef);
67 ok( !ret, "GetICMProfileA succeeded\n" );
68 ok( size, "expected size > 0\n" );
69 ok( filename[0] == 0, "Expected filename to be empty\n" );
70 ok( error == ERROR_INSUFFICIENT_BUFFER, "got %ld, expected ERROR_INSUFFICIENT_BUFFER\n", error );
71
73 ok( !ret, "GetICMProfileA succeeded\n" );
74
75 size = MAX_PATH;
77 ok( ret, "GetICMProfileA failed %ld\n", GetLastError() );
78
79 trace( "%s\n", filename );
80}
81
83{
84 BOOL ret;
87
88 SetLastError( 0xdeadbeef );
91 {
92 win_skip( "GetICMProfileW is not implemented\n" );
93 return;
94 }
95 ok( !ret, "GetICMProfileW succeeded\n" );
96
98 ok( !ret, "GetICMProfileW succeeded\n" );
99
100 if (0)
101 {
102 /* Vista crashes */
103 size = MAX_PATH;
104 ret = GetICMProfileW( dc, &size, NULL );
105 ok( ret, "GetICMProfileW failed %ld\n", GetLastError() );
106 }
107
109 ok( !ret, "GetICMProfileW succeeded\n" );
110
111 size = MAX_PATH;
113 ok( !ret, "GetICMProfileW succeeded\n" );
114
115 size = 0;
116 ret = GetICMProfileW( dc, &size, NULL );
117 ok( !ret, "GetICMProfileW succeeded\n" );
118 ok( size > 0, "got %lu\n", size );
119
120 size = 0;
121 SetLastError(0xdeadbeef);
124 ok( !ret, "GetICMProfileW succeeded\n" );
125 ok( size, "expected size > 0\n" );
126 ok( error == ERROR_INSUFFICIENT_BUFFER, "got %ld, expected ERROR_INSUFFICIENT_BUFFER\n", error );
127
128 size = MAX_PATH;
130 ok( ret, "GetICMProfileW failed %ld\n", GetLastError() );
131}
132
133static void test_SetICMMode( HDC dc )
134{
135 INT ret, knob, save;
136 BOOL impl;
137
138 SetLastError( 0xdeadbeef );
139 impl = GetICMProfileA( NULL, NULL, NULL );
140 if ( !impl && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
141 {
142 win_skip( "On NT4 where SetICMMode is not implemented but this is not advertised\n" );
143 return;
144 }
145
146 SetLastError( 0xdeadbeef );
147 ret = SetICMMode( NULL, 0 );
148 ok( !ret, "SetICMMode succeeded (%ld)\n", GetLastError() );
149
150 ret = SetICMMode( dc, -1 );
151 ok( !ret, "SetICMMode succeeded (%ld)\n", GetLastError() );
152
153 save = SetICMMode( dc, ICM_QUERY );
154 ok( save == ICM_ON || save == ICM_OFF, "SetICMMode failed (%ld)\n", GetLastError() );
155
156 if (save == ICM_ON) knob = ICM_OFF; else knob = ICM_ON;
157
158 ret = SetICMMode( dc, knob );
159 todo_wine ok( ret, "SetICMMode failed (%ld)\n", GetLastError() );
160
162 todo_wine ok( ret == knob, "SetICMMode failed (%ld)\n", GetLastError() );
163
164 ret = SetICMMode( dc, save );
165 ok( ret, "SetICMMode failed (%ld)\n", GetLastError() );
166
167 SetLastError( 0xdeadbeef );
168 dc = CreateDCW( L"DISPLAY", NULL, NULL, NULL );
169 if ( !dc && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
170 {
171 win_skip( "CreateDCW is not implemented\n" );
172 return;
173 }
174 ok( dc != NULL, "CreateDCW failed (%ld)\n", GetLastError() );
175
177 ok( ret == ICM_OFF, "SetICMMode failed (%ld)\n", GetLastError() );
178
179 DeleteDC( dc );
180}
181
183{
184 trace("%s\n", filename);
185 return 1;
186}
187
189{
190 INT ret;
191
192 ret = EnumICMProfilesA( NULL, NULL, 0 );
193 ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
194
196 ok(ret == -1 || ret == 1 || broken(ret == 0) /* nt4 */,
197 "expected -1 or 1, got %d\n", ret);
198
199 ret = EnumICMProfilesA( dc, NULL, 0 );
200 ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
201}
202
204{
205 return 1;
206}
207
209{
210 INT ret;
211
212 ret = EnumICMProfilesW( NULL, NULL, 0 );
213 ok(ret == -1 || broken(ret == 0) /* NT4 */, "expected -1, got %d\n", ret);
214
215 ret = EnumICMProfilesW( dc, NULL, 0 );
216 ok(ret == -1 || broken(ret == 0) /* NT4 */, "expected -1, got %d\n", ret);
217
219 ok(ret == -1 || ret == 1 || broken(ret == 0) /* NT4 */, "expected -1 or 1, got %d\n", ret);
220}
221
223{
224 BOOL ret;
225 char profile[MAX_PATH];
226 DWORD len, error;
227
228 SetLastError( 0xdeadbeef );
231 {
232 win_skip("SetICMProfileA is not implemented\n");
233 return;
234 }
235
236 len = sizeof(profile);
238 ok(ret, "GetICMProfileA failed %lu\n", GetLastError());
239
240 SetLastError( 0xdeadbeef );
243 ok(!ret, "SetICMProfileA succeeded\n");
245 "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
246
247 SetLastError( 0xdeadbeef );
250 ok(!ret, "SetICMProfileA succeeded\n");
252 "expected ERROR_INVALID_HANDLE, got %lu\n", error);
253
254 SetLastError( 0xdeadbeef );
257 ok(!ret, "SetICMProfileA succeeded\n");
259 "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
260
262 ok(ret, "SetICMProfileA failed %lu\n", GetLastError());
263}
264
266{
267 BOOL ret;
269 DWORD len, error;
270
271 SetLastError( 0xdeadbeef );
274 {
275 win_skip("SetICMProfileW is not implemented\n");
276 return;
277 }
278
281 ok(ret, "GetICMProfileW failed %lu\n", GetLastError());
282
283 SetLastError( 0xdeadbeef );
286 ok(!ret, "SetICMProfileW succeeded\n");
287 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
288
289 SetLastError( 0xdeadbeef );
292 ok(!ret, "SetICMProfileW succeeded\n");
293 ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %lu\n", error);
294
295 SetLastError( 0xdeadbeef );
298 ok(!ret, "SetICMProfileW succeeded\n");
299 ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", error);
300
302 ok(ret, "SetICMProfileW failed %lu\n", GetLastError());
303}
304
306{
307 HDC dc = GetDC( NULL );
308
316
317 ReleaseDC( NULL, dc );
318}
@ lparam
Definition: SystemMenu.c:31
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
HDC dc
Definition: cylfrac.c:34
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define NULL
Definition: types.h:112
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define MAX_PATH
Definition: compat.h:34
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define CALLBACK
Definition: compat.h:35
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
const char * filename
Definition: ioapi.h:137
#define profile
Definition: kernel32.h:12
#define win_skip
Definition: minitest.h:67
#define todo_wine
Definition: minitest.h:80
LONG_PTR LPARAM
Definition: minwindef.h:175
#define error(str)
Definition: mkdosfs.c:1605
static HDC
Definition: imagelist.c:88
static void test_SetICMMode(HDC dc)
Definition: icm.c:133
static void test_GetICMProfileA(HDC dc)
Definition: icm.c:30
static void test_SetICMProfileW(HDC dc)
Definition: icm.c:265
static void test_EnumICMProfilesA(HDC dc)
Definition: icm.c:188
static void test_GetICMProfileW(HDC dc)
Definition: icm.c:82
static INT CALLBACK enum_profiles_callbackW(LPWSTR filename, LPARAM lparam)
Definition: icm.c:203
static void test_SetICMProfileA(HDC dc)
Definition: icm.c:222
static INT CALLBACK enum_profiles_callbackA(LPSTR filename, LPARAM lparam)
Definition: icm.c:182
static void test_EnumICMProfilesW(HDC dc)
Definition: icm.c:208
short WCHAR
Definition: pedump.c:58
uint16_t * LPWSTR
Definition: typedefs.h:56
char * LPSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
int WINAPI EnumICMProfilesW(_In_ HDC, _In_ ICMENUMPROCW, _In_opt_ LPARAM)
int WINAPI SetICMMode(_In_ HDC, _In_ int)
BOOL WINAPI GetICMProfileA(_In_ HDC hdc, _Inout_ LPDWORD pBufSize, _Out_writes_opt_(*pBufSize) LPSTR pszFilename)
BOOL WINAPI SetICMProfileW(_In_ HDC, _In_ LPWSTR)
#define ICM_QUERY
Definition: wingdi.h:983
#define ICM_OFF
Definition: wingdi.h:982
#define ICM_ON
Definition: wingdi.h:981
BOOL WINAPI SetICMProfileA(_In_ HDC, _In_ LPSTR)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI GetICMProfileW(_In_ HDC hdc, _Inout_ LPDWORD pBufSize, _Out_writes_opt_(*pBufSize) LPWSTR pszFilename)
int WINAPI EnumICMProfilesA(_In_ HDC, _In_ ICMENUMPROCA, _In_opt_ LPARAM)
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)