Alexandre Julliard : user32/tests: Fix the resource tests for various Windows versions.

Alexandre Julliard julliard at winehq.org
Mon Nov 17 09:14:04 CST 2008


Module: wine
Branch: master
Commit: 1877ff01f9f6447b7d59a9a814ce56f7f5ddd6a1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1877ff01f9f6447b7d59a9a814ce56f7f5ddd6a1

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Nov 14 21:17:48 2008 +0100

user32/tests: Fix the resource tests for various Windows versions.

---

 dlls/user32/tests/resource.c |   56 ++++++++++++++++++++++++++---------------
 1 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/dlls/user32/tests/resource.c b/dlls/user32/tests/resource.c
index 30b3e1f..b8e0493 100644
--- a/dlls/user32/tests/resource.c
+++ b/dlls/user32/tests/resource.c
@@ -180,41 +180,43 @@ static void test_accel1(void)
     ok( hAccel != NULL, "create accelerator table\n");
 
     r = CopyAcceleratorTable( hAccel, NULL, 0 );
-    ok( r == n, "two entries in table\n");
+    ok( r == n || broken(r == 2), /* win9x */
+        "two entries in table %u/%u\n", r, n);
 
-    r = CopyAcceleratorTable( hAccel, &ac[0], r );
-    ok( r == n, "still should be two entries in table\n");
+    r = CopyAcceleratorTable( hAccel, &ac[0], n );
+    ok( r == n || broken(r == 2), /* win9x */
+        "still should be two entries in table %u/%u\n", r, n);
 
     n=0;
     ok( ac[n].cmd == 1000, "cmd 0 not preserved\n");
     ok( ac[n].key == 'A', "key 0 not preserved\n");
     ok( ac[n].fVirt == (FVIRTKEY | FNOINVERT), "fVirt 0 not preserved\n");
 
-    n++;
+    if (++n == r) goto done;
     ok( ac[n].cmd == 0xffff, "cmd 1 not preserved\n");
     ok( ac[n].key == 0xffff, "key 1 not preserved\n");
     ok( ac[n].fVirt == 0x007f, "fVirt 1 not changed\n");
 
-    n++;
+    if (++n == r) goto done;
     ok( ac[n].cmd == 0xfff0, "cmd 2 not preserved\n");
     ok( ac[n].key == 0x00ff, "key 2 not preserved\n");
     ok( ac[n].fVirt == 0x0070, "fVirt 2 not changed\n");
 
-    n++;
+    if (++n == r) goto done;
     ok( ac[n].cmd == 0xfff0, "cmd 3 not preserved\n");
     ok( ac[n].key == 0x00ff, "key 3 not preserved\n");
     ok( ac[n].fVirt == 0x0000, "fVirt 3 not changed\n");
 
-    n++;
+    if (++n == r) goto done;
     ok( ac[n].cmd == 0xfff0, "cmd 4 not preserved\n");
     ok( ac[n].key == 0xffff, "key 4 not preserved\n");
     ok( ac[n].fVirt == 0x0001, "fVirt 4 not changed\n");
-
+done:
     r = DestroyAcceleratorTable( hAccel );
     ok( r, "destroy accelerator table\n");
 
     hAccel = CreateAcceleratorTable( &ac[0], 0 );
-    ok( !hAccel, "zero elements should fail\n");
+    ok( !hAccel || broken(hAccel != NULL), /* nt4 */ "zero elements should fail\n");
 
     /* these will on crash win2k
     hAccel = CreateAcceleratorTable( NULL, 1 );
@@ -230,6 +232,7 @@ static void test_accel2(void)
 {
     ACCEL ac[2], out[2];
     HACCEL hac;
+    int res;
 
     ac[0].cmd   = 0;
     ac[0].fVirt = 0;
@@ -246,8 +249,8 @@ static void test_accel2(void)
 
     /* try a zero count */
     hac = CreateAcceleratorTable( &ac[0], 0 );
-    ok( !hac , "fail\n");
-    ok( !DestroyAcceleratorTable( hac ), "destroy failed\n");
+    ok( !hac || broken(hac != NULL), /* nt4 */ "fail\n");
+    if (!hac) ok( !DestroyAcceleratorTable( hac ), "destroy failed\n");
 
     /* creating one accelerator should work */
     hac = CreateAcceleratorTable( &ac[0], 1 );
@@ -258,9 +261,12 @@ static void test_accel2(void)
     /* how about two of the same type? */
     hac = CreateAcceleratorTable( &ac[0], 2);
     ok( hac != NULL , "fail\n");
-    ok( 2 == CopyAcceleratorTable( hac, NULL, 100 ), "copy null failed\n");
-    ok( 2 == CopyAcceleratorTable( hac, NULL, 0 ), "copy null failed\n");
-    ok( 2 == CopyAcceleratorTable( hac, NULL, 1 ), "copy null failed\n");
+    res = CopyAcceleratorTable( hac, NULL, 100 );
+    ok( res == 2 || broken(res == 0), /* win9x */ "copy null failed %d\n", res);
+    res = CopyAcceleratorTable( hac, NULL, 0 );
+    ok( res == 2, "copy null failed %d\n", res);
+    res = CopyAcceleratorTable( hac, NULL, 1 );
+    ok( res == 2 || broken(res == 0), /* win9x */ "copy null failed %d\n", res);
     ok( 1 == CopyAcceleratorTable( hac, out, 1 ), "copy 1 failed\n");
     ok( 2 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n");
     ok( DestroyAcceleratorTable( hac ), "destroy failed\n");
@@ -311,14 +317,18 @@ static void test_accel2(void)
     memset( ac, 0xff, sizeof ac );
     hac = CreateAcceleratorTable( &ac[0], 2);
     ok( hac != NULL , "fail\n");
-    ok( 2 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n");
+    res = CopyAcceleratorTable( hac, out, 2 );
+    ok( res == 2 || broken(res == 1), /* win9x */ "copy 2 failed %d\n", res);
     /* ok( memcmp( ac, out, sizeof ac ), "tables not different\n"); */
     ok( out[0].cmd == ac[0].cmd, "cmd modified\n");
     ok( out[0].fVirt == (ac[0].fVirt&0x7f), "fVirt not modified\n");
     ok( out[0].key == ac[0].key, "key modified\n");
-    ok( out[1].cmd == ac[1].cmd, "cmd modified\n");
-    ok( out[1].fVirt == (ac[1].fVirt&0x7f), "fVirt not modified\n");
-    ok( out[1].key == ac[1].key, "key modified\n");
+    if (res == 2)
+    {
+        ok( out[1].cmd == ac[1].cmd, "cmd modified\n");
+        ok( out[1].fVirt == (ac[1].fVirt&0x7f), "fVirt not modified\n");
+        ok( out[1].key == ac[1].key, "key modified\n");
+    }
     ok( DestroyAcceleratorTable( hac ), "destroy failed\n");
 }
 
@@ -343,9 +353,13 @@ static void test_PrivateExtractIcons(void) {
     cIcons = pPrivateExtractIconsA(szShell32Dll, 0, 16, 16, ahIcon, aIconId, 3, 0);
     ok(cIcons == 3, "Three icons requested got cIcons=%d\n", cIcons);
 
-    cIcons = pPrivateExtractIconsA(szShell32Dll, 0, MAKELONG(32,16), MAKELONG(32,16), 
-                                  ahIcon, aIconId, 3, 0);
-    ok(cIcons == 4, "Three icons requested, four expected, got cIcons=%d\n", cIcons);
+    /* count must be a multiple of two when getting two sizes */
+    cIcons = pPrivateExtractIconsA(szShell32Dll, 0, MAKELONG(16,32), MAKELONG(16,32),
+                                   ahIcon, aIconId, 3, 0);
+    ok(cIcons == 0 /* vista */ || cIcons == 4, "Three icons requested got cIcons=%d\n", cIcons);
+    cIcons = pPrivateExtractIconsA(szShell32Dll, 0, MAKELONG(16,32), MAKELONG(16,32),
+                                   ahIcon, aIconId, 4, 0);
+    ok(cIcons == 4, "Four icons requested got cIcons=%d\n", cIcons);
 }
 
 static void test_LoadImage(void)




More information about the wine-cvs mailing list