shell32/tests: Add more ShellExecute() shortcut tests.

This commit is contained in:
Francois Gouget 2012-10-05 10:40:03 +02:00 committed by Alexandre Julliard
parent 0931522795
commit ab654c63cf
1 changed files with 45 additions and 20 deletions

View File

@ -88,6 +88,9 @@ static void strcat_param(char* str, const char* name, const char* param)
} }
} }
static int _todo_wait = 0;
#define todo_wait for (_todo_wait = 1; _todo_wait; _todo_wait = 0)
static char shell_call[2048]=""; static char shell_call[2048]="";
static int bad_shellexecute = 0; static int bad_shellexecute = 0;
static INT_PTR shell_execute(LPCSTR operation, LPCSTR file, LPCSTR parameters, LPCSTR directory) static INT_PTR shell_execute(LPCSTR operation, LPCSTR file, LPCSTR parameters, LPCSTR directory)
@ -130,7 +133,10 @@ static INT_PTR shell_execute(LPCSTR operation, LPCSTR file, LPCSTR parameters, L
rc = SE_ERR_NOASSOC; rc = SE_ERR_NOASSOC;
} }
} }
ok(wait_rc==WAIT_OBJECT_0 || rc <= 32, "%s WaitForSingleObject returned %d\n", shell_call, wait_rc); if (!_todo_wait)
ok(wait_rc==WAIT_OBJECT_0 || rc <= 32, "%s WaitForSingleObject returned %d\n", shell_call, wait_rc);
else todo_wine
ok(wait_rc==WAIT_OBJECT_0 || rc <= 32, "%s WaitForSingleObject returned %d\n", shell_call, wait_rc);
} }
/* The child process may have changed the result file, so let profile /* The child process may have changed the result file, so let profile
* functions know about it * functions know about it
@ -151,7 +157,8 @@ static INT_PTR shell_execute(LPCSTR operation, LPCSTR file, LPCSTR parameters, L
} }
static INT_PTR shell_execute_ex(DWORD mask, LPCSTR operation, LPCSTR file, static INT_PTR shell_execute_ex(DWORD mask, LPCSTR operation, LPCSTR file,
LPCSTR parameters, LPCSTR directory) LPCSTR parameters, LPCSTR directory,
LPCSTR class)
{ {
SHELLEXECUTEINFO sei; SHELLEXECUTEINFO sei;
BOOL success; BOOL success;
@ -168,6 +175,7 @@ static INT_PTR shell_execute_ex(DWORD mask, LPCSTR operation, LPCSTR file,
strcat_param(shell_call, "file", file); strcat_param(shell_call, "file", file);
strcat_param(shell_call, "params", parameters); strcat_param(shell_call, "params", parameters);
strcat_param(shell_call, "dir", directory); strcat_param(shell_call, "dir", directory);
strcat_param(shell_call, "class", class);
strcat(shell_call, ")"); strcat(shell_call, ")");
if (winetest_debug > 1) if (winetest_debug > 1)
trace("%s\n", shell_call); trace("%s\n", shell_call);
@ -182,7 +190,7 @@ static INT_PTR shell_execute_ex(DWORD mask, LPCSTR operation, LPCSTR file,
sei.nShow=SW_SHOWNORMAL; sei.nShow=SW_SHOWNORMAL;
sei.hInstApp=NULL; /* Out */ sei.hInstApp=NULL; /* Out */
sei.lpIDList=NULL; sei.lpIDList=NULL;
sei.lpClass=NULL; sei.lpClass=class;
sei.hkeyClass=NULL; sei.hkeyClass=NULL;
sei.dwHotKey=0; sei.dwHotKey=0;
U(sei).hIcon=NULL; U(sei).hIcon=NULL;
@ -204,7 +212,10 @@ static INT_PTR shell_execute_ex(DWORD mask, LPCSTR operation, LPCSTR file,
ok(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject(hProcess) returned %d\n", wait_rc); ok(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject(hProcess) returned %d\n", wait_rc);
} }
wait_rc=WaitForSingleObject(hEvent, 5000); wait_rc=WaitForSingleObject(hEvent, 5000);
ok(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", wait_rc); if (!_todo_wait)
ok(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", wait_rc);
else todo_wine
ok(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", wait_rc);
} }
/* The child process may have changed the result file, so let profile /* The child process may have changed the result file, so let profile
* functions know about it * functions know about it
@ -943,12 +954,12 @@ static void test_lpFile_parsed(void)
/* test SEE_MASK_DOENVSUBST works */ /* test SEE_MASK_DOENVSUBST works */
rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI, rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI,
NULL, "%TMPDIR%\\simple.shlexec", NULL, NULL); NULL, "%TMPDIR%\\simple.shlexec", NULL, NULL, NULL);
ok(rc > 32, "%s failed: rc=%lu\n", shell_call, rc); ok(rc > 32, "%s failed: rc=%lu\n", shell_call, rc);
/* quoted lpFile does not work on real win95 and nt4 */ /* quoted lpFile does not work on real win95 and nt4 */
rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI, rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI,
NULL, "\"%TMPDIR%\\simple.shlexec\"", NULL, NULL); NULL, "\"%TMPDIR%\\simple.shlexec\"", NULL, NULL, NULL);
ok(rc > 32 || broken(rc == SE_ERR_FNF) /* Win95/NT4 */, ok(rc > 32 || broken(rc == SE_ERR_FNF) /* Win95/NT4 */,
"%s failed: rc=%lu\n", shell_call, rc); "%s failed: rc=%lu\n", shell_call, rc);
} }
@ -1752,20 +1763,34 @@ static void test_lnks(void)
const filename_tests_t* test; const filename_tests_t* test;
INT_PTR rc; INT_PTR rc;
/* Should open through our association */
sprintf(filename, "%s\\test_shortcut_shlexec.lnk", tmpdir); sprintf(filename, "%s\\test_shortcut_shlexec.lnk", tmpdir);
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, filename, NULL, NULL); rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, filename, NULL, NULL, NULL);
ok(rc > 32, "%s failed: rc=%lu err=%u\n", shell_call, rc, ok(rc > 32, "%s failed: rc=%lu err=%u\n", shell_call, rc, GetLastError());
GetLastError());
okChildInt("argcA", 5); okChildInt("argcA", 5);
okChildString("argvA3", "Open"); okChildString("argvA3", "Open");
sprintf(params, "%s\\test file.shlexec", tmpdir); sprintf(params, "%s\\test file.shlexec", tmpdir);
get_long_path_name(params, filename, sizeof(filename)); get_long_path_name(params, filename, sizeof(filename));
okChildPath("argvA4", filename); okChildPath("argvA4", filename);
todo_wait rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_DOENVSUBST, NULL, "%TMPDIR%\\test_shortcut_shlexec.lnk", NULL, NULL, NULL);
ok(rc > 32, "%s failed: rc=%lu err=%u\n", shell_call, rc, GetLastError());
okChildInt("argcA", 5);
todo_wine okChildString("argvA3", "Open");
sprintf(params, "%s\\test file.shlexec", tmpdir);
get_long_path_name(params, filename, sizeof(filename));
todo_wine okChildPath("argvA4", filename);
/* Should just run our executable */
sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir); sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, filename, NULL, NULL); rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, filename, NULL, NULL, NULL);
ok(rc > 32, "%s failed: rc=%lu err=%u\n", shell_call, rc, ok(rc > 32, "%s failed: rc=%lu err=%u\n", shell_call, rc, GetLastError());
GetLastError()); okChildInt("argcA", 4);
okChildString("argvA3", "Lnk");
/* Lnk's ContextMenuHandler has priority over an explicit class */
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, filename, NULL, NULL, "shlexec.shlexec");
ok(rc > 32, "%s failed: rc=%lu err=%u\n", shell_call, rc, GetLastError());
okChildInt("argcA", 4); okChildInt("argcA", 4);
okChildString("argvA3", "Lnk"); okChildString("argvA3", "Lnk");
@ -1783,7 +1808,7 @@ static void test_lnks(void)
*c='/'; *c='/';
c++; c++;
} }
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, filename, NULL, NULL); rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, filename, NULL, NULL, NULL);
ok(rc > 32, "%s failed: rc=%lu err=%u\n", shell_call, rc, ok(rc > 32, "%s failed: rc=%lu err=%u\n", shell_call, rc,
GetLastError()); GetLastError());
okChildInt("argcA", 4); okChildInt("argcA", 4);
@ -1798,7 +1823,7 @@ static void test_lnks(void)
sprintf(params+1, test->basename, tmpdir); sprintf(params+1, test->basename, tmpdir);
strcat(params,"\""); strcat(params,"\"");
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, filename, params, rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, filename, params,
NULL); NULL, NULL);
if (rc > 32) if (rc > 32)
rc=33; rc=33;
if ((test->todo & 0x1)==0) if ((test->todo & 0x1)==0)
@ -1854,7 +1879,7 @@ static void test_exes(void)
/* We need NOZONECHECKS on Win2003 to block a dialog */ /* We need NOZONECHECKS on Win2003 to block a dialog */
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, argv0, params, rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, argv0, params,
NULL); NULL, NULL);
ok(rc > 32, "%s returned %lu\n", shell_call, rc); ok(rc > 32, "%s returned %lu\n", shell_call, rc);
okChildInt("argcA", 4); okChildInt("argcA", 4);
okChildString("argvA3", "Exec"); okChildString("argvA3", "Exec");
@ -1892,7 +1917,7 @@ static void test_exes_long(void)
/* We need NOZONECHECKS on Win2003 to block a dialog */ /* We need NOZONECHECKS on Win2003 to block a dialog */
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, argv0, params, rc=shell_execute_ex(SEE_MASK_NOZONECHECKS, NULL, argv0, params,
NULL); NULL, NULL);
ok(rc > 32, "%s returned %lu\n", shell_call, rc); ok(rc > 32, "%s returned %lu\n", shell_call, rc);
okChildInt("argcA", 4); okChildInt("argcA", 4);
okChildString("argvA3", longparam); okChildString("argvA3", longparam);
@ -2069,7 +2094,7 @@ static void test_dde(void)
ddeExec[0] = 0; ddeExec[0] = 0;
dde_ready_event = CreateEventA(NULL, FALSE, FALSE, "winetest_shlexec_dde_ready"); dde_ready_event = CreateEventA(NULL, FALSE, FALSE, "winetest_shlexec_dde_ready");
rc = shell_execute_ex(SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI, NULL, filename, NULL, NULL); rc = shell_execute_ex(SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI, NULL, filename, NULL, NULL, NULL);
CloseHandle(dde_ready_event); CloseHandle(dde_ready_event);
if ((test->todo & 0x1)==0) if ((test->todo & 0x1)==0)
{ {
@ -2186,7 +2211,7 @@ static DWORD CALLBACK ddeThread(LPVOID arg)
assert(info && info->filename); assert(info && info->filename);
PostThreadMessage(info->threadIdParent, PostThreadMessage(info->threadIdParent,
WM_QUIT, WM_QUIT,
shell_execute_ex(SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI, NULL, info->filename, NULL, NULL), shell_execute_ex(SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI, NULL, info->filename, NULL, NULL, NULL),
0L); 0L);
ExitThread(0); ExitThread(0);
} }
@ -2458,11 +2483,11 @@ static void test_directory(void)
sprintf(params, "shlexec \"%s\" Exec", child_file); sprintf(params, "shlexec \"%s\" Exec", child_file);
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_FLAG_NO_UI, rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_FLAG_NO_UI,
NULL, path_find_file_name(argv0), params, NULL); NULL, path_find_file_name(argv0), params, NULL, NULL);
todo_wine ok(rc == SE_ERR_FNF, "%s returned %lu\n", shell_call, rc); todo_wine ok(rc == SE_ERR_FNF, "%s returned %lu\n", shell_call, rc);
rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_FLAG_NO_UI, rc=shell_execute_ex(SEE_MASK_NOZONECHECKS|SEE_MASK_FLAG_NO_UI,
NULL, path_find_file_name(argv0), params, newdir); NULL, path_find_file_name(argv0), params, newdir, NULL);
ok(rc > 32, "%s returned %lu\n", shell_call, rc); ok(rc > 32, "%s returned %lu\n", shell_call, rc);
okChildInt("argcA", 4); okChildInt("argcA", 4);
okChildString("argvA3", "Exec"); okChildString("argvA3", "Exec");