PV> On 02/17/2010 09:51 AM, Ilya Basin wrote: >> Hi! Please comment on "try 2" of the patch. Will you accept it? >> IB> + /* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if >> TEMP is undefined */ >> IB> + SetEnvironmentVariableA("TEMP", fileA);
PV> I'm still not convinced you need this but I think that's minor. PV> I ran your tests on winetestbot and there are 2 failures for Win95 and NT4: PV> https://winetestbot.geldorp.nl/JobDetails.pl?Key=733 Added 2 win_skip's for these failures. Tested on NT4. Don't have 95 though. --- dlls/shell32/tests/shlexec.c | 98 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 0 deletions(-) mode change 100644 => 100755 dlls/shell32/tests/shlexec.c diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c old mode 100644 new mode 100755 index c673f0a..150856c --- a/dlls/shell32/tests/shlexec.c +++ b/dlls/shell32/tests/shlexec.c @@ -797,6 +797,10 @@ static const char* testfiles[]= "%s\\test file.sde", "%s\\test file.exe", "%s\\test2.exe", + "%s\\simple.shlexec", + "%s\\drawback_file.noassoc", + "%s\\drawback_file.noassoc foo.shlexec", + "%s\\drawback_nonexist.noassoc foo.shlexec", NULL }; @@ -852,6 +856,99 @@ static filename_tests_t noquotes_tests[]= {NULL, NULL, 0} }; +static void test_lpFile_parsed(void) +{ + /* basename tmpdir */ + const char* shorttmpdir; + + const char *testfile; + char fileA[MAX_PATH]; + + int rc; + int expected; + + HMODULE hkernel32 = GetModuleHandle("kernel32"); + BOOL isreallyXP_2k3_plus = NULL != GetProcAddress(hkernel32, "AttachConsole"); + BOOL isreally98_2k_plus = NULL != GetProcAddress(hkernel32, "GetLongPathNameA"); + + GetTempPathA(sizeof(fileA), fileA); + shorttmpdir = tmpdir + strlen(fileA); + + /* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if TEMP is undefined */ + SetEnvironmentVariableA("TEMP", fileA); + + #define TEST_LPFILE_PARSED_OK_() (rc==expected || rc>32 && expected>32) + #define TEST_LPFILE_PARSED_OK() ok(TEST_LPFILE_PARSED_OK_(), "expected %s (%d), got %s (%d), lpFile: %s \n", expected==33 ? "success" : "failure", expected, rc > 32 ? "success" : "failure", rc, fileA) + + /* existing "drawback_file.noassoc" prevents finding "drawback_file.noassoc foo.shlexec" on wine */ + testfile = "%s\\drawback_file.noassoc foo.shlexec"; + expected = 33; sprintf(fileA, testfile, tmpdir); + rc=shell_execute(NULL, fileA, NULL, NULL); + todo_wine { TEST_LPFILE_PARSED_OK(); } + + /* quoted lpFile not works on real win95 and nt4 */ + if (isreally98_2k_plus) { + /* if quoted, existing "drawback_file.noassoc" not prevents finding "drawback_file.noassoc foo.shlexec" on wine */ + testfile = "\"%s\\drawback_file.noassoc foo.shlexec\""; + expected = 33; sprintf(fileA, testfile, tmpdir); + rc=shell_execute(NULL, fileA, NULL, NULL); + TEST_LPFILE_PARSED_OK(); + } else { + win_skip("ShellExecute('\"command\"', ...) only works on 98/2k or newer\n"); + } + + /* error should be 2, not 31 */ + testfile = "\"%s\\drawback_file.noassoc\" foo.shlexec"; + expected = 2; sprintf(fileA, testfile, tmpdir); + rc=shell_execute(NULL, fileA, NULL, NULL); + TEST_LPFILE_PARSED_OK(); + + /* ""command"" not works on wine (and real win9x and w2k) */ + if (isreallyXP_2k3_plus) { + testfile = "\"\"%s\\simple.shlexec\"\""; + expected = 33; sprintf(fileA, testfile, tmpdir); + rc=shell_execute(NULL, fileA, NULL, NULL); + todo_wine { TEST_LPFILE_PARSED_OK(); } + } else { + win_skip("ShellExecute('\"\"command\"\"', ...) only works on XP/2k3 or newer\n"); + } + + /* nonexisting "drawback_nonexist.noassoc" not prevents finding "drawback_nonexist.noassoc foo.shlexec" on wine */ + testfile = "%s\\drawback_nonexist.noassoc foo.shlexec"; + expected = 33; sprintf(fileA, testfile, tmpdir); + rc=shell_execute(NULL, fileA, NULL, NULL); + TEST_LPFILE_PARSED_OK(); + + /* is SEE_MASK_DOENVSUBST default flag? Should only be when XP emulates 9x (XP bug or real 95 or ME behavior ?) */ + testfile = "%%TEMP%%\\%s\\simple.shlexec"; + expected = 2; sprintf(fileA, testfile, shorttmpdir); + rc=shell_execute(NULL, fileA, NULL, NULL); + todo_wine { TEST_LPFILE_PARSED_OK(); } + + /* quoted */ + testfile = "\"%%TEMP%%\\%s\\simple.shlexec\""; + expected = 2; sprintf(fileA, testfile, shorttmpdir); + rc=shell_execute(NULL, fileA, NULL, NULL); + todo_wine { TEST_LPFILE_PARSED_OK(); } + + /* test SEE_MASK_DOENVSUBST works */ + testfile = "%%TEMP%%\\%s\\simple.shlexec"; + expected = 33; sprintf(fileA, testfile, shorttmpdir); + rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI, NULL, fileA, NULL, NULL); + TEST_LPFILE_PARSED_OK(); + + /* quoted lpFile not works on real win95 and nt4 */ + if (isreally98_2k_plus) { + /* quoted */ + testfile = "\"%%TEMP%%\\%s\\simple.shlexec\""; + expected = 33; sprintf(fileA, testfile, shorttmpdir); + rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI, NULL, fileA, NULL, NULL); + TEST_LPFILE_PARSED_OK(); + } else { + win_skip("ShellExecute('\"command\"', ...) only works on 98/2k or newer\n"); + } +} + static void test_filename(void) { char filename[MAX_PATH]; @@ -1938,6 +2035,7 @@ START_TEST(shlexec) init_test(); + test_lpFile_parsed(); test_filename(); test_find_executable(); test_lnks(); -- 1.6.6.1