2008-01-21 16:33:55 +01:00
|
|
|
/*
|
|
|
|
* Tests for ICM functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005, 2008 Hans Leidekker
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
|
|
|
|
|
|
|
|
static void test_GetICMProfileA( HDC dc )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
DWORD size, error;
|
|
|
|
char filename[MAX_PATH];
|
|
|
|
|
2008-02-26 17:00:33 +01:00
|
|
|
SetLastError( 0xdeadbeef );
|
2008-01-21 16:33:55 +01:00
|
|
|
ret = GetICMProfileA( NULL, NULL, NULL );
|
2008-02-26 17:00:33 +01:00
|
|
|
if ( !ret && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
|
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip( "GetICMProfileA is not implemented\n" );
|
2008-02-26 17:00:33 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-01-21 16:33:55 +01:00
|
|
|
ok( !ret, "GetICMProfileA succeeded\n" );
|
|
|
|
|
|
|
|
ret = GetICMProfileA( dc, NULL, NULL );
|
|
|
|
ok( !ret, "GetICMProfileA succeeded\n" );
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = GetICMProfileA( dc, &size, NULL );
|
|
|
|
ok( !ret, "GetICMProfileA succeeded\n" );
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = GetICMProfileA( NULL, &size, filename );
|
|
|
|
ok( !ret, "GetICMProfileA succeeded\n" );
|
|
|
|
|
|
|
|
size = 0;
|
2008-09-10 17:47:49 +02:00
|
|
|
filename[0] = 0;
|
2008-01-21 16:33:55 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetICMProfileA( dc, &size, filename );
|
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "GetICMProfileA succeeded\n" );
|
|
|
|
ok( size, "expected size > 0\n" );
|
2008-09-10 17:47:49 +02:00
|
|
|
ok( filename[0] == 0, "Expected filename to be empty\n" );
|
2011-02-25 23:33:17 +01:00
|
|
|
ok( error == ERROR_INSUFFICIENT_BUFFER, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error );
|
2008-09-10 17:47:49 +02:00
|
|
|
|
2011-02-25 23:33:17 +01:00
|
|
|
ret = GetICMProfileA( dc, NULL, filename );
|
|
|
|
ok( !ret, "GetICMProfileA succeeded\n" );
|
2008-01-21 16:33:55 +01:00
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = GetICMProfileA( dc, &size, filename );
|
|
|
|
ok( ret, "GetICMProfileA failed %d\n", GetLastError() );
|
|
|
|
|
|
|
|
trace( "%s\n", filename );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetICMProfileW( HDC dc )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
DWORD size, error;
|
|
|
|
WCHAR filename[MAX_PATH];
|
|
|
|
|
2008-02-26 17:00:33 +01:00
|
|
|
SetLastError( 0xdeadbeef );
|
2008-01-21 16:33:55 +01:00
|
|
|
ret = GetICMProfileW( NULL, NULL, NULL );
|
2008-02-26 17:00:33 +01:00
|
|
|
if ( !ret && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
|
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip( "GetICMProfileW is not implemented\n" );
|
2008-02-26 17:00:33 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-01-21 16:33:55 +01:00
|
|
|
ok( !ret, "GetICMProfileW succeeded\n" );
|
|
|
|
|
|
|
|
ret = GetICMProfileW( dc, NULL, NULL );
|
|
|
|
ok( !ret, "GetICMProfileW succeeded\n" );
|
|
|
|
|
2008-02-26 17:16:56 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* Vista crashes */
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = GetICMProfileW( dc, &size, NULL );
|
|
|
|
ok( ret, "GetICMProfileW failed %d\n", GetLastError() );
|
|
|
|
}
|
2008-01-21 16:33:55 +01:00
|
|
|
|
|
|
|
ret = GetICMProfileW( dc, NULL, filename );
|
|
|
|
ok( !ret, "GetICMProfileW succeeded\n" );
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = GetICMProfileW( NULL, &size, filename );
|
|
|
|
ok( !ret, "GetICMProfileW succeeded\n" );
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetICMProfileW( dc, &size, filename );
|
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "GetICMProfileW succeeded\n" );
|
|
|
|
ok( size, "expected size > 0\n" );
|
|
|
|
ok( error == ERROR_INSUFFICIENT_BUFFER, "got %d, expected ERROR_INSUFFICIENT_BUFFER\n", error );
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = GetICMProfileW( dc, &size, filename );
|
|
|
|
ok( ret, "GetICMProfileW failed %d\n", GetLastError() );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SetICMMode( HDC dc )
|
|
|
|
{
|
|
|
|
INT ret, knob, save;
|
2008-09-10 17:49:52 +02:00
|
|
|
BOOL impl;
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
impl = GetICMProfileA( NULL, NULL, NULL );
|
|
|
|
if ( !impl && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
|
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip( "On NT4 where SetICMMode is not implemented but this is not advertised\n" );
|
2008-09-10 17:49:52 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-01-21 16:33:55 +01:00
|
|
|
|
2008-02-26 17:00:33 +01:00
|
|
|
SetLastError( 0xdeadbeef );
|
2008-01-21 16:33:55 +01:00
|
|
|
ret = SetICMMode( NULL, 0 );
|
|
|
|
ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = SetICMMode( dc, -1 );
|
|
|
|
ok( !ret, "SetICMMode succeeded (%d)\n", GetLastError() );
|
|
|
|
|
|
|
|
save = SetICMMode( dc, ICM_QUERY );
|
|
|
|
ok( save == ICM_ON || save == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
|
|
|
|
|
|
|
|
if (save == ICM_ON) knob = ICM_OFF; else knob = ICM_ON;
|
|
|
|
|
|
|
|
ret = SetICMMode( dc, knob );
|
|
|
|
todo_wine ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = SetICMMode( dc, ICM_QUERY );
|
|
|
|
todo_wine ok( ret == knob, "SetICMMode failed (%d)\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = SetICMMode( dc, save );
|
|
|
|
ok( ret, "SetICMMode failed (%d)\n", GetLastError() );
|
|
|
|
|
2008-02-26 17:00:33 +01:00
|
|
|
SetLastError( 0xdeadbeef );
|
2008-01-21 16:33:55 +01:00
|
|
|
dc = CreateDCW( displayW, NULL, NULL, NULL );
|
2008-02-26 17:00:33 +01:00
|
|
|
if ( !dc && ( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) )
|
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip( "CreateDCW is not implemented\n" );
|
2008-02-26 17:00:33 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-01-21 16:33:55 +01:00
|
|
|
ok( dc != NULL, "CreateDCW failed (%d)\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = SetICMMode( dc, ICM_QUERY );
|
|
|
|
ok( ret == ICM_OFF, "SetICMMode failed (%d)\n", GetLastError() );
|
|
|
|
|
|
|
|
DeleteDC( dc );
|
|
|
|
}
|
|
|
|
|
2010-10-26 12:41:49 +02:00
|
|
|
static CALLBACK INT enum_profiles_callbackA( LPSTR filename, LPARAM lparam )
|
|
|
|
{
|
|
|
|
trace("%s\n", filename);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_EnumICMProfilesA( HDC dc )
|
|
|
|
{
|
|
|
|
INT ret;
|
|
|
|
|
|
|
|
ret = EnumICMProfilesA( NULL, NULL, 0 );
|
|
|
|
ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
|
|
|
|
|
|
|
|
ret = EnumICMProfilesA( dc, enum_profiles_callbackA, 0 );
|
2011-02-25 23:33:17 +01:00
|
|
|
ok(ret == -1 || broken(ret == 0) /* nt4 */,
|
2010-10-31 19:27:49 +01:00
|
|
|
"expected -1, got %d\n", ret);
|
|
|
|
|
2011-02-25 23:33:17 +01:00
|
|
|
ret = EnumICMProfilesA( dc, NULL, 0 );
|
|
|
|
ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
|
2010-10-26 12:41:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static CALLBACK INT enum_profiles_callbackW( LPWSTR filename, LPARAM lparam )
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_EnumICMProfilesW( HDC dc )
|
|
|
|
{
|
|
|
|
INT ret;
|
|
|
|
|
|
|
|
ret = EnumICMProfilesW( NULL, NULL, 0 );
|
2011-02-25 23:33:17 +01:00
|
|
|
ok(ret == -1 || broken(ret == 0) /* NT4 */, "expected -1, got %d\n", ret);
|
2010-10-26 12:41:49 +02:00
|
|
|
|
|
|
|
ret = EnumICMProfilesW( dc, NULL, 0 );
|
2011-02-25 23:33:17 +01:00
|
|
|
ok(ret == -1 || broken(ret == 0) /* NT4 */, "expected -1, got %d\n", ret);
|
2010-10-26 12:41:49 +02:00
|
|
|
|
|
|
|
ret = EnumICMProfilesW( dc, enum_profiles_callbackW, 0 );
|
2011-02-25 23:33:17 +01:00
|
|
|
ok(ret == -1 || ret == 1 || broken(ret == 0) /* NT4 */, "expected -1, got %d\n", ret);
|
2010-10-26 12:41:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SetICMProfileA( HDC dc )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
char profile[MAX_PATH];
|
|
|
|
DWORD len, error;
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = SetICMProfileA( NULL, NULL );
|
|
|
|
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip("SetICMProfileA is not implemented\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = sizeof(profile);
|
|
|
|
ret = GetICMProfileA( dc, &len, profile );
|
|
|
|
ok(ret, "GetICMProfileA failed %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = SetICMProfileA( NULL, NULL );
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "SetICMProfileA succeeded\n");
|
2011-02-25 23:33:17 +01:00
|
|
|
ok(error == ERROR_INVALID_PARAMETER,
|
2010-10-26 12:41:49 +02:00
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = SetICMProfileA( NULL, profile );
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "SetICMProfileA succeeded\n");
|
2011-02-25 23:33:17 +01:00
|
|
|
ok(error == ERROR_INVALID_HANDLE,
|
2010-10-26 12:41:49 +02:00
|
|
|
"expected ERROR_INVALID_HANDLE, got %u\n", error);
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = SetICMProfileA( dc, NULL );
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "SetICMProfileA succeeded\n");
|
2011-02-25 23:33:17 +01:00
|
|
|
ok(error == ERROR_INVALID_PARAMETER,
|
2010-10-31 19:27:49 +01:00
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
2010-10-26 12:41:49 +02:00
|
|
|
|
|
|
|
ret = SetICMProfileA( dc, profile );
|
|
|
|
ok(ret, "SetICMProfileA failed %u\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SetICMProfileW( HDC dc )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
WCHAR profile[MAX_PATH];
|
|
|
|
DWORD len, error;
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = SetICMProfileW( NULL, NULL );
|
|
|
|
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip("SetICMProfileW is not implemented\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = sizeof(profile)/sizeof(profile[0]);
|
|
|
|
ret = GetICMProfileW( dc, &len, profile );
|
|
|
|
ok(ret, "GetICMProfileW failed %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = SetICMProfileW( NULL, NULL );
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "SetICMProfileW succeeded\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = SetICMProfileW( NULL, profile );
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "SetICMProfileW succeeded\n");
|
|
|
|
ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = SetICMProfileW( dc, NULL );
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "SetICMProfileW succeeded\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
|
|
|
|
|
|
|
ret = SetICMProfileW( dc, profile );
|
|
|
|
ok(ret, "SetICMProfileW failed %u\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2008-01-21 16:33:55 +01:00
|
|
|
START_TEST(icm)
|
|
|
|
{
|
|
|
|
HDC dc = GetDC( NULL );
|
|
|
|
|
|
|
|
test_GetICMProfileA( dc );
|
|
|
|
test_GetICMProfileW( dc );
|
|
|
|
test_SetICMMode( dc );
|
2010-10-26 12:41:49 +02:00
|
|
|
test_EnumICMProfilesA( dc );
|
|
|
|
test_EnumICMProfilesW( dc );
|
|
|
|
test_SetICMProfileA( dc );
|
|
|
|
test_SetICMProfileW( dc );
|
2008-01-21 16:33:55 +01:00
|
|
|
|
|
|
|
ReleaseDC( NULL, dc );
|
|
|
|
}
|