[MSCMS_WINETEST]
[reactos.git] / rostests / winetests / mscms / profile.c
index b5bf5aa..fd35193 100644 (file)
@@ -59,7 +59,7 @@ static BOOL     (WINAPI *pSetStandardColorSpaceProfileW)(PCWSTR,DWORD,PWSTR);
 static BOOL     (WINAPI *pUninstallColorProfileA)(PCSTR,PCSTR,BOOL);
 static BOOL     (WINAPI *pUninstallColorProfileW)(PCWSTR,PCWSTR,BOOL);
 
-static BOOL     (WINAPI *pEnumDisplayDevicesA)(LPCSTR,DWORD,PDISPLAY_DEVICE,DWORD);
+static BOOL     (WINAPI *pEnumDisplayDevicesA)(LPCSTR,DWORD,PDISPLAY_DEVICEA,DWORD);
 
 #define GETFUNCPTR(func) p##func = (void *)GetProcAddress( hmscms, #func ); \
     if (!p##func) return FALSE;
@@ -122,6 +122,8 @@ 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 BOOL have_color_profile;
+
 static const unsigned char rgbheader[] =
 { 0x48, 0x0c, 0x00, 0x00, 0x6f, 0x6e, 0x69, 0x4c, 0x00, 0x00, 0x10, 0x02,
   0x72, 0x74, 0x6e, 0x6d, 0x20, 0x42, 0x47, 0x52, 0x20, 0x5a, 0x59, 0x58,
@@ -254,17 +256,16 @@ static void test_GetColorProfileElement( char *standardprofile )
         ok( !ret, "GetColorProfileElement() succeeded (%d)\n", GetLastError() );
 
         size = 0;
-
         ret = pGetColorProfileElement( handle, tag, 0, &size, NULL, &ref );
-        ok( !ret && size > 0, "GetColorProfileElement() succeeded (%d)\n", GetLastError() );
-
-        size = sizeof(buffer);
+        ok( !ret, "GetColorProfileElement() succeeded\n" );
+        ok( size > 0, "wrong size\n" );
 
         /* Functional checks */
 
+        size = sizeof(buffer);
         ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
-        ok( ret && size > 0, "GetColorProfileElement() failed (%d)\n", GetLastError() );
-
+        ok( ret, "GetColorProfileElement() failed %u\n", GetLastError() );
+        ok( size > 0, "wrong size\n" );
         ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected tag data\n" );
 
         pCloseColorProfile( handle );
@@ -670,7 +671,7 @@ static void test_EnumColorProfilesA( char *standardprofile )
     ok( !ret, "EnumColorProfilesA() succeeded (%d)\n", GetLastError() );
 
     ret = pEnumColorProfilesA( NULL, &record, buffer, &size, &number );
-    if (standardprofile)
+    if (have_color_profile)
         ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
     else
         todo_wine ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
@@ -684,7 +685,7 @@ static void test_EnumColorProfilesA( char *standardprofile )
 
     size = total;
     ret = pEnumColorProfilesA( NULL, &record, buffer, &size, &number );
-    if (standardprofile)
+    if (have_color_profile)
         ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
     else
         todo_wine ok( ret, "EnumColorProfilesA() failed (%d)\n", GetLastError() );
@@ -724,7 +725,7 @@ static void test_EnumColorProfilesW( WCHAR *standardprofileW )
     ok( !ret, "EnumColorProfilesW() succeeded (%d)\n", GetLastError() );
 
     ret = pEnumColorProfilesW( NULL, &record, buffer, &size, &number );
-    if (standardprofileW)
+    if (have_color_profile)
         ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
     else
         todo_wine ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
@@ -737,7 +738,7 @@ static void test_EnumColorProfilesW( WCHAR *standardprofileW )
 
     size = total;
     ret = pEnumColorProfilesW( NULL, &record, buffer, &size, &number );
-    if (standardprofileW)
+    if (have_color_profile)
         ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
     else
         todo_wine ok( ret, "EnumColorProfilesW() failed (%d)\n", GetLastError() );
@@ -1054,18 +1055,16 @@ static void test_SetColorProfileElement( char *testprofile )
         /* Functional checks */
 
         size = sizeof(data);
-
         ret = pSetColorProfileElement( handle, tag, 0, &size, data );
-        ok( ret, "SetColorProfileElement() failed (%d)\n", GetLastError() );
+        ok( ret, "SetColorProfileElement() failed %u\n", GetLastError() );
 
         size = sizeof(buffer);
-
         ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref );
-        ok( ret && size > 0, "GetColorProfileElement() failed (%d)\n", GetLastError() );
+        ok( ret, "GetColorProfileElement() failed %u\n", GetLastError() );
+        ok( size > 0, "wrong size\n" );
 
         ok( !memcmp( data, buffer, sizeof(data) ),
-            "Unexpected tag data, expected %s, got %s (%d)\n",
-            data, buffer, GetLastError() );
+            "Unexpected tag data, expected %s, got %s (%u)\n", data, buffer, GetLastError() );
 
         pCloseColorProfile( handle );
     }
@@ -1247,17 +1246,16 @@ static void test_AssociateColorProfileWithDeviceA( char *testprofile )
     BOOL ret;
     char profile[MAX_PATH], basename[MAX_PATH];
     DWORD error, size = sizeof(profile);
-    DISPLAY_DEVICE display;
+    DISPLAY_DEVICEA display, monitor;
     BOOL res;
-    DISPLAY_DEVICE monitor;
 
     if (testprofile && pEnumDisplayDevicesA)
     {
-        display.cb = sizeof( DISPLAY_DEVICE );
+        display.cb = sizeof( DISPLAY_DEVICEA );
         res = pEnumDisplayDevicesA( NULL, 0, &display, 0 );
         ok( res, "Can't get display info\n" );
 
-        monitor.cb = sizeof( DISPLAY_DEVICE );
+        monitor.cb = sizeof( DISPLAY_DEVICEA );
         res = pEnumDisplayDevicesA( display.DeviceName, 0, &monitor, 0 );
         if (res)
         {
@@ -1321,6 +1319,21 @@ static void test_AssociateColorProfileWithDeviceA( char *testprofile )
     }
 }
 
+static BOOL have_profile(void)
+{
+    char glob[MAX_PATH + sizeof("\\*.icm")];
+    DWORD size = MAX_PATH;
+    HANDLE handle;
+    WIN32_FIND_DATAA data;
+
+    if (!pGetColorDirectoryA( NULL, glob, &size )) return FALSE;
+    lstrcatA( glob, "\\*.icm" );
+    handle = FindFirstFileA( glob, &data );
+    if (handle == INVALID_HANDLE_VALUE) return FALSE;
+    FindClose( handle );
+    return TRUE;
+}
+
 START_TEST(profile)
 {
     UINT len;
@@ -1382,9 +1395,9 @@ START_TEST(profile)
     }
 
     /* If found, create a temporary copy for testing purposes */
-    if (standardprofile && GetTempPath( sizeof(path), path ))
+    if (standardprofile && GetTempPathA( sizeof(path), path ))
     {
-        if (GetTempFileName( path, "rgb", 0, file ))
+        if (GetTempFileNameA( path, "rgb", 0, file ))
         {
             if (CopyFileA( standardprofile, file, FALSE ))
             {
@@ -1396,6 +1409,8 @@ START_TEST(profile)
         }
     }
 
+    have_color_profile = have_profile();
+
     test_GetColorDirectoryA();
     test_GetColorDirectoryW();