push 37d76373165707dfd5c864bc2126a42ed39183b4
[wine/hacks.git] / dlls / gdi32 / tests / icm.c
blobbbd557412215437807f4e8462e68335b1329b3ef
1 /*
2 * Tests for ICM functions
4 * Copyright (C) 2005, 2008 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
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "wingdi.h"
28 #include "wine/test.h"
30 static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
32 static void test_GetICMProfileA( HDC dc )
34 BOOL ret;
35 DWORD size, error;
36 char filename[MAX_PATH];
38 ret = GetICMProfileA( NULL, NULL, NULL );
39 ok( !ret, "GetICMProfileA succeeded\n" );
41 ret = GetICMProfileA( dc, NULL, NULL );
42 ok( !ret, "GetICMProfileA succeeded\n" );
44 size = MAX_PATH;
45 ret = GetICMProfileA( dc, &size, NULL );
46 ok( !ret, "GetICMProfileA succeeded\n" );
48 ret = GetICMProfileA( dc, NULL, filename );
49 ok( !ret, "GetICMProfileA succeeded\n" );
51 size = MAX_PATH;
52 ret = GetICMProfileA( NULL, &size, filename );
53 ok( !ret, "GetICMProfileA succeeded\n" );
55 size = 0;
56 SetLastError(0xdeadbeef);
57 ret = GetICMProfileA( dc, &size, filename );
58 error = GetLastError();
59 ok( !ret, "GetICMProfileA succeeded\n" );
60 ok( size, "expected size > 0\n" );
61 ok( error == ERROR_INSUFFICIENT_BUFFER, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error );
63 size = MAX_PATH;
64 ret = GetICMProfileA( dc, &size, filename );
65 ok( ret, "GetICMProfileA failed %d\n", GetLastError() );
67 trace( "%s\n", filename );
70 static void test_GetICMProfileW( HDC dc )
72 BOOL ret;
73 DWORD size, error;
74 WCHAR filename[MAX_PATH];
76 ret = GetICMProfileW( NULL, NULL, NULL );
77 ok( !ret, "GetICMProfileW succeeded\n" );
79 ret = GetICMProfileW( dc, NULL, NULL );
80 ok( !ret, "GetICMProfileW succeeded\n" );
82 size = MAX_PATH;
83 ret = GetICMProfileW( dc, &size, NULL );
84 ok( ret, "GetICMProfileW failed %d\n", GetLastError() );
86 ret = GetICMProfileW( dc, NULL, filename );
87 ok( !ret, "GetICMProfileW succeeded\n" );
89 size = MAX_PATH;
90 ret = GetICMProfileW( NULL, &size, filename );
91 ok( !ret, "GetICMProfileW succeeded\n" );
93 size = 0;
94 SetLastError(0xdeadbeef);
95 ret = GetICMProfileW( dc, &size, filename );
96 error = GetLastError();
97 ok( !ret, "GetICMProfileW succeeded\n" );
98 ok( size, "expected size > 0\n" );
99 ok( error == ERROR_INSUFFICIENT_BUFFER, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error );
101 size = MAX_PATH;
102 ret = GetICMProfileW( dc, &size, filename );
103 ok( ret, "GetICMProfileW failed %d\n", GetLastError() );
106 static void test_SetICMMode( HDC dc )
108 INT ret, knob, save;
110 ret = SetICMMode( NULL, 0 );
111 ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
113 ret = SetICMMode( dc, -1 );
114 ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
116 save = SetICMMode( dc, ICM_QUERY );
117 ok( save == ICM_ON || save == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
119 if (save == ICM_ON) knob = ICM_OFF; else knob = ICM_ON;
121 ret = SetICMMode( dc, knob );
122 todo_wine ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
124 ret = SetICMMode( dc, ICM_QUERY );
125 todo_wine ok( ret == knob, "SetICMMode failed (%d)\n", GetLastError() );
127 ret = SetICMMode( dc, save );
128 ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
130 dc = CreateDCW( displayW, NULL, NULL, NULL );
131 ok( dc != NULL, "CreateDCW failed (%d)\n", GetLastError() );
133 ret = SetICMMode( dc, ICM_QUERY );
134 ok( ret == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
136 DeleteDC( dc );
139 START_TEST(icm)
141 HDC dc = GetDC( NULL );
143 test_GetICMProfileA( dc );
144 test_GetICMProfileW( dc );
145 test_SetICMMode( dc );
147 ReleaseDC( NULL, dc );