msi: Add tests for MsiGetComponentPath.

This commit is contained in:
James Hawkins 2007-12-04 21:33:37 -06:00 committed by Alexandre Julliard
parent 5f3dd23f10
commit ced84f5b53
1 changed files with 393 additions and 0 deletions

View File

@ -976,6 +976,398 @@ static void test_MsiQueryComponentState(void)
RegCloseKey(compkey);
}
static void test_MsiGetComponentPath(void)
{
HKEY compkey, prodkey, installprop;
CHAR prodcode[MAX_PATH];
CHAR prod_squashed[MAX_PATH];
CHAR component[MAX_PATH];
CHAR comp_base85[MAX_PATH];
CHAR comp_squashed[MAX_PATH];
CHAR keypath[MAX_PATH];
CHAR path[MAX_PATH];
INSTALLSTATE state;
LPSTR usersid;
DWORD size, val;
LONG res;
create_test_guid(prodcode, prod_squashed);
compose_base85_guid(component, comp_base85, comp_squashed);
get_user_sid(&usersid);
/* NULL szProduct */
size = MAX_PATH;
state = MsiGetComponentPathA(NULL, component, path, &size);
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
/* NULL szComponent */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, NULL, path, &size);
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
/* NULL lpPathBuf */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, NULL, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
/* NULL pcchBuf */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, NULL);
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
/* all params valid */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
lstrcatA(keypath, comp_squashed);
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local system component key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
lstrcatA(keypath, prod_squashed);
lstrcatA(keypath, "\\InstallProperties");
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
val = 1;
res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* install properties key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(compkey, "");
RegDeleteValueA(installprop, "WindowsInstaller");
RegDeleteKeyA(installprop, "");
RegCloseKey(compkey);
RegCloseKey(installprop);
DeleteFileA("C:\\imapath");
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\");
lstrcatA(keypath, usersid);
lstrcatA(keypath, "\\Components\\");
lstrcatA(keypath, comp_squashed);
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* user managed component key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
lstrcatA(keypath, prod_squashed);
lstrcatA(keypath, "\\InstallProperties");
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
val = 1;
res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* install properties key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(compkey, "");
RegDeleteValueA(installprop, "WindowsInstaller");
RegDeleteKeyA(installprop, "");
RegCloseKey(compkey);
RegCloseKey(installprop);
DeleteFileA("C:\\imapath");
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\Managed\\");
lstrcatA(keypath, usersid);
lstrcatA(keypath, "\\Installer\\Products\\");
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* user managed product key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\");
lstrcatA(keypath, usersid);
lstrcatA(keypath, "\\Components\\");
lstrcatA(keypath, comp_squashed);
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* user managed component key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
lstrcatA(keypath, prod_squashed);
lstrcatA(keypath, "\\InstallProperties");
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
val = 1;
res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* install properties key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(prodkey, "");
RegDeleteKeyA(compkey, "");
RegDeleteValueA(installprop, "WindowsInstaller");
RegDeleteKeyA(installprop, "");
RegCloseKey(prodkey);
RegCloseKey(compkey);
RegCloseKey(installprop);
DeleteFileA("C:\\imapath");
lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* user unmanaged product key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\");
lstrcatA(keypath, usersid);
lstrcatA(keypath, "\\Components\\");
lstrcatA(keypath, comp_squashed);
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* user unmanaged component key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(prodkey, "");
RegDeleteKeyA(compkey, "");
RegCloseKey(prodkey);
RegCloseKey(compkey);
RegCloseKey(installprop);
DeleteFileA("C:\\imapath");
lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
lstrcatA(keypath, prod_squashed);
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local classes product key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
lstrcatA(keypath, comp_squashed);
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local user component key exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* product value exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
create_file("C:\\imapath", "C:\\imapath", 11);
/* file exists */
size = MAX_PATH;
state = MsiGetComponentPathA(prodcode, component, path, &size);
todo_wine
{
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
ok(size == 10, "Expected 10, got %d\n", size);
}
RegDeleteValueA(compkey, prod_squashed);
RegDeleteKeyA(prodkey, "");
RegDeleteKeyA(compkey, "");
RegCloseKey(prodkey);
RegCloseKey(compkey);
DeleteFileA("C:\\imapath");
}
START_TEST(msi)
{
init_functionpointers();
@ -987,4 +1379,5 @@ START_TEST(msi)
test_MsiQueryProductState();
test_MsiQueryFeatureState();
test_MsiQueryComponentState();
test_MsiGetComponentPath();
}