#include "wine/test.h"
+static HRESULT (WINAPI *pCreateAsyncBindCtxEx)(IBindCtx *, DWORD,
+ IBindStatusCallback *, IEnumFORMATETC *, IBindCtx **, DWORD);
+
+
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
static const CHAR dwl_htmlA[] = "dwl.html";
static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
+static const WCHAR test_txtW[] = {'t','e','s','t','.','t','x','t',0};
static const WCHAR emptyW[] = {0};
static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
static HANDLE complete_event, complete_event2;
static HRESULT binding_hres;
static BOOL have_IHttpNegotiate2, use_bscex;
-static BOOL test_redirect;
+static BOOL test_redirect, use_cache_file, callback_read;
+static WCHAR cache_file_name[MAX_PATH];
static LPCWSTR urls[] = {
WINE_ABOUT_URL,
IMoniker *mon1 = NULL;
IMoniker *mon2 = NULL;
+ hr = CreateURLMoniker(NULL, NULL, NULL);
+ ok(hr == E_INVALIDARG,
+ "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
+
+ mon1 = (IMoniker *)0xdeadbeef;
+ hr = CreateURLMoniker(NULL, NULL, &mon1);
+ ok(hr == E_INVALIDARG,
+ "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
+ ok(mon1 == NULL, "Expected the output pointer to be NULL, got %p\n", mon1);
+
+ hr = CreateURLMoniker(NULL, emptyW, NULL);
+ ok(hr == E_INVALIDARG,
+ "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
+
+ hr = CreateURLMoniker(NULL, emptyW, &mon1);
+ ok(hr == S_OK ||
+ broken(hr == MK_E_SYNTAX), /* IE5/IE5.01/IE6 SP2 */
+ "Expected CreateURLMoniker to return S_OK, got 0x%08x\n", hr);
+ if(mon1) IMoniker_Release(mon1);
+
hr = CreateURLMoniker(NULL, url1, &mon1);
ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
if(SUCCEEDED(hr)) {
DWORD grfPI, HANDLE_PTR dwReserved)
{
BINDINFO bindinfo;
- DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
+ DWORD bind_info, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
HRESULT hres;
static const STGMEDIUM stgmed_zero = {0};
memset(&bindinfo, 0, sizeof(bindinfo));
bindinfo.cbSize = sizeof(bindinfo);
- hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
+ hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo);
ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
- if(filedwl_api) {
- ok(bindf == (BINDF_PULLDATA|BINDF_FROMURLMON|BINDF_NEEDFILE), "bindf=%08x\n", bindf);
- }else if(tymed == TYMED_ISTREAM && is_urlmon_protocol(test_protocol)) {
- ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
- |BINDF_FROMURLMON),
- "bindf=%08x\n", bindf);
- }else {
- ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
- |BINDF_FROMURLMON|BINDF_NEEDFILE),
- "bindf=%08x\n", bindf);
- }
+ ok(bind_info & BINDF_FROMURLMON, "BINDF_FROMURLMON is not set\n");
+
+ if(filedwl_api || !is_urlmon_protocol(test_protocol) || !(bindf&BINDF_ASYNCSTORAGE) || tymed != TYMED_ISTREAM)
+ ok(bind_info & BINDF_NEEDFILE, "BINDF_NEEDFILE is not set\n");
+ else
+ ok(!(bind_info & BINDF_NEEDFILE), "BINDF_NEEDFILE is set\n");
+
+ bind_info &= ~(BINDF_NEEDFILE|BINDF_FROMURLMON);
+ if(filedwl_api)
+ ok(bind_info == BINDF_PULLDATA, "bind_info = %x, expected BINDF_PULLDATA\n", bind_info);
+ else
+ ok(bind_info == (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)), "bind_info = %x, expected %x\n",
+ bind_info, (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)));
ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
ok(hres == S_OK,
"ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
- if(tymed == TYMED_FILE) {
- hres = IInternetProtocolSink_ReportProgress(protocol_sink,
- BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_fileW);
- ok(hres == S_OK,
- "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
- }
+ hres = IInternetProtocolSink_ReportProgress(protocol_sink,
+ BINDSTATUS_CACHEFILENAMEAVAILABLE, use_cache_file ? cache_file_name : cache_fileW);
+ ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
bscf |= BSCF_FIRSTDATANOTIFICATION;
break;
todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
else
CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
- if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
+ if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST))
SetEvent(complete_event);
break;
case BINDSTATUS_CONNECTING:
todo_wine CHECK_EXPECT(OnProgress_CONNECTING);
else
CHECK_EXPECT(OnProgress_CONNECTING);
- if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
+ if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST))
SetEvent(complete_event);
break;
case BINDSTATUS_REDIRECTING:
CHECK_EXPECT(OnProgress_REDIRECTING);
ok(!lstrcmpW(szStatusText, WINE_ABOUT_URL), "unexpected status text %s\n",
wine_dbgstr_w(szStatusText));
- if(!bind_to_object || iface == &objbsc)
+ if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
+ && (!bind_to_object || iface == &objbsc))
SetEvent(complete_event);
break;
case BINDSTATUS_SENDINGREQUEST:
CHECK_EXPECT2(OnProgress_SENDINGREQUEST);
else
CHECK_EXPECT(OnProgress_SENDINGREQUEST);
- if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
+ if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST))
SetEvent(complete_event);
break;
case BINDSTATUS_MIMETYPEAVAILABLE:
}
ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
- do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
- while(hres == S_OK);
- ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
+ if(callback_read) {
+ do {
+ hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
+ if(test_protocol == HTTP_TEST && emulate_protocol && readed)
+ ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
+ }while(hres == S_OK);
+ ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
+ }
break;
case TYMED_FILE:
static WCHAR testW[] = {'t','e','s','t',0};
- hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
+ if (!pCreateAsyncBindCtxEx) {
+ win_skip("CreateAsyncBindCtxEx not present\n");
+ return;
+ }
+
+ hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
- hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
+ hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
if(SUCCEEDED(hres)) {
}
CreateBindCtx(0, &bctx_arg);
- hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
+ hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
if(SUCCEEDED(hres)) {
IBindCtx_Release(bctx_arg);
SET_EXPECT(QueryInterface_IServiceProvider);
- hres = CreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
+ hres = pCreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
CHECK_CALLED(QueryInterface_IServiceProvider);
hres = CreateBindCtx(0, &bctx2);
ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
- hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
+ hres = pCreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
#define BINDTEST_FILEDWLAPI 0x0004
#define BINDTEST_HTTPRESPONSE 0x0008
#define BINDTEST_REDIRECT 0x0010
+#define BINDTEST_USE_CACHE 0x0020
+#define BINDTEST_NO_CALLBACK_READ 0x0040
static void init_bind_test(int protocol, DWORD flags, DWORD t)
{
else
urls[HTTP_TEST] = WINE_ABOUT_URL;
test_redirect = (flags & BINDTEST_REDIRECT) != 0;
+ use_cache_file = (flags & BINDTEST_USE_CACHE) != 0;
+ callback_read = !(flags & BINDTEST_NO_CALLBACK_READ);
}
static void test_BindToStorage(int protocol, DWORD flags, DWORD t)
return;
}
- if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
+ if(!(bindf & BINDF_ASYNCHRONOUS) && tymed == TYMED_FILE) {
+ ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
+ ok(unk == NULL, "unk != NULL\n");
+ }else if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
|| (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
ok(unk == NULL, "istr should be NULL\n");
ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
ok(unk != NULL, "unk == NULL\n");
}
- if(unk)
+ if(unk && callback_read)
IUnknown_Release(unk);
if(FAILED(hres))
if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
http_is_first = FALSE;
+
+ if(!callback_read) {
+ BYTE buf[512];
+ DWORD readed;
+ IStream *stream;
+
+ hres = IUnknown_QueryInterface(unk, &IID_IStream, (void**)&stream);
+ ok(hres == S_OK, "Could not get IStream iface: %08x\n", hres);
+ IUnknown_Release(unk);
+
+ do {
+ readed = 0xdeadbeef;
+ hres = IStream_Read(stream, buf, sizeof(buf), &readed);
+ ok(readed != 0xdeadbeef, "readed = 0xdeadbeef\n");
+ if(emulate_protocol && test_protocol == HTTP_TEST && readed)
+ ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
+ }while(hres == S_OK);
+ ok(hres == S_FALSE, "IStream_Read returned %08x\n", hres);
+ ok(!readed, "readed = %d\n", readed);
+
+ IStream_Release(stream);
+ }
}
static void test_BindToObject(int protocol, DWORD flags)
set_file_url(path);
}
+static void create_cache_file(void)
+{
+ char buf[6500];
+ HANDLE file;
+ DWORD size;
+
+ file = CreateFileW(test_txtW, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
+ if(file == INVALID_HANDLE_VALUE)
+ return;
+
+ memset(buf, 'X', sizeof(buf));
+ WriteFile(file, buf, sizeof(buf), &size, NULL);
+ CloseHandle(file);
+
+ size = GetCurrentDirectoryW(MAX_PATH, cache_file_name);
+ cache_file_name[size] = '\\';
+ memcpy(cache_file_name+size+1, test_txtW, sizeof(test_txtW));
+}
+
static void test_ReportResult(HRESULT exhres)
{
IMoniker *mon = NULL;
if(FAILED(hres))
return;
- hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
+ hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
START_TEST(url)
{
+ HMODULE hurlmon;
+
+ hurlmon = GetModuleHandle("urlmon.dll");
+ pCreateAsyncBindCtxEx = (void*) GetProcAddress(hurlmon, "CreateAsyncBindCtxEx");
+
complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
thread_id = GetCurrentThreadId();
create_file();
+ create_cache_file();
test_create();
trace("synchronous http test...\n");
test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
+ trace("emulated synchronous http test (to file)...\n");
+ test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
+
trace("synchronous http test (to object)...\n");
test_BindToObject(HTTP_TEST, 0);
+ trace("emulated synchronous http test (with cache)...\n");
+ test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
+
+ trace("emulated synchronous http test (with cache, no read)...\n");
+ test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
+
+ trace("synchronous http test (with cache, no read)...\n");
+ test_BindToStorage(HTTP_TEST, BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
+
trace("synchronous file test...\n");
test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
+ trace("emulated synchronous file test (to file)...\n");
+ test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
+
trace("synchronous file test (to object)...\n");
test_BindToObject(FILE_TEST, 0);
trace("emulated http test (redirect)...\n");
test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT, TYMED_ISTREAM);
+ trace("emulated http test (with cache)...\n");
+ test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
+
trace("asynchronous https test...\n");
test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
}
DeleteFileA(wszIndexHtmlA);
+ DeleteFileW(test_txtW);
CloseHandle(complete_event);
CloseHandle(complete_event2);
CoUninitialize();