urlmon/tests: Make array-based MIME tests more generic.
This commit is contained in:
parent
6b73e8fb9f
commit
e7ca2655e8
|
@ -87,6 +87,26 @@ static int strcmp_wa(const WCHAR *strw, const char *stra)
|
||||||
return lstrcmpW(strw, buf);
|
return lstrcmpW(strw, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void heap_free(void *mem)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static WCHAR *a2w(const char *str)
|
||||||
|
{
|
||||||
|
WCHAR *ret;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if(!str)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
||||||
|
ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void test_CreateFormatEnum(void)
|
static void test_CreateFormatEnum(void)
|
||||||
{
|
{
|
||||||
IEnumFORMATETC *fenum = NULL, *fenum2 = NULL;
|
IEnumFORMATETC *fenum = NULL, *fenum2 = NULL;
|
||||||
|
@ -561,6 +581,8 @@ static const struct {
|
||||||
const char *mime;
|
const char *mime;
|
||||||
const char *mime_pjpeg;
|
const char *mime_pjpeg;
|
||||||
const char *broken_mime;
|
const char *broken_mime;
|
||||||
|
const char *url;
|
||||||
|
const char *proposed_mime;
|
||||||
} mime_tests2[] = {
|
} mime_tests2[] = {
|
||||||
{data1, sizeof(data1), "text/plain"},
|
{data1, sizeof(data1), "text/plain"},
|
||||||
{data2, sizeof(data2), "application/octet-stream", "image/pjpeg"},
|
{data2, sizeof(data2), "application/octet-stream", "image/pjpeg"},
|
||||||
|
@ -657,13 +679,18 @@ static const struct {
|
||||||
{data93, sizeof(data93), "text/xml", "text/plain"},
|
{data93, sizeof(data93), "text/xml", "text/plain"},
|
||||||
{data94, sizeof(data94), "text/html", "text/plain"},
|
{data94, sizeof(data94), "text/html", "text/plain"},
|
||||||
{data95, sizeof(data95), "text/xml", "text/richtext"},
|
{data95, sizeof(data95), "text/xml", "text/richtext"},
|
||||||
{data96, sizeof(data96), "text/plain"}
|
{data96, sizeof(data96), "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"},
|
||||||
|
{data1, sizeof(data1), "text/plain", NULL, NULL, "file:some%20file%2ejpg", "application/octet-stream"},
|
||||||
|
{NULL, sizeof(data1), "text/html", NULL, NULL, "res://mshtml.dll/blank.htm"},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void test_FindMimeFromData(void)
|
static void test_FindMimeFromData(void)
|
||||||
{
|
{
|
||||||
|
WCHAR *mime, *proposed_mime, *url;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
LPWSTR mime;
|
|
||||||
BYTE b;
|
BYTE b;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -701,14 +728,18 @@ static void test_FindMimeFromData(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i < sizeof(mime_tests2)/sizeof(mime_tests2[0]); i++) {
|
for(i=0; i < sizeof(mime_tests2)/sizeof(mime_tests2[0]); i++) {
|
||||||
hres = pFindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
|
url = a2w(mime_tests2[i].url);
|
||||||
NULL, 0, &mime, 0);
|
proposed_mime = a2w(mime_tests2[i].proposed_mime);
|
||||||
|
hres = pFindMimeFromData(NULL, url, mime_tests2[i].data, mime_tests2[i].size,
|
||||||
|
proposed_mime, 0, &mime, 0);
|
||||||
ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
|
ok(hres == S_OK, "[%d] FindMimeFromData failed: %08x\n", i, hres);
|
||||||
b = !strcmp_wa(mime, mime_tests2[i].mime);
|
b = !strcmp_wa(mime, mime_tests2[i].mime);
|
||||||
ok(b || broken(mime_tests2[i].broken_mime && !strcmp_wa(mime, mime_tests2[i].broken_mime)),
|
ok(b || broken(mime_tests2[i].broken_mime && !strcmp_wa(mime, mime_tests2[i].broken_mime)),
|
||||||
"[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
|
"[%d] wrong mime: %s\n", i, wine_dbgstr_w(mime));
|
||||||
|
heap_free(proposed_mime);
|
||||||
|
heap_free(url);
|
||||||
CoTaskMemFree(mime);
|
CoTaskMemFree(mime);
|
||||||
if(!b)
|
if(!b || url || proposed_mime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
|
hres = pFindMimeFromData(NULL, NULL, mime_tests2[i].data, mime_tests2[i].size,
|
||||||
|
@ -746,46 +777,6 @@ static void test_FindMimeFromData(void)
|
||||||
CoTaskMemFree(mime);
|
CoTaskMemFree(mime);
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, url1, data1, sizeof(data1), NULL, 0, &mime, 0);
|
|
||||||
ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
|
|
||||||
ok(!strcmp_wa(mime, "text/plain"), "wrong mime: %s\n", wine_dbgstr_w(mime));
|
|
||||||
CoTaskMemFree(mime);
|
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, url1, data1, sizeof(data1), app_octet_streamW, 0, &mime, 0);
|
|
||||||
ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
|
|
||||||
ok(!strcmp_wa(mime, "text/plain"), "wrong mime: %s\n", wine_dbgstr_w(mime));
|
|
||||||
CoTaskMemFree(mime);
|
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, url4, data1, sizeof(data1), app_octet_streamW, 0, &mime, 0);
|
|
||||||
ok(hres == S_OK, "FindMimeFromData failed: %08x\n", hres);
|
|
||||||
ok(!strcmp_wa(mime, "text/plain"), "wrong mime: %s\n", wine_dbgstr_w(mime));
|
|
||||||
CoTaskMemFree(mime);
|
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, url1, NULL, 0, NULL, 0, &mime, 0);
|
|
||||||
ok(hres == S_OK, "FindMimeFromData failed: %08x, expected S_OK\n", hres);
|
|
||||||
ok(!strcmp_wa(mime, "text/html"), "wrong mime: %s\n", wine_dbgstr_w(mime));
|
|
||||||
CoTaskMemFree(mime);
|
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, url1, NULL, sizeof(data1), NULL, 0, &mime, 0);
|
|
||||||
ok(hres == S_OK, "FindMimeFromData failed: %08x, expected S_OK\n", hres);
|
|
||||||
ok(!strcmp_wa(mime, "text/html"), "wrong mime: %s\n", wine_dbgstr_w(mime));
|
|
||||||
CoTaskMemFree(mime);
|
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, url1, 0, 0, NULL, 0, &mime, 0);
|
|
||||||
ok(hres == S_OK, "FindMimeFromData failed: %08x, expected S_OK\n", hres);
|
|
||||||
ok(!strcmp_wa(mime, "text/html"), "wrong mime: %s\n", wine_dbgstr_w(mime));
|
|
||||||
CoTaskMemFree(mime);
|
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, url1, 0, sizeof(data1), NULL, 0, &mime, 0);
|
|
||||||
ok(hres == S_OK, "FindMimeFromData failed: %08x, expected S_OK\n", hres);
|
|
||||||
ok(!strcmp_wa(mime, "text/html"), "wrong mime: %s\n", wine_dbgstr_w(mime));
|
|
||||||
CoTaskMemFree(mime);
|
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, url1, data1, sizeof(data1), NULL, 0, &mime, 0);
|
|
||||||
ok(hres == S_OK, "FindMimeFromData failed: %08x, expected S_OK\n", hres);
|
|
||||||
ok(!strcmp_wa(mime, "text/plain"), "wrong mime: %s\n", wine_dbgstr_w(mime));
|
|
||||||
CoTaskMemFree(mime);
|
|
||||||
|
|
||||||
hres = pFindMimeFromData(NULL, NULL, NULL, 0, NULL, 0, &mime, 0);
|
hres = pFindMimeFromData(NULL, NULL, NULL, 0, NULL, 0, &mime, 0);
|
||||||
ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres);
|
ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue