msi: Add tests for MsiEnumProducts.

This commit is contained in:
Hans Leidekker 2009-03-27 13:40:59 +01:00 committed by Alexandre Julliard
parent 9163b0d0a3
commit f0d1d61d3b

View File

@ -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();