James Hawkins : advpack: Add initial tests for SetPerUserSecValues.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Apr 6 15:27:08 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: a7e055e0bd9e1164493a2677dd1fb1c855a2d045
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=a7e055e0bd9e1164493a2677dd1fb1c855a2d045

Author: James Hawkins <truiken at gmail.com>
Date:   Thu Apr  6 03:48:49 2006 -0500

advpack: Add initial tests for SetPerUserSecValues.

---

 dlls/advpack/tests/advpack.c |  111 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 110 insertions(+), 1 deletions(-)

diff --git a/dlls/advpack/tests/advpack.c b/dlls/advpack/tests/advpack.c
index 857458b..15cf3fc 100644
--- a/dlls/advpack/tests/advpack.c
+++ b/dlls/advpack/tests/advpack.c
@@ -25,13 +25,20 @@
 #include <assert.h>
 #include "wine/test.h"
 
+/* defines for the TranslateInfString/Ex tests */
 #define TEST_STRING1 "\\Application Name"
 #define TEST_STRING2 "%49001%\\Application Name"
 
+/* defines for the SetPerUserSecValues tests */
+#define GUID_KEY    "SOFTWARE\\Microsoft\\Active Setup\\Installed Components\\guid"
+#define REG_VAL_EXISTS(key, value)   !RegQueryValueEx(key, value, NULL, NULL, NULL, NULL)
+#define OPEN_GUID_KEY() !RegOpenKey(HKEY_LOCAL_MACHINE, GUID_KEY, &guid)
+
 static HRESULT (WINAPI *pCloseINFEngine)(HINF);
 static HRESULT (WINAPI *pDelNode)(LPCSTR,DWORD);
 static HRESULT (WINAPI *pGetVersionFromFile)(LPSTR,LPDWORD,LPDWORD,BOOL);
 static HRESULT (WINAPI *pOpenINFEngine)(PCSTR,PCSTR,DWORD,HINF*,PVOID);
+static HRESULT (WINAPI *pSetPerUserSecValues)(PPERUSERSECTION pPerUser);
 static HRESULT (WINAPI *pTranslateInfString)(LPSTR,LPSTR,LPSTR,LPSTR,LPSTR,DWORD,LPDWORD,LPVOID);
 static HRESULT (WINAPI *pTranslateInfStringEx)(HINF,PCSTR,PCSTR,PCSTR,PSTR,DWORD,PDWORD,PVOID);
 
@@ -62,11 +69,12 @@ static BOOL init_function_pointers(void)
     pDelNode = (void *)GetProcAddress(hAdvPack, "DelNode");
     pGetVersionFromFile = (void *)GetProcAddress(hAdvPack, "GetVersionFromFile");
     pOpenINFEngine = (void*)GetProcAddress(hAdvPack, "OpenINFEngine");
+    pSetPerUserSecValues = (void*)GetProcAddress(hAdvPack, "SetPerUserSecValues");
     pTranslateInfString = (void *)GetProcAddress(hAdvPack, "TranslateInfString");
     pTranslateInfStringEx = (void*)GetProcAddress(hAdvPack, "TranslateInfStringEx");
 
     if (!pCloseINFEngine || !pDelNode || !pGetVersionFromFile ||
-        !pOpenINFEngine || !pTranslateInfString)
+        !pOpenINFEngine || !pSetPerUserSecValues || !pTranslateInfString)
         return FALSE;
 
     return TRUE;
@@ -389,6 +397,106 @@ static void translateinfstringex_test(vo
     DeleteFileA("c:\\test.inf");
 }
 
