tests: APIs not defined on some platforms

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

 




Changelog:

 * dlls/netapi32/tests/wksta.c,
   dlls/shlwapi/tests/shreg.c

   NetpGetComputerName, SHCopyKeyA and SHRegGetPathA don't exist on all
Windows platforms -> use LoadLibrary + GetProcAddress


Index: dlls/netapi32/tests/wksta.c
===================================================================
RCS file: /home/wine/wine/dlls/netapi32/tests/wksta.c,v
retrieving revision 1.1
diff -u -r1.1 wksta.c
--- dlls/netapi32/tests/wksta.c	11 Sep 2002 02:35:18 -0000	1.1
+++ dlls/netapi32/tests/wksta.c	16 Sep 2002 09:27:14 -0000
@@ -27,16 +27,24 @@
 #include "lmwksta.h"
 #include "lmapibuf.h"

-NET_API_STATUS WINAPI NetpGetComputerName(LPWSTR *Buffer);
+typedef NET_API_STATUS (WINAPI *NetpGetComputerName_func)(LPWSTR *Buffer);

 void run_get_comp_name_tests(void)
 {
-    WCHAR empty[] = {0};
-    LPWSTR ws = empty;
-
-    ok(NetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved");
-    ok(ws[0] != 0, "Some value is populated to the buffer");
-    NetApiBufferFree(ws);
+    HANDLE hnetapi32 = LoadLibraryA("netapi32.dll");
+    if (hnetapi32)
+    {
+        WCHAR empty[] = {0};
+        LPWSTR ws = empty;
+        NetpGetComputerName_func pNetpGetComputerName;
+        pNetpGetComputerName = (NetpGetComputerName_func)GetProcAddress(hnetapi32,"NetpGetComputerName");
+        if (pNetpGetComputerName)
+        {
+            ok((*pNetpGetComputerName)(&ws) == NERR_Success, "Computer name is retrieved");
+            ok(ws[0] != 0, "Some value is populated to the buffer");
+            NetApiBufferFree(ws);
+        }
+    }
 }

 void run_usergetinfo_tests(void)
Index: dlls/shlwapi/tests/shreg.c
===================================================================
RCS file: /home/wine/wine/dlls/shlwapi/tests/shreg.c,v
retrieving revision 1.9
diff -u -r1.9 shreg.c
--- dlls/shlwapi/tests/shreg.c	12 Sep 2002 22:29:58 -0000	1.9
+++ dlls/shlwapi/tests/shreg.c	16 Sep 2002 09:27:19 -0000
@@ -32,6 +32,12 @@
 #define REG_TEST_KEY        "Software\\Wine\\Test"
 #define REG_CURRENT_VERSION "Software\\Microsoft\\Windows NT\\CurrentVersion"

+static HMODULE hshlwapi=NULL;
+typedef DWORD (WINAPI *SHCopyKeyA_func)(HKEY,LPCSTR,HKEY,DWORD);
+static SHCopyKeyA_func pSHCopyKeyA;
+typedef DWORD (WINAPI *SHRegGetPathA_func)(HKEY,LPCSTR,LPCSTR,LPSTR,DWORD);
+static SHRegGetPathA_func pSHRegGetPathA;
+
 static char * sTestpath1 = "%LONGSYSTEMVAR%\\subdir1";
 static char * sTestpath2 = "%FOO%\\subdir1";

@@ -112,8 +118,11 @@
 {
 	char buf[MAX_PATH];

+	if (!pSHRegGetPathA)
+		return;
+
 	strcpy(buf, sEmptyBuffer);
-	ok(! SHRegGetPathA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", buf, 0), "SHRegGetPathA failed");
+	ok(! (*pSHRegGetPathA)(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", buf, 0), "SHRegGetPathA failed");
 	ok( 0 == strcmp(sExpTestpath1, buf) , "(%s)", buf);
 }

@@ -214,7 +223,6 @@
 	RegCloseKey(hKey);
 }

-
 static void test_SHCopyKey(void)
 {
 	HKEY hKeySrc, hKeyDst;
@@ -242,7 +250,8 @@
 	}


-	ok (!SHCopyKeyA(hKeyDst, NULL, hKeySrc, 0), "failed copy");
+	if (pSHCopyKeyA)
+		ok (!(*pSHCopyKeyA)(hKeyDst, NULL, hKeySrc, 0), "failed copy");

 	RegCloseKey(hKeySrc);
 	RegCloseKey(hKeyDst);
@@ -265,6 +274,12 @@
 START_TEST(shreg)
 {
 	HKEY hkey = create_test_entries();
+	hshlwapi = LoadLibraryA("shlwapi.dll");
+	if (hshlwapi)
+	{
+		pSHCopyKeyA=(SHCopyKeyA_func)GetProcAddress(hshlwapi,"SHCopyKeyA");
+		pSHRegGetPathA=(SHRegGetPathA_func)GetProcAddress(hshlwapi,"SHRegGetPathA");
+	}
 	test_SHGetValue();
 	test_SHQUeryValueEx();
 	test_SHGetRegPath();



-- 
Francois Gouget         fgouget@free.fr        http://fgouget.free.fr/
                     f u kn rd ts, ur wy 2 gky 4 ur wn gd.



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

  Powered by Linux