shell32: Add tests for ShellExecute()'s handling of file URLs.
Francois Gouget
fgouget at codeweavers.com
Wed Sep 19 13:12:37 CDT 2012
As a first step for bug 22929 and bug 27569.
---
dlls/shell32/tests/shlexec.c | 115 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index 7434702..756f720 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -1305,6 +1305,116 @@ static void test_filename(void)
}
}
+typedef struct
+{
+ const char* urlprefix;
+ const char* basename;
+ int flags;
+ int todo;
+ int rc;
+} fileurl_tests_t;
+
+#define USE_COLON 0x80
+#define USE_BSLASH 0x40
+
+static fileurl_tests_t fileurl_tests[]=
+{
+ {"file:/", "%s\\nonexistent.shlexec", 0, 0x1, SE_ERR_PNF},
+ {"file:/", "%s\\test file.shlexec", 0, 0x1, 33},
+ {"file://", "%s\\test file.shlexec", 0, 0x1, 33},
+ {"file:///", "%s\\test file.shlexec", 0, 0x1, 33},
+ {"File:///", "%s\\test file.shlexec", 0, 0x1, 33},
+ {"file:///", "%s\\test file.shlexec", USE_COLON, 0x1, 33},
+ {"file:///", "%s\\test file.shlexec", USE_BSLASH, 0x1, 33},
+ {"file:////", "%s\\test file.shlexec", 0, 0x1, 33},
+ {"file://///", "%s\\test file.shlexec", 0, 0x1, SE_ERR_PNF},
+ {"file://localhost/", "%s\\test file.shlexec", 0, 0x1, 33},
+ {"file://localhost:80/", "%s\\test file.shlexec", 0, 0x1, SE_ERR_PNF},
+ {"file://LocalHost/", "%s\\test file.shlexec", 0, 0x1, 33},
+ {"file://127.0.0.1/", "%s\\test file.shlexec", 0, 0x1, SE_ERR_PNF},
+ {"file://::1/", "%s\\test file.shlexec", 0, 0x1, SE_ERR_PNF},
+ {"file://notahost/", "%s\\test file.shlexec", 0, 0x1, SE_ERR_PNF},
+ {"file://www.winehq.org/", "%s\\test file.shlexec", 0, 0x1, SE_ERR_PNF},
+
+ {NULL, NULL, 0, 0, 0}
+};
+
+static void test_fileurl(void)
+{
+ char filename[MAX_PATH], fileurl[MAX_PATH], longtmpdir[MAX_PATH];
+ const fileurl_tests_t* test;
+ char *s;
+ int rc;
+
+ GetLongPathName(tmpdir, longtmpdir, sizeof(longtmpdir)/sizeof(*longtmpdir));
+
+ test=fileurl_tests;
+ while (test->basename)
+ {
+ if (skip_noassoc_tests && test->rc == SE_ERR_NOASSOC)
+ {
+ win_skip("Skipping shellexecute of file with unassociated extension\n");
+ test++;
+ continue;
+ }
+
+ sprintf(filename, test->basename, longtmpdir);
+ strcpy(fileurl, test->urlprefix);
+ strcat(fileurl, filename);
+ s = fileurl + strlen(test->urlprefix);
+ while (*s)
+ {
+ if (!(test->flags & USE_COLON) && *s==':')
+ *s='|';
+ else if (!(test->flags & USE_BSLASH) && *s=='\\')
+ *s='/';
+ s++;
+ }
+ rc=shell_execute(NULL, fileurl, NULL, NULL);
+ if (rc > 32)
+ rc=33;
+ if ((test->todo & 0x1)==0)
+ {
+ ok(rc==test->rc,
+ "%s failed: rc=%d err=%d\n", shell_call,
+ rc, GetLastError());
+ }
+ else todo_wine
+ {
+ ok(rc==test->rc, "%s failed: rc=%d err=%d\n", shell_call,
+ rc, GetLastError());
+ }
+ if (rc == 33)
+ {
+ if ((test->todo & 0x2)==0)
+ {
+ okChildInt("argcA", 5);
+ }
+ else todo_wine
+ {
+ okChildInt("argcA", 5);
+ }
+ if ((test->todo & 0x4)==0)
+ {
+ okChildString("argvA3", "Open");
+ }
+ else todo_wine
+ {
+ okChildString("argvA3", "Open");
+ }
+ if ((test->todo & 0x8)==0)
+ {
+ okChildPath("argvA4", filename);
+ }
+ else todo_wine
+ {
+ okChildPath("argvA4", filename);
+ }
+ }
+ test++;
+ }
+}
+
static void test_find_executable(void)
{
char notepad_path[MAX_PATH];
@@ -2296,9 +2406,13 @@ START_TEST(shlexec)
init_test();
+#if 0
test_argify();
test_lpFile_parsed();
test_filename();
+#endif
+ test_fileurl();
+#if 0
test_find_executable();
test_lnks();
test_exes();
@@ -2308,6 +2422,7 @@ START_TEST(shlexec)
test_commandline();
test_directory();
test_trojans();
+#endif
cleanup_test();
}
--
1.7.10.4
More information about the wine-patches
mailing list