Commit 84370303 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added more loading tests.

parent 5d9e6455
......@@ -71,6 +71,7 @@ static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
DEFINE_EXPECT(LockContainer);
DEFINE_EXPECT(SetActiveObject);
DEFINE_EXPECT(SetActiveObject_null);
DEFINE_EXPECT(GetWindow);
DEFINE_EXPECT(CanInPlaceActivate);
DEFINE_EXPECT(OnInPlaceActivate);
......@@ -118,6 +119,7 @@ DEFINE_EXPECT(GetDisplayName);
DEFINE_EXPECT(BindToStorage);
DEFINE_EXPECT(IsSystemMoniker);
DEFINE_EXPECT(GetBindResult);
DEFINE_EXPECT(GetClassID);
DEFINE_EXPECT(Abort);
DEFINE_EXPECT(Read);
DEFINE_EXPECT(CreateInstance);
......@@ -135,7 +137,7 @@ DEFINE_EXPECT(GetExternal);
static IUnknown *doc_unk;
static BOOL expect_LockContainer_fLock;
static BOOL expect_SetActiveObject_active, expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
static BOOL ipsex;
static BOOL set_clientsite = FALSE, container_locked = FALSE;
static BOOL readystate_set_loading = FALSE, load_from_stream;
......@@ -163,10 +165,12 @@ static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',
static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
static HRESULT QueryInterface(REFIID riid, void **ppv);
static void test_readyState(IUnknown*);
static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
static BOOL nogecko = FALSE;
#define test_readyState(u) _test_readyState(__LINE__,u)
static void _test_readyState(unsigned,IUnknown*);
static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR);
static const WCHAR wszTimesNewRoman[] =
......@@ -186,6 +190,17 @@ static const char *debugstr_guid(REFIID riid)
return buf;
}
static const char *debugstr_w(LPCWSTR str)
{
static char buf[1024];
if(!str)
return "(null)";
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
return buf;
}
#define EXPECT_UPDATEUI 1
#define EXPECT_SETTITLE 2
......@@ -850,6 +865,7 @@ static const IBindingVtbl BindingVtbl = {
static IBinding Binding = { &BindingVtbl };
DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
{
......@@ -857,6 +873,8 @@ static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void
if(IsEqualGUID(&IID_IMoniker_unk, riid))
return E_NOINTERFACE; /* TODO */
if(IsEqualGUID(&IID_IMoniker_unk2, riid))
return E_NOINTERFACE; /* TODO */
ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
......@@ -874,8 +892,9 @@ static ULONG WINAPI Moniker_Release(IMoniker *iface)
static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
CHECK_EXPECT(GetClassID);
ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
return E_FAIL;
}
static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
......@@ -924,6 +943,8 @@ static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMon
CHECK_EXPECT(BindToStorage);
load_state = LD_LOADING;
ok(pbc != NULL, "pbc == NULL\n");
ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
......@@ -1233,13 +1254,14 @@ static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
static const WCHAR wszHTML_Document[] =
{'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
if(pActiveObject) {
CHECK_EXPECT2(SetActiveObject);
if(expect_SetActiveObject_active) {
ok(pActiveObject != NULL, "pActiveObject = NULL\n");
if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
}else {
CHECK_EXPECT(SetActiveObject_null);
ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
}
......@@ -1634,13 +1656,12 @@ static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocum
SET_EXPECT(OnUIActivate);
SET_EXPECT(SetActiveObject);
SET_EXPECT(ShowUI);
expect_SetActiveObject_active = TRUE;
expect_status_text = NULL;
hres = IOleDocumentView_UIActivate(view, TRUE);
if(FAILED(hres)) {
trace("UIActivate failed: %08x\n", hres);
skip("UIActivate failed: %08x\n", hres);
return hres;
}
ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
......@@ -2368,7 +2389,7 @@ static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
return DefWindowProc(hwnd, msg, wParam, lParam);
}
static void test_readyState(IUnknown *unk)
static void _test_readyState(unsigned line, IUnknown *unk)
{
IHTMLDocument2 *htmldoc;
BSTR state;
......@@ -2400,7 +2421,9 @@ static void test_readyState(IUnknown *unk)
hres = IHTMLDocument2_get_readyState(htmldoc, &state);
ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
ok(!lstrcmpW(state, expected_state[load_state]), "unexpected state, expected %d\n", load_state);
ok_(__FILE__, line)
(!lstrcmpW(state, expected_state[load_state]), "unexpected state \"%s\", expected %d\n",
debugstr_w(state), load_state);
IHTMLDocument_Release(htmldoc);
}
......@@ -2562,11 +2585,13 @@ static void test_Load(IPersistMoniker *persist)
SET_EXPECT(OnChanged_READYSTATE);
SET_EXPECT(Exec_ShellDocView_84);
SET_EXPECT(BindToStorage);
SET_EXPECT(SetActiveObject);
if(set_clientsite) {
SET_EXPECT(Invoke_AMBIENT_SILENT);
SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
SET_EXPECT(Exec_ShellDocView_37);
}
load_state = LD_DOLOAD;
expect_LockContainer_fLock = TRUE;
readystate_set_loading = TRUE;
......@@ -2598,6 +2623,7 @@ static void test_Load(IPersistMoniker *persist)
CHECK_CALLED(OnChanged_READYSTATE);
SET_CALLED(Exec_ShellDocView_84);
CHECK_CALLED(BindToStorage);
SET_CALLED(SetActiveObject); /* FIXME */
if(set_clientsite) {
CHECK_CALLED(Invoke_AMBIENT_SILENT);
CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
......@@ -2779,14 +2805,15 @@ static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
};
static void test_QueryStatus(IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
#define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
{
IOleCommandTarget *cmdtrg;
OLECMD olecmd = {cmdid, 0};
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
if(FAILED(hres))
return;
......@@ -2795,8 +2822,8 @@ static void test_QueryStatus(IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf
IOleCommandTarget_Release(cmdtrg);
ok(olecmd.cmdID == cmdid, "cmdID changed\n");
ok(olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
}
static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
......@@ -2937,7 +2964,7 @@ static void test_exec_onunload(IUnknown *unk)
IOleCommandTarget_Release(cmdtrg);
}
static void test_exec_editmode(IUnknown *unk)
static void test_exec_editmode(IUnknown *unk, BOOL loaded)
{
IOleCommandTarget *cmdtrg;
HRESULT hres;
......@@ -2949,13 +2976,22 @@ static void test_exec_editmode(IUnknown *unk)
editmode = TRUE;
if(loaded)
load_state = LD_DOLOAD;
if(loaded)
SET_EXPECT(GetClassID);
SET_EXPECT(SetStatusText);
SET_EXPECT(Exec_ShellDocView_37);
SET_EXPECT(GetHostInfo);
if(loaded)
SET_EXPECT(GetDisplayName);
SET_EXPECT(Invoke_AMBIENT_SILENT);
SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
SET_EXPECT(OnChanged_READYSTATE);
SET_EXPECT(Exec_ShellDocView_84);
if(loaded)
SET_EXPECT(BindToStorage);
SET_EXPECT(InPlaceUIWindow_SetActiveObject);
SET_EXPECT(HideUI);
SET_EXPECT(ShowUI);
......@@ -2968,13 +3004,19 @@ static void test_exec_editmode(IUnknown *unk)
OLECMDEXECOPT_DODEFAULT, NULL, NULL);
ok(hres == S_OK, "Exec failed: %08x\n", hres);
if(loaded)
CHECK_CALLED(GetClassID);
CHECK_CALLED(SetStatusText);
CHECK_CALLED(Exec_ShellDocView_37);
CHECK_CALLED(GetHostInfo);
if(loaded)
CHECK_CALLED(GetDisplayName);
CHECK_CALLED(Invoke_AMBIENT_SILENT);
CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
CHECK_CALLED(OnChanged_READYSTATE);
SET_CALLED(Exec_ShellDocView_84);
if(loaded)
CHECK_CALLED(BindToStorage);
CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
CHECK_CALLED(HideUI);
CHECK_CALLED(ShowUI);
......@@ -3021,8 +3063,13 @@ static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
if(out && !nogecko) {
ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
if(V_VT(out) == VT_BSTR)
ok(!lstrcmpW(V_BSTR(out), name ? name : exname), "unexpected fontname\n");
if(V_VT(out) == VT_BSTR) {
if(exname)
ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
"unexpected fontname \"%s\"\n", debugstr_w(name));
else
ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
}
VariantClear(out);
}
......@@ -3404,7 +3451,6 @@ static HRESULT test_Activate(IUnknown *unk, DWORD flags)
SET_EXPECT(ShowUI);
SET_EXPECT(InPlaceUIWindow_SetActiveObject);
SET_EXPECT(InPlaceFrame_SetBorderSpace);
expect_SetActiveObject_active = TRUE;
expect_status_text = NULL;
hres = IOleDocumentView_UIActivate(docview, TRUE);
......@@ -3480,17 +3526,16 @@ static void test_UIDeactivate(void)
SET_EXPECT(InPlaceUIWindow_SetActiveObject);
}
if(call_UIActivate != CallUIActivate_None) {
SET_EXPECT(SetActiveObject);
SET_EXPECT(SetActiveObject_null);
SET_EXPECT(HideUI);
SET_EXPECT(OnUIDeactivate);
}
expect_SetActiveObject_active = FALSE;
hres = IOleDocumentView_UIActivate(view, FALSE);
ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
if(call_UIActivate != CallUIActivate_None) {
CHECK_CALLED(SetActiveObject);
CHECK_CALLED(SetActiveObject_null);
CHECK_CALLED(HideUI);
CHECK_CALLED(OnUIDeactivate);
}
......@@ -3630,15 +3675,15 @@ static void init_test(enum load_state_t ls) {
ipsex = FALSE;
}
static void test_HTMLDocument(enum load_state_t ls)
static void test_HTMLDocument(BOOL do_load)
{
IUnknown *unk;
HRESULT hres;
ULONG ref;
trace("Testing HTMLDocument (%s)...\n", (ls == LD_DOLOAD ? " load" : "no load"));
trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
init_test(ls);
init_test(do_load ? LD_DOLOAD : LD_NO);
hres = create_document(&unk);
if(FAILED(hres))
......@@ -3652,7 +3697,7 @@ static void test_HTMLDocument(enum load_state_t ls)
test_ConnectionPointContainer(unk);
test_GetCurMoniker(unk, NULL, NULL);
test_Persist(unk);
if(load_state == LD_NO)
if(!do_load)
test_OnAmbientPropertyChange2(unk);
hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
......@@ -3661,7 +3706,7 @@ static void test_HTMLDocument(enum load_state_t ls)
return;
}
if(load_state == LD_LOADING) {
if(do_load) {
test_download(FALSE, TRUE, TRUE);
test_GetCurMoniker(unk, &Moniker, NULL);
}
......@@ -3706,9 +3751,9 @@ static void test_HTMLDocument(enum load_state_t ls)
test_CloseView();
test_Close(unk, TRUE);
test_OnAmbientPropertyChange2(unk);
test_GetCurMoniker(unk, load_state == LD_NO ? NULL : &Moniker, NULL);
test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL);
if(ls != LD_DOLOAD) {
if(!do_load) {
/* Activate HTMLDocument again, calling UIActivate after showing the window */
call_UIActivate = CallUIActivate_AfterShow;
test_Activate(unk, 0);
......@@ -3835,7 +3880,6 @@ static void test_edit_uiactivate(IOleObject *oleobj)
SET_EXPECT(ShowUI);
SET_EXPECT(InPlaceUIWindow_SetActiveObject);
SET_EXPECT(InPlaceFrame_SetBorderSpace);
expect_SetActiveObject_active = TRUE;
expect_status_text = NULL;
hres = IOleDocumentView_UIActivate(docview, TRUE);
......@@ -3850,16 +3894,16 @@ static void test_edit_uiactivate(IOleObject *oleobj)
IOleDocumentView_Release(docview);
}
static void test_editing_mode(void)
static void test_editing_mode(BOOL do_load)
{
IUnknown *unk;
IOleObject *oleobj;
HRESULT hres;
ULONG ref;
trace("Testing HTMLDocument (edit)...\n");
trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
init_test(LD_DOLOAD);
init_test(do_load ? LD_DOLOAD : LD_NO);
call_UIActivate = CallUIActivate_AfterShow;
hres = create_document(&unk);
......@@ -3877,17 +3921,20 @@ static void test_editing_mode(void)
test_edit_uiactivate(oleobj);
test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
test_exec_editmode(unk);
if(do_load)
test_Persist(unk);
stream_read = protocol_read = 0;
test_exec_editmode(unk, do_load);
test_UIDeactivate();
call_UIActivate = CallUIActivate_None;
IOleObject_Release(oleobj);
test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
test_download(TRUE, FALSE, FALSE);
test_download(TRUE, do_load, do_load);
test_timer(EXPECT_UPDATEUI);
test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
if(!do_load) {
test_exec_fontname(unk, NULL, wszTimesNewRoman);
test_exec_fontname(unk, wszArial, wszTimesNewRoman);
test_timer(EXPECT_UPDATEUI);
......@@ -3911,6 +3958,7 @@ static void test_editing_mode(void)
test_timer(EXPECT_UPDATEUI);
test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
OLECMDF_SUPPORTED|OLECMDF_ENABLED);
}
test_UIDeactivate();
test_InPlaceDeactivate(unk, TRUE);
......@@ -3980,11 +4028,12 @@ START_TEST(htmldoc)
container_hwnd = create_container_window();
register_protocol();
test_HTMLDocument(LD_NO);
test_HTMLDocument(LD_DOLOAD);
test_HTMLDocument(FALSE);
test_HTMLDocument(TRUE);
test_HTMLDocument_hlink();
test_HTMLDocument_StreamLoad();
test_editing_mode();
test_editing_mode(FALSE);
test_editing_mode(TRUE);
DestroyWindow(container_hwnd);
CoUninitialize();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment