ntdll: The FileMailslotSetInformation and FileCompletionInformation cases of NtSetInf...
[wine] / dlls / gdi32 / tests / icm.c
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
30 static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
31
32 static void test_GetICMProfileA( HDC dc )
33 {
34     BOOL ret;
35     DWORD size, error;
36     char filename[MAX_PATH];
37
38     ret = GetICMProfileA( NULL, NULL, NULL );
39     ok( !ret, "GetICMProfileA succeeded\n" );
40
41     ret = GetICMProfileA( dc, NULL, NULL );
42     ok( !ret, "GetICMProfileA succeeded\n" );
43
44     size = MAX_PATH;
45     ret = GetICMProfileA( dc, &size, NULL );
46     ok( !ret, "GetICMProfileA succeeded\n" );
47
48     ret = GetICMProfileA( dc, NULL, filename );
49     ok( !ret, "GetICMProfileA succeeded\n" );
50
51     size = MAX_PATH;
52     ret = GetICMProfileA( NULL, &size, filename );
53     ok( !ret, "GetICMProfileA succeeded\n" );
54
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 );
62
63     size = MAX_PATH;
64     ret = GetICMProfileA( dc, &size, filename );
65     ok( ret, "GetICMProfileA failed %d\n", GetLastError() );
66
67     trace( "%s\n", filename );
68 }
69
70 static void test_GetICMProfileW( HDC dc )
71 {
72     BOOL ret;
73     DWORD size, error;
74     WCHAR filename[MAX_PATH];
75
76     ret = GetICMProfileW( NULL, NULL, NULL );
77     ok( !ret, "GetICMProfileW succeeded\n" );
78
79     ret = GetICMProfileW( dc, NULL, NULL );
80     ok( !ret, "GetICMProfileW succeeded\n" );
81
82     size = MAX_PATH;
83     ret = GetICMProfileW( dc, &size, NULL );
84     ok( ret, "GetICMProfileW failed %d\n", GetLastError() );
85
86     ret = GetICMProfileW( dc, NULL, filename );
87     ok( !ret, "GetICMProfileW succeeded\n" );
88
89     size = MAX_PATH;
90     ret = GetICMProfileW( NULL, &size, filename );
91     ok( !ret, "GetICMProfileW succeeded\n" );
92
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 );
100
101     size = MAX_PATH;
102     ret = GetICMProfileW( dc, &size, filename );
103     ok( ret, "GetICMProfileW failed %d\n", GetLastError() );
104 }
105
106 static void test_SetICMMode( HDC dc )
107 {
108     INT ret, knob, save;
109
110     ret = SetICMMode( NULL, 0 );
111     ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
112
113     ret = SetICMMode( dc, -1 );
114     ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
115
116     save = SetICMMode( dc, ICM_QUERY );
117     ok( save == ICM_ON || save == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
118
119     if (save == ICM_ON) knob = ICM_OFF; else knob = ICM_ON;
120
121     ret = SetICMMode( dc, knob );
122     todo_wine ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
123
124     ret = SetICMMode( dc, ICM_QUERY );
125     todo_wine ok( ret == knob, "SetICMMode failed (%d)\n", GetLastError() );
126
127     ret = SetICMMode( dc, save );
128     ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
129
130     dc = CreateDCW( displayW, NULL, NULL, NULL );
131     ok( dc != NULL, "CreateDCW failed (%d)\n", GetLastError() );
132
133     ret = SetICMMode( dc, ICM_QUERY );
134     ok( ret == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
135
136     DeleteDC( dc );
137 }
138
139 START_TEST(icm)
140 {
141     HDC dc = GetDC( NULL );
142
143     test_GetICMProfileA( dc );
144     test_GetICMProfileW( dc );
145     test_SetICMMode( dc );
146
147     ReleaseDC( NULL, dc );
148 }