+static BOOL check_reg_str(HKEY hkey, LPSTR name, LPSTR value)
+{
+    DWORD size = MAX_PATH;
+    char check[MAX_PATH];
+
+    if (RegQueryValueEx(hkey, name, NULL, NULL, (LPBYTE)check, &size))
+        return FALSE;
+
+    return !lstrcmp(check, value);
+}
+
+static BOOL check_reg_dword(HKEY hkey, LPSTR name, DWORD value)
+{
+    DWORD size = sizeof(DWORD);
+    DWORD check;
+
+    if (RegQueryValueEx(hkey, name, NULL, NULL, (LPBYTE)&check, &size))
+        return FALSE;
+
+    return (check == value);
+}
+
+static void setperusersecvalues_test()
+{
+    PERUSERSECTION peruser;
+    HRESULT hr;
+    HKEY guid;
+
+    lstrcpy(peruser.szGUID, "guid");
+    lstrcpy(peruser.szDispName, "displayname");
+    lstrcpy(peruser.szLocale, "locale");
+    lstrcpy(peruser.szStub, "stub");
+    lstrcpy(peruser.szVersion, "1,1,1,1");
+    lstrcpy(peruser.szCompID, "compid");
+    peruser.dwIsInstalled = 1;
+    peruser.bRollback = FALSE;
+
+    /* set initial values */
+    hr = pSetPerUserSecValues(&peruser);
+    todo_wine
+    {
+        ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
+        ok(OPEN_GUID_KEY(), "Expected guid key to exist\n");
+        ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");
+        ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n");
+        ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n");
+        ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n");
+        ok(check_reg_str(guid, "Version", "1,1,1,1"), "Expected 1,1,1,1\n");
+        ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n");
+    }
+    ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n");
+    ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n");
+    ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n");
+    ok(!REG_VAL_EXISTS(guid, "OldVersion"), "Expected OldVersion to not exist\n");
+    ok(!REG_VAL_EXISTS(guid, "RealStubPath"), "Expected RealStubPath to not exist\n");
+
+    /* raise the version, but bRollback is FALSE, so vals not saved */
+    lstrcpy(peruser.szVersion, "2,1,1,1");
+    hr = pSetPerUserSecValues(&peruser);
+    todo_wine
+    {
+        ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
+        ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");
+        ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n");
+        ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n");
+        ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n");
+        ok(check_reg_str(guid, "Version", "2,1,1,1"), "Expected 2,1,1,1\n");
+        ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n");
+    }
+    ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n");
+    ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n");
+    ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n");
+    ok(!REG_VAL_EXISTS(guid, "OldVersion"), "Expected OldVersion to not exist\n");
+    ok(!REG_VAL_EXISTS(guid, "RealStubPath"), "Expected RealStubPath to not exist\n");
+
+    /* raise the version again, bRollback is TRUE so vals are saved */
+    peruser.bRollback = 1;
+    lstrcpy(peruser.szVersion, "3,1,1,1");
+    hr = pSetPerUserSecValues(&peruser);
+    todo_wine
+    {
+        ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
+        ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");
+        ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n");
+        ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n");
+        ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n");
+        ok(check_reg_str(guid, "OldDisplayName", "displayname"), "Expected displayname\n");
+        ok(check_reg_str(guid, "OldLocale", "locale"), "Expected locale\n");
+        ok(check_reg_str(guid, "RealStubPath", "stub"), "Expected stub\n");
+        ok(check_reg_str(guid, "OldStubPath", "stub"), "Expected stub\n");
+        ok(check_reg_str(guid, "OldVersion", "2,1,1,1"), "Expected 2,1,1,1\n");
+        ok(check_reg_str(guid, "StubPath",
+           "rundll32.exe advpack.dll,UserInstStubWrapper guid"),
+           "Expected real stub\n");
+        ok(check_reg_str(guid, "Version", "3,1,1,1"), "Expected 3,1,1,1\n");
+    }
+
+    RegDeleteKey(HKEY_LOCAL_MACHINE, GUID_KEY);
+}
+
 START_TEST(advpack)
 {
     if (!init_function_pointers())
@@ -398,6 +506,7 @@ START_TEST(advpack)
 
     version_test();
     delnode_test();
+    setperusersecvalues_test();
     translateinfstring_test();
     translateinfstringex_test();
 }




More information about the wine-cvs mailing list