Commit 9d7ac35e authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

msi/tests: Use the custom DLL for testing deferred actions.

parent af3a2c75
...@@ -83,3 +83,38 @@ UINT WINAPI test_retval(MSIHANDLE hinst) ...@@ -83,3 +83,38 @@ UINT WINAPI test_retval(MSIHANDLE hinst)
sscanf(prop, "%u", &retval); sscanf(prop, "%u", &retval);
return retval; return retval;
} }
static void append_file(MSIHANDLE hinst, const char *filename, const char *text)
{
DWORD size;
HANDLE file = CreateFileA(filename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
ok(hinst, file != INVALID_HANDLE_VALUE, "CreateFile failed, error %u\n", GetLastError());
SetFilePointer(file, 0, NULL, FILE_END);
WriteFile(file, text, strlen(text), &size, NULL);
CloseHandle(file);
}
UINT WINAPI da_immediate(MSIHANDLE hinst)
{
char prop[300];
DWORD len = sizeof(prop);
MsiGetPropertyA(hinst, "TESTPATH", prop, &len);
append_file(hinst, prop, "one");
return ERROR_SUCCESS;
}
UINT WINAPI da_deferred(MSIHANDLE hinst)
{
char prop[300];
DWORD len = sizeof(prop);
MsiGetPropertyA(hinst, "CustomActionData", prop, &len);
append_file(hinst, prop, "two");
return ERROR_SUCCESS;
}
@ stdcall main_test(long) @ stdcall main_test(long)
@ stdcall test_retval(long) @ stdcall test_retval(long)
@ stdcall da_immediate(long)
@ stdcall da_deferred(long)
...@@ -1300,12 +1300,12 @@ static const char ft_install_exec_seq_dat[] = ...@@ -1300,12 +1300,12 @@ static const char ft_install_exec_seq_dat[] =
"InstallFinalize\t\t1500\n"; "InstallFinalize\t\t1500\n";
static const char da_custom_action_dat[] = static const char da_custom_action_dat[] =
"Action\tType\tSource\tTarget\tISComments\n" "Action\tType\tSource\tTarget\n"
"s72\ti2\tS64\tS0\tS255\n" "s72\ti2\tS64\tS0\n"
"CustomAction\tAction\n" "CustomAction\tAction\n"
"deferred\t1074\tCMDEXE\t/c if exist msitest (exit 0) else (exit 1)\t\n" "setprop\t51\tdeferred\t[TESTPATH]\n"
"immediate\t50\tCMDEXE\t/c mkdir msitest\t\n" "immediate\t1\tcustom.dll\tda_immediate\n"
"cleanup\t50\tCMDEXE\t/c rmdir msitest\t\n"; "deferred\t1025\tcustom.dll\tda_deferred\n";
static const char da_install_exec_seq_dat[] = static const char da_install_exec_seq_dat[] =
"Action\tCondition\tSequence\n" "Action\tCondition\tSequence\n"
...@@ -1315,10 +1315,10 @@ static const char da_install_exec_seq_dat[] = ...@@ -1315,10 +1315,10 @@ static const char da_install_exec_seq_dat[] =
"FileCost\t\t300\n" "FileCost\t\t300\n"
"CostFinalize\t\t400\n" "CostFinalize\t\t400\n"
"InstallInitialize\t\t500\n" "InstallInitialize\t\t500\n"
"deferred\t\t600\n" "setprop\t\t600\n"
"immediate\t\t700\n" "deferred\t\t700\n"
"InstallFinalize\t\t1100\n" "immediate\t\t800\n"
"cleanup\t\t1200\n"; "InstallFinalize\t\t1100\n";
typedef struct _msi_table typedef struct _msi_table
{ {
...@@ -6042,23 +6042,45 @@ static void test_feature_tree(void) ...@@ -6042,23 +6042,45 @@ static void test_feature_tree(void)
DeleteFileA( msifile ); DeleteFileA( msifile );
} }
static void check_file_matches(const char *filename, const char *text)
{
char buffer[200];
HANDLE file;
DWORD size;
file = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
ReadFile(file, buffer, sizeof(buffer), &size, NULL);
ok(size == strlen(text) && !memcmp(buffer, text, size), "got %.*s\n", size, buffer);
CloseHandle(file);
}
static void test_deferred_action(void) static void test_deferred_action(void)
{ {
char path[200], file[200], buffer[200];
UINT r; UINT r;
GetTempPathA(sizeof(path), path);
GetTempFileNameA(path, "da", 0, file);
sprintf(buffer, "TESTPATH=\"%s\"", file);
create_database(msifile, da_tables, sizeof(da_tables) / sizeof(da_tables[0])); create_database(msifile, da_tables, sizeof(da_tables) / sizeof(da_tables[0]));
add_custom_dll();
MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
r = MsiInstallProductA(msifile, "CMDEXE=\"cmd.exe\""); r = MsiInstallProductA(msifile, buffer);
if (r == ERROR_INSTALL_PACKAGE_REJECTED) if (r == ERROR_INSTALL_PACKAGE_REJECTED)
{ {
skip("Not enough rights to perform tests\n"); skip("Not enough rights to perform tests\n");
goto error; goto error;
} }
todo_wine
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
todo_wine
check_file_matches(file, "onetwo");
ok(DeleteFileA(file), "Directory not created\n");
error: error:
DeleteFileA(msifile); DeleteFileA(msifile);
} }
......
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