Sysparams test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changelog:

 * dlls/user/tests/sysparams.c

   Check for sysparams keys in either the Win9x or NT locations. this
makes the test succeed on Win9x and NT4 platforms.
   Add a 'strict' mode which specifically makes sure that the NT
location is set.
   In strict mode the test succeeds on Windows XP and Wine.


Index: dlls/user/tests/sysparams.c
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/sysparams.c,v
retrieving revision 1.12
diff -u -r1.12 sysparams.c
--- dlls/user/tests/sysparams.c	16 Jan 2003 00:19:24 -0000	1.12
+++ dlls/user/tests/sysparams.c	17 Jan 2003 20:31:05 -0000
@@ -37,6 +37,8 @@
 # define SPI_GETDESKWALLPAPER 0x0073
 #endif

+static int strict;
+
 #define eq(received, expected, label, type) \
         ok((received) == (expected), "%s: got " type " instead of " type, (label),(received),(expected))

@@ -59,13 +61,17 @@
 #define SPI_SETGRIDGRANULARITY_VALNAME          "GridGranularity"
 #define SPI_SETKEYBOARDDELAY_REGKEY             "Control Panel\\Keyboard"
 #define SPI_SETKEYBOARDDELAY_VALNAME            "KeyboardDelay"
-#define SPI_SETICONTITLEWRAP_REGKEY             "Control Panel\\Desktop\\WindowMetrics"
+#define SPI_SETICONTITLEWRAP_REGKEY1            "Control Panel\\Desktop\\WindowMetrics"
+#define SPI_SETICONTITLEWRAP_REGKEY2            "Control Panel\\Desktop"
 #define SPI_SETICONTITLEWRAP_VALNAME            "IconTitleWrap"
-#define SPI_SETMENUDROPALIGNMENT_REGKEY         "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
+#define SPI_SETMENUDROPALIGNMENT_REGKEY1        "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
+#define SPI_SETMENUDROPALIGNMENT_REGKEY2        "Control Panel\\Desktop"
 #define SPI_SETMENUDROPALIGNMENT_VALNAME        "MenuDropAlignment"
-#define SPI_SETDOUBLECLKWIDTH_REGKEY            "Control Panel\\Mouse"
+#define SPI_SETDOUBLECLKWIDTH_REGKEY1           "Control Panel\\Mouse"
+#define SPI_SETDOUBLECLKWIDTH_REGKEY2           "Control Panel\\Desktop"
 #define SPI_SETDOUBLECLKWIDTH_VALNAME           "DoubleClickWidth"
-#define SPI_SETDOUBLECLKHEIGHT_REGKEY           "Control Panel\\Mouse"
+#define SPI_SETDOUBLECLKHEIGHT_REGKEY1          "Control Panel\\Mouse"
+#define SPI_SETDOUBLECLKHEIGHT_REGKEY2          "Control Panel\\Desktop"
 #define SPI_SETDOUBLECLKHEIGHT_VALNAME          "DoubleClickHeight"
 #define SPI_SETDOUBLECLICKTIME_REGKEY           "Control Panel\\Mouse"
 #define SPI_SETDOUBLECLICKTIME_VALNAME          "DoubleClickSpeed"
@@ -148,23 +154,55 @@
  * lpsRegName - registry entry name
  * lpsTestValue - value to test
  */
-static void _test_reg_key( LPSTR subKey, LPSTR valName, LPSTR testValue, char *file, int line )
+static void _test_reg_key( LPSTR subKey1, LPSTR subKey2, LPSTR valName, LPSTR testValue )
 {
-    CHAR  value[MAX_PATH] = "";
-    DWORD valueLen = MAX_PATH;
+    CHAR  value[MAX_PATH];
+    DWORD valueLen;
     DWORD type;
     HKEY hKey;
+    LONG rc;
+    int found=0;

-    RegOpenKeyA( HKEY_CURRENT_USER, subKey, &hKey );
-    RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
+    *value='\0';
+    valueLen=sizeof(value);
+    RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey );
+    rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
     RegCloseKey( hKey );
-    ok( !strcmp( testValue, value ),
-        "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s",
-        subKey, valName, testValue, value );
+    if (rc==ERROR_SUCCESS)
+    {
+        ok( !strcmp( testValue, value ),
+            "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s",
+            subKey1, valName, testValue, value );
+        found++;
+    }
+    else if (strict)
+    {
+        ok(0,"Missing registry entry: subKey=%s, valName=%s",
+           subKey1, valName);
+    }
+    if (subKey2 && !strict)
+    {
+        *value='\0';
+        valueLen=sizeof(value);
+        RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey );
+        rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
+        RegCloseKey( hKey );
+        if (rc==ERROR_SUCCESS)
+        {
+            ok( !strcmp( testValue, value ),
+                "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s",
+                subKey2, valName, testValue, value );
+            found++;
+        }
+    }
+    ok(found,"Missing registry entry: %s in %s or %s",
+       valName, subKey1, (subKey2?subKey2:"<n/a>") );
 }

 #define test_reg_key( subKey, valName, testValue ) \
-    _test_reg_key( subKey, valName, testValue, __FILE__, __LINE__ )
+    _test_reg_key( subKey, NULL, valName, testValue )
+#define test_reg_key_ex( subKey1, subKey2, valName, testValue ) \
+    _test_reg_key( subKey1, subKey2, valName, testValue )

 static void test_SPI_SETBEEP( void )                   /*      2 */
 {
@@ -653,9 +691,10 @@
                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
         test_change_message( SPI_SETICONTITLEWRAP, 1 );
-        test_reg_key( SPI_SETICONTITLEWRAP_REGKEY,
-                      SPI_SETICONTITLEWRAP_VALNAME,
-                      vals[i] ? "1" : "0" );
+        test_reg_key_ex( SPI_SETICONTITLEWRAP_REGKEY1,
+                         SPI_SETICONTITLEWRAP_REGKEY2,
+                         SPI_SETICONTITLEWRAP_VALNAME,
+                         vals[i] ? "1" : "0" );

         rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &v, 0 );
         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
@@ -685,9 +724,10 @@
                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
         test_change_message( SPI_SETMENUDROPALIGNMENT, 0 );
-        test_reg_key( SPI_SETMENUDROPALIGNMENT_REGKEY,
-                      SPI_SETMENUDROPALIGNMENT_VALNAME,
-                      vals[i] ? "1" : "0" );
+        test_reg_key_ex( SPI_SETMENUDROPALIGNMENT_REGKEY1,
+                         SPI_SETMENUDROPALIGNMENT_REGKEY2,
+                         SPI_SETMENUDROPALIGNMENT_VALNAME,
+                         vals[i] ? "1" : "0" );

         rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &v, 0 );
         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
@@ -720,8 +760,9 @@
         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
         test_change_message( SPI_SETDOUBLECLKWIDTH, 0 );
         sprintf( buf, "%d", vals[i] );
-        test_reg_key( SPI_SETDOUBLECLKWIDTH_REGKEY,
-                      SPI_SETDOUBLECLKWIDTH_VALNAME, buf );
+        test_reg_key_ex( SPI_SETDOUBLECLKWIDTH_REGKEY1,
+                         SPI_SETDOUBLECLKWIDTH_REGKEY2,
+                         SPI_SETDOUBLECLKWIDTH_VALNAME, buf );
         eq( GetSystemMetrics( SM_CXDOUBLECLK ), (int)vals[i],
             "SM_CXDOUBLECLK", "%d" );
     }
@@ -750,8 +791,9 @@
         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
         test_change_message( SPI_SETDOUBLECLKHEIGHT, 0 );
         sprintf( buf, "%d", vals[i] );
-        test_reg_key( SPI_SETDOUBLECLKHEIGHT_REGKEY,
-                      SPI_SETDOUBLECLKHEIGHT_VALNAME, buf );
+        test_reg_key_ex( SPI_SETDOUBLECLKHEIGHT_REGKEY1,
+                         SPI_SETDOUBLECLKHEIGHT_REGKEY2,
+                         SPI_SETDOUBLECLKHEIGHT_VALNAME, buf );
         eq( GetSystemMetrics( SM_CYDOUBLECLK ), (int)vals[i],
             "SM_CYDOUBLECLK", "%d" );
     }
@@ -1054,11 +1096,17 @@

 START_TEST(sysparams)
 {
+    int argc;
+    char** argv;
     WNDCLASSA wc;
     MSG msg;
     HANDLE hThread;
     DWORD dwThreadId;
     HANDLE hInstance = GetModuleHandleA( NULL );
+
+    argc = winetest_get_mainargs(&argv);
+    strict=(argc >= 3 && strcmp(argv[2],"strict")==0);
+    trace("strict=%d\n",strict);

     change_counter = 0;
     change_last_param = 0;



-- 
Francois Gouget         fgouget@free.fr        http://fgouget.free.fr/
In theory, theory and practice are the same, but in practice they're different.



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux