Commit 38933b1a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IViewObject::SetSink tests.

parent a8474118
...@@ -152,6 +152,7 @@ DEFINE_EXPECT(Frame_EnableModeless_FALSE); ...@@ -152,6 +152,7 @@ DEFINE_EXPECT(Frame_EnableModeless_FALSE);
DEFINE_EXPECT(Frame_GetWindow); DEFINE_EXPECT(Frame_GetWindow);
DEFINE_EXPECT(TranslateUrl); DEFINE_EXPECT(TranslateUrl);
DEFINE_EXPECT(Advise_Close); DEFINE_EXPECT(Advise_Close);
DEFINE_EXPECT(OnViewChange);
static IUnknown *doc_unk; static IUnknown *doc_unk;
static IMoniker *doc_mon; static IMoniker *doc_mon;
...@@ -2678,50 +2679,60 @@ static const IServiceProviderVtbl ServiceProviderVtbl = { ...@@ -2678,50 +2679,60 @@ static const IServiceProviderVtbl ServiceProviderVtbl = {
static IServiceProvider ServiceProvider = { &ServiceProviderVtbl }; static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSink *iface, static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSinkEx *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
return QueryInterface(riid, ppv); return QueryInterface(riid, ppv);
} }
static ULONG WINAPI AdviseSink_AddRef(IAdviseSink *iface) static ULONG WINAPI AdviseSink_AddRef(IAdviseSinkEx *iface)
{ {
return 2; return 2;
} }
static ULONG WINAPI AdviseSink_Release(IAdviseSink *iface) static ULONG WINAPI AdviseSink_Release(IAdviseSinkEx *iface)
{ {
return 1; return 1;
} }
static void WINAPI AdviseSink_OnDataChange(IAdviseSink *iface, static void WINAPI AdviseSink_OnDataChange(IAdviseSinkEx *iface,
FORMATETC *pFormatetc, STGMEDIUM *pStgmed) FORMATETC *pFormatetc, STGMEDIUM *pStgmed)
{ {
ok(0, "unexpected call\n"); ok(0, "unexpected call\n");
} }
static void WINAPI AdviseSink_OnViewChange(IAdviseSink *iface, static void WINAPI AdviseSink_OnViewChange(IAdviseSinkEx *iface,
DWORD dwAspect, LONG lindex) DWORD dwAspect, LONG lindex)
{ {
ok(0, "unexpected call\n"); ok(0, "unexpected call\n");
} }
static void WINAPI AdviseSink_OnRename(IAdviseSink *iface, IMoniker *pmk) static void WINAPI AdviseSink_OnRename(IAdviseSinkEx *iface, IMoniker *pmk)
{ {
ok(0, "unexpected call\n"); ok(0, "unexpected call\n");
} }
static void WINAPI AdviseSink_OnSave(IAdviseSink *iface) static void WINAPI AdviseSink_OnSave(IAdviseSinkEx *iface)
{ {
ok(0, "unexpected call\n"); ok(0, "unexpected call\n");
} }
static void WINAPI AdviseSink_OnClose(IAdviseSink *iface) static void WINAPI AdviseSink_OnClose(IAdviseSinkEx *iface)
{
ok(0, "unexpected call\n");
}
static void WINAPI AdviseSinkEx_OnViewStatusChange(IAdviseSinkEx *iface, DWORD dwViewStatus)
{
ok(0, "unexpected call\n");
}
static void WINAPI ObjectAdviseSink_OnClose(IAdviseSinkEx *iface)
{ {
CHECK_EXPECT(Advise_Close); CHECK_EXPECT(Advise_Close);
} }
static const IAdviseSinkVtbl AdviseSinkVtbl = { static const IAdviseSinkExVtbl AdviseSinkVtbl = {
AdviseSink_QueryInterface, AdviseSink_QueryInterface,
AdviseSink_AddRef, AdviseSink_AddRef,
AdviseSink_Release, AdviseSink_Release,
...@@ -2729,10 +2740,47 @@ static const IAdviseSinkVtbl AdviseSinkVtbl = { ...@@ -2729,10 +2740,47 @@ static const IAdviseSinkVtbl AdviseSinkVtbl = {
AdviseSink_OnViewChange, AdviseSink_OnViewChange,
AdviseSink_OnRename, AdviseSink_OnRename,
AdviseSink_OnSave, AdviseSink_OnSave,
AdviseSink_OnClose ObjectAdviseSink_OnClose,
AdviseSinkEx_OnViewStatusChange
};
static IAdviseSinkEx AdviseSink = { &AdviseSinkVtbl };
static HRESULT WINAPI ViewAdviseSink_QueryInterface(IAdviseSinkEx *iface,
REFIID riid, void **ppv)
{
if(IsEqualGUID(&IID_IAdviseSinkEx, riid)) {
*ppv = iface;
return S_OK;
}
ok(0, "unexpected riid %s\n", debugstr_guid(riid));
*ppv = NULL;
return E_NOINTERFACE;
}
static void WINAPI ViewAdviseSink_OnViewChange(IAdviseSinkEx *iface,
DWORD dwAspect, LONG lindex)
{
CHECK_EXPECT2(OnViewChange);
ok(dwAspect == DVASPECT_CONTENT, "dwAspect = %d\n", dwAspect);
ok(lindex == -1, "lindex = %d\n", lindex);
}
static const IAdviseSinkExVtbl ViewAdviseSinkVtbl = {
ViewAdviseSink_QueryInterface,
AdviseSink_AddRef,
AdviseSink_Release,
AdviseSink_OnDataChange,
ViewAdviseSink_OnViewChange,
AdviseSink_OnRename,
AdviseSink_OnSave,
AdviseSink_OnClose,
AdviseSinkEx_OnViewStatusChange
}; };
static IAdviseSink AdviseSink = { &AdviseSinkVtbl }; static IAdviseSinkEx ViewAdviseSink = { &ViewAdviseSinkVtbl };
DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */ DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
DEFINE_GUID(IID_IThumbnailView, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD); DEFINE_GUID(IID_IThumbnailView, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
...@@ -2919,6 +2967,20 @@ static void _test_readyState(unsigned line, IUnknown *unk) ...@@ -2919,6 +2967,20 @@ static void _test_readyState(unsigned line, IUnknown *unk)
IHTMLDocument2_Release(htmldoc); IHTMLDocument2_Release(htmldoc);
} }
static void test_ViewAdviseSink(IHTMLDocument2 *doc)
{
IViewObject *view;
HRESULT hres;
hres = IHTMLDocument2_QueryInterface(doc, &IID_IViewObject, (void**)&view);
ok(hres == S_OK, "QueryInterface(IID_IViewObject) failed: %08x\n", hres);
hres = IViewObject_SetAdvise(view, DVASPECT_CONTENT, ADVF_PRIMEFIRST, (IAdviseSink*)&ViewAdviseSink);
ok(hres == S_OK, "SetAdvise failed: %08x\n", hres);
IViewObject_Release(view);
}
static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid) static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
{ {
IConnectionPointContainer *tmp_container = NULL; IConnectionPointContainer *tmp_container = NULL;
...@@ -3100,6 +3162,7 @@ static void test_download(DWORD flags) ...@@ -3100,6 +3162,7 @@ static void test_download(DWORD flags)
SET_EXPECT(SetStatusText); SET_EXPECT(SetStatusText);
if(!(flags & DWL_EMPTY)) if(!(flags & DWL_EMPTY))
SET_EXPECT(Exec_SETDOWNLOADSTATE_1); SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
SET_EXPECT(OnViewChange);
SET_EXPECT(GetDropTarget); SET_EXPECT(GetDropTarget);
if(flags & DWL_TRYCSS) if(flags & DWL_TRYCSS)
SET_EXPECT(Exec_ShellDocView_84); SET_EXPECT(Exec_ShellDocView_84);
...@@ -3148,6 +3211,7 @@ static void test_download(DWORD flags) ...@@ -3148,6 +3211,7 @@ static void test_download(DWORD flags)
CHECK_CALLED(SetStatusText); CHECK_CALLED(SetStatusText);
if(!(flags & DWL_EMPTY)) if(!(flags & DWL_EMPTY))
CHECK_CALLED(Exec_SETDOWNLOADSTATE_1); CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
CHECK_CALLED(OnViewChange);
CHECK_CALLED(GetDropTarget); CHECK_CALLED(GetDropTarget);
if(flags & DWL_TRYCSS) if(flags & DWL_TRYCSS)
SET_CALLED(Exec_ShellDocView_84); SET_CALLED(Exec_ShellDocView_84);
...@@ -3845,14 +3909,14 @@ static void test_Advise(IHTMLDocument2 *doc) ...@@ -3845,14 +3909,14 @@ static void test_Advise(IHTMLDocument2 *doc)
ok(hres == E_INVALIDARG || hres == S_OK, "Advise returned: %08x\n", hres); ok(hres == E_INVALIDARG || hres == S_OK, "Advise returned: %08x\n", hres);
ok(conn == 0 || conn == 1, "conn = %d\n", conn); ok(conn == 0 || conn == 1, "conn = %d\n", conn);
hres = IOleObject_Advise(oleobj, &AdviseSink, NULL); hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, NULL);
ok(hres == E_INVALIDARG, "Advise returned: %08x\n", hres); ok(hres == E_INVALIDARG, "Advise returned: %08x\n", hres);
hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
ok(hres == S_OK, "Advise returned: %08x\n", hres); ok(hres == S_OK, "Advise returned: %08x\n", hres);
ok(conn == 1, "conn = %d\n", conn); ok(conn == 1, "conn = %d\n", conn);
hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
ok(hres == S_OK, "Advise returned: %08x\n", hres); ok(hres == S_OK, "Advise returned: %08x\n", hres);
ok(conn == 2, "conn = %d\n", conn); ok(conn == 2, "conn = %d\n", conn);
...@@ -4281,6 +4345,7 @@ static void test_HTMLDocument(BOOL do_load) ...@@ -4281,6 +4345,7 @@ static void test_HTMLDocument(BOOL do_load)
test_IsDirty(doc, S_FALSE); test_IsDirty(doc, S_FALSE);
test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED); test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
test_external(doc, FALSE); test_external(doc, FALSE);
test_ViewAdviseSink(doc);
test_ConnectionPointContainer(doc); test_ConnectionPointContainer(doc);
test_GetCurMoniker((IUnknown*)doc, NULL, NULL); test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
test_Persist(doc, &Moniker); test_Persist(doc, &Moniker);
...@@ -4376,6 +4441,7 @@ static void test_HTMLDocument_hlink(void) ...@@ -4376,6 +4441,7 @@ static void test_HTMLDocument_hlink(void)
return; return;
doc_unk = (IUnknown*)doc; doc_unk = (IUnknown*)doc;
test_ViewAdviseSink(doc);
test_ConnectionPointContainer(doc); test_ConnectionPointContainer(doc);
test_GetCurMoniker((IUnknown*)doc, NULL, NULL); test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
test_Persist(doc, &Moniker); test_Persist(doc, &Moniker);
...@@ -4476,6 +4542,7 @@ static void test_HTMLDocument_http(void) ...@@ -4476,6 +4542,7 @@ static void test_HTMLDocument_http(void)
hres = CreateURLMoniker(NULL, http_urlW, &http_mon); hres = CreateURLMoniker(NULL, http_urlW, &http_mon);
ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres); ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
test_ViewAdviseSink(doc);
test_ConnectionPointContainer(doc); test_ConnectionPointContainer(doc);
test_GetCurMoniker((IUnknown*)doc, NULL, NULL); test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
test_Persist(doc, http_mon); test_Persist(doc, http_mon);
...@@ -4551,11 +4618,12 @@ static void test_HTMLDocument_StreamLoad(void) ...@@ -4551,11 +4618,12 @@ static void test_HTMLDocument_StreamLoad(void)
hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres); ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
ok(hres == S_OK, "Advise failed: %08x\n", hres); ok(hres == S_OK, "Advise failed: %08x\n", hres);
test_readyState((IUnknown*)doc); test_readyState((IUnknown*)doc);
test_IsDirty(doc, S_FALSE); test_IsDirty(doc, S_FALSE);
test_ViewAdviseSink(doc);
test_ConnectionPointContainer(doc); test_ConnectionPointContainer(doc);
test_QueryService(doc, FALSE); test_QueryService(doc, FALSE);
test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH); test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
...@@ -4608,11 +4676,12 @@ static void test_HTMLDocument_StreamInitNew(void) ...@@ -4608,11 +4676,12 @@ static void test_HTMLDocument_StreamInitNew(void)
hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres); ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
ok(hres == S_OK, "Advise failed: %08x\n", hres); ok(hres == S_OK, "Advise failed: %08x\n", hres);
test_readyState((IUnknown*)doc); test_readyState((IUnknown*)doc);
test_IsDirty(doc, S_FALSE); test_IsDirty(doc, S_FALSE);
test_ViewAdviseSink(doc);
test_ConnectionPointContainer(doc); test_ConnectionPointContainer(doc);
test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH); test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
test_DoVerb(oleobj); test_DoVerb(oleobj);
...@@ -4691,10 +4760,11 @@ static void test_editing_mode(BOOL do_load) ...@@ -4691,10 +4760,11 @@ static void test_editing_mode(BOOL do_load)
hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres); ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
hres = IOleObject_Advise(oleobj, &AdviseSink, &conn); hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
ok(hres == S_OK, "Advise failed: %08x\n", hres); ok(hres == S_OK, "Advise failed: %08x\n", hres);
test_readyState((IUnknown*)doc); test_readyState((IUnknown*)doc);
test_ViewAdviseSink(doc);
test_ConnectionPointContainer(doc); test_ConnectionPointContainer(doc);
test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH); test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
test_DoVerb(oleobj); test_DoVerb(oleobj);
......
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