[URLMON_WINETEST] Skip test_ftp_protocol() because of timeouts. ROSTESTS-165
[reactos.git] / rostests / winetests / urlmon / misc.c
index ce3d117..7efd20d 100644 (file)
@@ -290,7 +290,6 @@ static void test_RegisterFormatEnumerator(void)
     IEnumFORMATETC_Release(format);
     IBindCtx_Release(bctx);
 }
-
 static const WCHAR url1[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
         '/','b','l','a','n','k','.','h','t','m',0};
 static const WCHAR url2[] = {'i','n','d','e','x','.','h','t','m',0};
@@ -306,9 +305,7 @@ static const WCHAR url8[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
 static const WCHAR url9[] =
     {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',
      '/','s','i','t','e','/','a','b','o','u','t',0};
-static const WCHAR url10[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
-        '.','j','p','g',0};
-static const WCHAR url11[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e','.','*','.',
+static const WCHAR url10[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e','.','*','.',
         'c','o','m',0};
 static const WCHAR url4e[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
         '.','j','p','g',0};
@@ -349,7 +346,7 @@ static const struct parse_test parse_tests[] = {
     {url4, E_FAIL, url4e, S_OK, path4,        wszFile, wszEmpty, S_OK, NULL, E_FAIL},
     {url5, E_FAIL, url5,  E_INVALIDARG, NULL, wszHttp, wszWineHQ, S_OK, wszHttpWineHQ, S_OK},
     {url6, S_OK,   url6,  E_INVALIDARG, NULL, wszAbout, NULL, E_FAIL, NULL, E_FAIL},
-    {url11, E_FAIL, url11, E_INVALIDARG,        NULL, wszHttp, wszGoogle, S_OK, wszHttpGoogle, S_OK}
+    {url10, E_FAIL, url10, E_INVALIDARG,NULL, wszHttp, wszGoogle, S_OK, wszHttpGoogle, S_OK}
 };
 
 static void test_CoInternetParseUrl(void)
@@ -472,17 +469,22 @@ static void test_CoInternetQueryInfo(void)
 }
 
 static const struct {
-    const WCHAR *url;
+    const char *url;
     const char *mime;
     HRESULT hres;
+    BOOL broken_failure;
+    const char *broken_mime;
 } mime_tests[] = {
-    {url1, "text/html", S_OK},
-    {url2, "text/html", S_OK},
-    {url3, "text/html", S_OK},
-    {url4, NULL, E_FAIL},
-    {url5, NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)},
-    {url6, NULL, E_FAIL},
-    {url7, NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)}
+    {"res://mshtml.dll/blank.htm", "text/html", S_OK},
+    {"index.htm", "text/html", S_OK},
+    {"file://c:\\Index.htm", "text/html", S_OK},
+    {"file://c:\\Index.htm?q=test", "text/html", S_OK, TRUE},
+    {"file://c:\\Index.htm#hash_part", "text/html", S_OK, TRUE},
+    {"file://c:\\Index.htm#hash_part.txt", "text/html", S_OK, FALSE, "text/plain"},
+    {"file://some%20file%2ejpg", NULL, E_FAIL},
+    {"http://www.winehq.org", NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)},
+    {"about:blank", NULL, E_FAIL},
+    {"ftp://winehq.org/file.test", NULL, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)}
 };
 
 static BYTE data1[] = "test data\n";
@@ -581,6 +583,8 @@ static BYTE data93[] = {'<','?','x','m','l',' ',' ','<','h','t','m','l','>'};
 static BYTE data94[] = {'<','h','t','m','l','>','<','?','x','m','l',' ',' '};
 static BYTE data95[] = {'{','\\','r','t','f','<','?','x','m','l',' ',' '};
 static BYTE data96[] = {'<','?','x','m','l',' '};
+static BYTE data97[] = "<body";
+static BYTE data98[] = "blah<BoDyblahblah";
 
 static const struct {
     BYTE *data;
@@ -687,6 +691,8 @@ static const struct {
     {data94, sizeof(data94), "text/html", "text/plain"},
     {data95, sizeof(data95), "text/xml", "text/richtext"},
     {data96, sizeof(data96), "text/plain"},
+    {data97, sizeof(data97), "text/html", "text/plain"},
+    {data98, sizeof(data98), "text/html", "text/plain"},
     {data1, sizeof(data1), "text/plain", NULL, NULL, "res://mshtml.dll/blank.htm"},
     {NULL, 0, "text/html", NULL, NULL, "res://mshtml.dll/blank.htm"},
     {data1, sizeof(data1), "text/plain", NULL, NULL, "res://mshtml.dll/blank.htm", "application/octet-stream"},
@@ -715,11 +721,16 @@ static void test_FindMimeFromData(void)
 
     for(i=0; i<sizeof(mime_tests)/sizeof(mime_tests[0]); i++) {
         mime = (LPWSTR)0xf0f0f0f0;
-        hres = pFindMimeFromData(NULL, mime_tests[i].url, NULL, 0, NULL, 0, &mime, 0);
+        url = a2w(mime_tests[i].url);
+        hres = pFindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
         if(mime_tests[i].mime) {
-            ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
-            ok(!strcmp_wa(mime, mime_tests[i].mime), "[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
-            CoTaskMemFree(mime);
+            ok(hres == S_OK || broken(mime_tests[i].broken_failure), "[%d] FindMimeFromData failed: %08x\n", i, hres);
+            if(hres == S_OK) {
+                ok(!strcmp_wa(mime, mime_tests[i].mime)
+                   || broken(mime_tests[i].broken_mime && !strcmp_wa(mime, mime_tests[i].broken_mime)),
+                   "[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
+                CoTaskMemFree(mime);
+            }
         }else {
             ok(hres == E_FAIL || hres == mime_tests[i].hres,
                "[%d] FindMimeFromData failed: %08x, expected %08x\n",
@@ -728,16 +739,17 @@ static void test_FindMimeFromData(void)
         }
 
         mime = (LPWSTR)0xf0f0f0f0;
-        hres = pFindMimeFromData(NULL, mime_tests[i].url, NULL, 0, text_plainW, 0, &mime, 0);
+        hres = pFindMimeFromData(NULL, url, NULL, 0, text_plainW, 0, &mime, 0);
         ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
         ok(!strcmp_wa(mime, "text/plain"), "[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
         CoTaskMemFree(mime);
 
         mime = (LPWSTR)0xf0f0f0f0;
-        hres = pFindMimeFromData(NULL, mime_tests[i].url, NULL, 0, app_octet_streamW, 0, &mime, 0);
+        hres = pFindMimeFromData(NULL, url, NULL, 0, app_octet_streamW, 0, &mime, 0);
         ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
         ok(!strcmp_wa(mime, "application/octet-stream"), "[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
         CoTaskMemFree(mime);
+        heap_free(url);
     }
 
     for(i=0; i < sizeof(mime_tests2)/sizeof(mime_tests2[0]); i++) {