Hans Leidekker : msi: Add tests for MsiEnumProducts.

Alexandre Julliard julliard at winehq.org
Fri Mar 27 10:06:40 CDT 2009


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Fri Mar 27 13:40:59 2009 +0100

msi: Add tests for MsiEnumProducts.

---

 dlls/msi/tests/msi.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c
index 928e48a..13afd92 100644
--- a/dlls/msi/tests/msi.c
+++ b/dlls/msi/tests/msi.c
@@ -10874,6 +10874,76 @@ static void test_MsiGetPatchInfoEx(void)
     RegCloseKey(udprod);
 }
 
+static void test_MsiEnumProducts(void)
+{
+    UINT r;
+    int found1, found2, found3;
+    DWORD index;
+    char product1[39], product2[39], product3[39], guid[39];
+    char product_squashed1[33], product_squashed2[33], product_squashed3[33];
+    char keypath1[MAX_PATH], keypath2[MAX_PATH], keypath3[MAX_PATH];
+    char *usersid;
+    HKEY key1, key2, key3;
+
+    create_test_guid(product1, product_squashed1);
+    create_test_guid(product2, product_squashed2);
+    create_test_guid(product3, product_squashed3);
+    get_user_sid(&usersid);
+
+    strcpy(keypath1, "Software\\Classes\\Installer\\Products\\");
+    strcat(keypath1, product_squashed1);
+
+    r = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath1, &key1);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+    strcpy(keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
+    strcat(keypath2, usersid);
+    strcat(keypath2, "\\Installer\\Products\\");
+    strcat(keypath2, product_squashed2);
+
+    r = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath2, &key2);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+    strcpy(keypath3, "Software\\Microsoft\\Installer\\Products\\");
+    strcat(keypath3, product_squashed3);
+
+    r = RegCreateKeyA(HKEY_CURRENT_USER, keypath3, &key3);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+    index = 0;
+    r = MsiEnumProductsA(index, NULL);
+    ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
+
+    index = 2;
+    r = MsiEnumProductsA(index, guid);
+    ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
+
+    index = 0;
+    r = MsiEnumProductsA(index, guid);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
+
+    found1 = found2 = found3 = 0;
+    while ((r = MsiEnumProductsA(index, guid)) == ERROR_SUCCESS)
+    {
+        if (!strcmp(product1, guid)) found1 = 1;
+        if (!strcmp(product2, guid)) found2 = 1;
+        if (!strcmp(product3, guid)) found3 = 1;
+        index++;
+    }
+    ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r);
+    ok(found1, "product1 not found\n");
+    ok(found2, "product2 not found\n");
+    ok(found3, "product3 not found\n");
+
+    RegDeleteKeyA(key1, "");
+    RegDeleteKeyA(key2, "");
+    RegDeleteKeyA(key3, "");
+    RegCloseKey(key1);
+    RegCloseKey(key2);
+    RegCloseKey(key3);
+    LocalFree(usersid);
+}
+
 START_TEST(msi)
 {
     init_functionpointers();
@@ -10901,6 +10971,7 @@ START_TEST(msi)
         test_MsiEnumPatchesEx();
         test_MsiEnumPatches();
         test_MsiGetPatchInfoEx();
+        test_MsiEnumProducts();
     }
 
     test_MsiGetFileVersion();




More information about the wine-cvs mailing list