shell32: Add tests for ShellExecute()'s handling of file URLs. (try2)

Francois Gouget fgouget at codeweavers.com
Wed Sep 19 13:52:19 CDT 2012


As a first step for bug 22929 and bug 27569.
---

With thanks to Juan Lang for spotting the unwanted diff chunk.
The only other changes are cosmetic (they slightly reduce the line 
count while hopefully not hurting readability).


 dlls/shell32/tests/shlexec.c |   96 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index 7434702..5d3a5f3 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -1305,6 +1305,101 @@ 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];
@@ -2299,6 +2394,7 @@ START_TEST(shlexec)
     test_argify();
     test_lpFile_parsed();
     test_filename();
+    test_fileurl();
     test_find_executable();
     test_lnks();
     test_exes();
-- 
1.7.10.4



More information about the wine-patches mailing list