Commit cb958cd7 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Test and handle the case where the SourceList key does not exist and the…

msi: Test and handle the case where the SourceList key does not exist and the PackageName value does not exist in MsiGetProductInfo.
parent dc50773c
...@@ -791,8 +791,15 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute, ...@@ -791,8 +791,15 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
if (!lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGENAMEW)) if (!lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGENAMEW))
{ {
res = RegOpenKeyW(prodkey, sourcelist, &source); res = RegOpenKeyW(prodkey, sourcelist, &source);
if (res == ERROR_SUCCESS) if (res != ERROR_SUCCESS)
val = msi_reg_get_value(source, szAttribute, &type); {
r = ERROR_UNKNOWN_PRODUCT;
goto done;
}
val = msi_reg_get_value(source, szAttribute, &type);
if (!val)
val = empty;
RegCloseKey(source); RegCloseKey(source);
} }
......
...@@ -3649,12 +3649,31 @@ static void test_MsiGetProductInfo(void) ...@@ -3649,12 +3649,31 @@ static void test_MsiGetProductInfo(void)
ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf); ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
ok(sz == 2, "Expected 2, got %d\n", sz); ok(sz == 2, "Expected 2, got %d\n", sz);
/* SourceList key does not exist */
sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
ok(r == ERROR_UNKNOWN_PRODUCT,
"Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
ok(!lstrcmpA(buf, "apple"),
"Expected buf to be unchanged, got \"%s\"\n", buf);
ok(sz == MAX_PATH, "Expected sz to be unchanged, got %d\n", sz);
res = RegCreateKeyA(prodkey, "SourceList", &source); res = RegCreateKeyA(prodkey, "SourceList", &source);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* SourceList key exists, but PackageName val does not exist */
sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
ok(sz == 0, "Expected 0, got %d\n", sz);
res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9); res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* PackageName val exists */
sz = MAX_PATH; sz = MAX_PATH;
lstrcpyA(buf, "apple"); lstrcpyA(buf, "apple");
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz); r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment