Improve {Uninstall,Install}ColorProfile{A,W}.
Better tests for these functions.
This commit is contained in:
parent
53e5799949
commit
dca6bdf5c4
|
@ -34,6 +34,16 @@
|
|||
#include "lcms_api.h"
|
||||
#undef LCMS_API_FUNCTION
|
||||
|
||||
#define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
|
||||
|
||||
static void MSCMS_basename( LPCWSTR path, LPWSTR name )
|
||||
{
|
||||
INT i = lstrlenW( path );
|
||||
|
||||
while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
|
||||
lstrcpyW( name, &path[i] );
|
||||
}
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(mscms);
|
||||
|
||||
BOOL WINAPI GetColorDirectoryA( PCSTR machine, PSTR buffer, PDWORD size )
|
||||
|
@ -62,7 +72,6 @@ BOOL WINAPI GetColorDirectoryA( PCSTR machine, PSTR buffer, PDWORD size )
|
|||
|
||||
HeapFree( GetProcessHeap(), 0, bufferW );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -83,7 +92,7 @@ BOOL WINAPI GetColorDirectoryW( PCWSTR machine, PWSTR buffer, PDWORD size )
|
|||
|
||||
if (len <= *size)
|
||||
{
|
||||
lstrcatW( buffer, colordir );
|
||||
lstrcpyW( buffer, colordir );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -111,27 +120,54 @@ BOOL WINAPI InstallColorProfileA( PCSTR machine, PCSTR profile )
|
|||
ret = InstallColorProfileW( NULL, profileW );
|
||||
HeapFree( GetProcessHeap(), 0, profileW );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL WINAPI InstallColorProfileW( PCWSTR machine, PCWSTR profile )
|
||||
{
|
||||
FIXME( "( %s ) stub\n", debugstr_w(profile) );
|
||||
WCHAR dest[MAX_PATH], base[MAX_PATH];
|
||||
DWORD size = sizeof(dest);
|
||||
static const WCHAR slash[] = { '\\', 0 };
|
||||
|
||||
TRACE( "( %s )\n", debugstr_w(profile) );
|
||||
|
||||
if (machine || !profile) return FALSE;
|
||||
|
||||
return FALSE;
|
||||
if (!GetColorDirectoryW( machine, dest, &size )) return FALSE;
|
||||
|
||||
MSCMS_basename( profile, base );
|
||||
|
||||
lstrcatW( dest, slash );
|
||||
lstrcatW( dest, base );
|
||||
|
||||
/* Is source equal to destination? */
|
||||
if (!lstrcmpW( profile, dest )) return TRUE;
|
||||
|
||||
return CopyFileW( profile, dest, TRUE );
|
||||
}
|
||||
|
||||
BOOL WINAPI UninstallColorProfileA( PCSTR machine, PCSTR profile, BOOL delete )
|
||||
{
|
||||
UINT len;
|
||||
LPWSTR profileW;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
TRACE( "( %s )\n", debugstr_a(profile) );
|
||||
|
||||
if (machine || !profile) return FALSE;
|
||||
|
||||
if (delete)
|
||||
return DeleteFileA( profile );
|
||||
len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
|
||||
profileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
||||
|
||||
return TRUE;
|
||||
if (profileW)
|
||||
{
|
||||
MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
|
||||
|
||||
ret = UninstallColorProfileW( NULL, profileW , delete );
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, profileW );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL WINAPI UninstallColorProfileW( PCWSTR machine, PCWSTR profile, BOOL delete )
|
||||
|
@ -175,7 +211,6 @@ HPROFILE WINAPI OpenColorProfileA( PPROFILE profile, DWORD access, DWORD sharing
|
|||
HeapFree( GetProcessHeap(), 0, profileW.pProfileData );
|
||||
}
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,11 +48,29 @@ static const WCHAR profile2W[] =
|
|||
'\\','c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ',
|
||||
's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
|
||||
|
||||
static LPSTR standardprofile = NULL;
|
||||
static LPWSTR standardprofileW = NULL;
|
||||
static LPSTR standardprofile;
|
||||
static LPWSTR standardprofileW;
|
||||
|
||||
static LPSTR testprofile = NULL;
|
||||
static LPWSTR testprofileW = NULL;
|
||||
static LPSTR testprofile;
|
||||
static LPWSTR testprofileW;
|
||||
|
||||
#define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
|
||||
|
||||
static void MSCMS_basenameA( LPCSTR path, LPSTR name )
|
||||
{
|
||||
INT i = strlen( path );
|
||||
|
||||
while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
|
||||
strcpy( name, &path[i] );
|
||||
}
|
||||
|
||||
static void MSCMS_basenameW( LPCWSTR path, LPWSTR name )
|
||||
{
|
||||
INT i = lstrlenW( path );
|
||||
|
||||
while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
|
||||
lstrcpyW( name, &path[i] );
|
||||
}
|
||||
|
||||
static void test_GetColorDirectoryA()
|
||||
{
|
||||
|
@ -139,7 +157,7 @@ static void test_InstallColorProfileA()
|
|||
ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
|
||||
|
||||
ret = InstallColorProfileA( NULL, machine );
|
||||
ok( !ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
|
||||
ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() );
|
||||
|
||||
if (standardprofile)
|
||||
{
|
||||
|
@ -151,10 +169,28 @@ static void test_InstallColorProfileA()
|
|||
|
||||
if (testprofile)
|
||||
{
|
||||
CHAR dest[MAX_PATH], base[MAX_PATH];
|
||||
DWORD size = sizeof(dest);
|
||||
CHAR slash[] = "\\";
|
||||
HANDLE handle;
|
||||
|
||||
ret = InstallColorProfileA( NULL, testprofile );
|
||||
ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
|
||||
|
||||
ret = UninstallColorProfileA( NULL, testprofile, TRUE );
|
||||
ret = GetColorDirectoryA( NULL, dest, &size );
|
||||
ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
|
||||
|
||||
MSCMS_basenameA( testprofile, base );
|
||||
|
||||
strcat( dest, slash );
|
||||
strcat( dest, base );
|
||||
|
||||
/* Check if the profile is really there */
|
||||
handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
|
||||
ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() );
|
||||
CloseHandle( handle );
|
||||
|
||||
ret = UninstallColorProfileA( NULL, dest, TRUE );
|
||||
ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
|
||||
}
|
||||
}
|
||||
|
@ -184,10 +220,28 @@ static void test_InstallColorProfileW()
|
|||
|
||||
if (testprofileW)
|
||||
{
|
||||
WCHAR dest[MAX_PATH], base[MAX_PATH];
|
||||
DWORD size = sizeof(dest);
|
||||
WCHAR slash[] = { '\\', 0 };
|
||||
HANDLE handle;
|
||||
|
||||
ret = InstallColorProfileW( NULL, testprofileW );
|
||||
ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
|
||||
|
||||
ret = UninstallColorProfileW( NULL, testprofileW, TRUE );
|
||||
ret = GetColorDirectoryW( NULL, dest, &size );
|
||||
ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
|
||||
|
||||
MSCMS_basenameW( testprofileW, base );
|
||||
|
||||
lstrcatW( dest, slash );
|
||||
lstrcatW( dest, base );
|
||||
|
||||
/* Check if the profile is really there */
|
||||
handle = CreateFileW( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
|
||||
ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() );
|
||||
CloseHandle( handle );
|
||||
|
||||
ret = UninstallColorProfileW( NULL, dest, TRUE );
|
||||
ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
|
||||
}
|
||||
}
|
||||
|
@ -304,11 +358,29 @@ static void test_UninstallColorProfileA()
|
|||
|
||||
if (testprofile)
|
||||
{
|
||||
CHAR dest[MAX_PATH], base[MAX_PATH];
|
||||
DWORD size = sizeof(dest);
|
||||
CHAR slash[] = "\\";
|
||||
HANDLE handle;
|
||||
|
||||
ret = InstallColorProfileA( NULL, testprofile );
|
||||
ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() );
|
||||
|
||||
ret = UninstallColorProfileA( NULL, testprofile, TRUE );
|
||||
ret = GetColorDirectoryA( NULL, dest, &size );
|
||||
ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() );
|
||||
|
||||
MSCMS_basenameA( testprofile, base );
|
||||
|
||||
strcat( dest, slash );
|
||||
strcat( dest, base );
|
||||
|
||||
ret = UninstallColorProfileA( NULL, dest, TRUE );
|
||||
ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() );
|
||||
|
||||
/* Check if the profile is really gone */
|
||||
handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
|
||||
ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%ld)\n", GetLastError() );
|
||||
CloseHandle( handle );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,11 +400,29 @@ static void test_UninstallColorProfileW()
|
|||
|
||||
if (testprofileW)
|
||||
{
|
||||
WCHAR dest[MAX_PATH], base[MAX_PATH];
|
||||
DWORD size = sizeof(dest);
|
||||
WCHAR slash[] = { '\\', 0 };
|
||||
HANDLE handle;
|
||||
|
||||
ret = InstallColorProfileW( NULL, testprofileW );
|
||||
ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() );
|
||||
|
||||
ret = UninstallColorProfileW( NULL, testprofileW, TRUE );
|
||||
ret = GetColorDirectoryW( NULL, dest, &size );
|
||||
ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() );
|
||||
|
||||
MSCMS_basenameW( testprofileW, base );
|
||||
|
||||
lstrcatW( dest, slash );
|
||||
lstrcatW( dest, base );
|
||||
|
||||
ret = UninstallColorProfileW( NULL, dest, TRUE );
|
||||
ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() );
|
||||
|
||||
/* Check if the profile is really gone */
|
||||
handle = CreateFileW( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL );
|
||||
ok( handle == INVALID_HANDLE_VALUE, "Found the profile (%ld)\n", GetLastError() );
|
||||
CloseHandle( handle );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue