Module: wine Branch: master Commit: 2046d69b4e701bfa16c189452b1b019788272bc6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2046d69b4e701bfa16c189452b...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Jul 19 17:59:40 2013 +0200
mshtml/tests: Added more res protocol tests.
---
dlls/mshtml/tests/protocol.c | 39 ++++++++++++++++++++++++++++++++++++++- dlls/mshtml/tests/rsrc.rc | 8 ++++++++ 2 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/dlls/mshtml/tests/protocol.c b/dlls/mshtml/tests/protocol.c index 7e66347..04c4714 100644 --- a/dlls/mshtml/tests/protocol.c +++ b/dlls/mshtml/tests/protocol.c @@ -27,6 +27,7 @@ #include "ole2.h" #include "urlmon.h" #include "shlwapi.h" +#include "wininet.h"
#include "initguid.h"
@@ -73,6 +74,9 @@ static const WCHAR about_test_url[] = {'a','b','o','u','t',':','t','e','s','t',0 static const WCHAR about_res_url[] = {'r','e','s',':','b','l','a','n','k',0}; static const WCHAR javascript_test_url[] = {'j','a','v','a','s','c','r','i','p','t',':','t','e','s','t','(',')',0};
+static WCHAR res_url_base[INTERNET_MAX_URL_LENGTH] = {'r','e','s',':','/','/'}; +static unsigned res_url_base_len; + static const char *debugstr_guid(REFIID riid) { static char buf[50]; @@ -248,7 +252,7 @@ static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT CHECK_CALLED(ReportResult); }
-static void protocol_start(IInternetProtocol *protocol, LPCWSTR url) +static void protocol_start(IInternetProtocol *protocol, const WCHAR *url) { HRESULT hres;
@@ -268,6 +272,33 @@ static void protocol_start(IInternetProtocol *protocol, LPCWSTR url) CHECK_CALLED(ReportResult); }
+static void test_res_url(const char *url_suffix) +{ + WCHAR url[INTERNET_MAX_URL_LENGTH]; + IInternetProtocol *protocol; + ULONG size, ref; + BYTE buf[100]; + HRESULT hres; + + memcpy(url, res_url_base, res_url_base_len*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, url_suffix, -1, url+res_url_base_len, sizeof(url)-res_url_base_len); + + hres = CoCreateInstance(&CLSID_ResProtocol, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void**)&protocol); + ok(hres == S_OK, "Could not create ResProtocol instance: %08x\n", hres); + + protocol_start(protocol, url); + + hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &size); + ok(hres == S_OK, "Read failed: %08x\n", hres); + + hres = IInternetProtocol_Terminate(protocol, 0); + ok(hres == S_OK, "Terminate failed: %08x\n", hres); + + + ref = IInternetProtocol_Release(protocol); + ok(!ref, "ref=%u\n", ref); +} + static void res_sec_url_cmp(LPCWSTR url, DWORD size, LPCWSTR file) { WCHAR buf[MAX_PATH]; @@ -578,6 +609,10 @@ static void test_res_protocol(void) }
IUnknown_Release(unk); + + test_res_url("/jstest.html"); + test_res_url("/Test/res.html"); + test_res_url("/test/dir/dir2/res.html"); }
static void do_test_about_protocol(IClassFactory *factory, DWORD bf) @@ -908,6 +943,8 @@ static void test_javascript_protocol(void)
START_TEST(protocol) { + res_url_base_len = 6 + GetModuleFileNameW(NULL, res_url_base + 6 /* strlen("res://") */, sizeof(res_url_base)-6); + OleInitialize(NULL);
test_res_protocol(); diff --git a/dlls/mshtml/tests/rsrc.rc b/dlls/mshtml/tests/rsrc.rc index 49aecdf..07d816d 100644 --- a/dlls/mshtml/tests/rsrc.rc +++ b/dlls/mshtml/tests/rsrc.rc @@ -33,3 +33,11 @@ externscr.js HTML "externscr.js"
/* @makedep: test_tlb.tlb */ 1 TYPELIB test_tlb.tlb + +/* For res: protocol test: */ + +/* @makedep: jstest.html */ +res.html test "jstest.html" + +/* @makedep: jstest.html */ +dir/dir2/res.html test "jstest.html"