This time with the patch.
Changelog:
- Code cleanup
- Dissable tests after UIActivate failes (fixes tests win 9x)
Index: dlls/mshtml/tests/htmldoc.c
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/tests/htmldoc.c,v
retrieving revision 1.8
diff -u -p -r1.8 htmldoc.c
--- dlls/mshtml/tests/htmldoc.c 15 Aug 2005 09:41:30 -0000 1.8
+++ dlls/mshtml/tests/htmldoc.c 15 Aug 2005 16:48:51 -0000
@@ -43,7 +43,6 @@
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE
-static IUnknown *htmldoc_unk = NULL;
static IOleDocumentView *view = NULL;
static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
@@ -469,7 +468,7 @@ static HRESULT WINAPI DocumentSite_Activ
CHECK_EXPECT(ActivateMe);
ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
- hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleDocument, (void**)&document);
+ hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
ok(hres == S_OK, "could not get IOleDocument: %08lx\n", hres);
if(SUCCEEDED(hres)) {
@@ -513,8 +512,15 @@ static HRESULT WINAPI DocumentSite_Activ
SET_EXPECT(SetActiveObject);
SET_EXPECT(ShowUI);
expect_SetActiveObject_active = TRUE;
+
hres = IOleDocumentView_UIActivate(view, TRUE);
+
+ if(FAILED(hres)) {
+ trace("UIActivate failed: %08lx\n", hres);
+ return hres;
+ }
ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
+
CHECK_CALLED(CanInPlaceActivate);
CHECK_CALLED(GetWindowContext);
CHECK_CALLED(GetWindow);
@@ -796,14 +802,14 @@ static LRESULT WINAPI wnd_proc(HWND hwnd
return DefWindowProc(hwnd, msg, wParam, lParam);
}
-static void test_Persist()
+static void test_Persist(IUnknown *unk)
{
IPersistMoniker *persist_mon;
IPersistFile *persist_file;
GUID guid;
HRESULT hres;
- hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IPersistFile, (void**)&persist_file);
+ hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08lx\n", hres);
if(SUCCEEDED(hres)) {
hres = IPersist_GetClassID(persist_file, NULL);
@@ -816,7 +822,7 @@ static void test_Persist()
IPersist_Release(persist_file);
}
- hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IPersistMoniker, (void**)&persist_mon);
+ hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08lx\n", hres);
if(SUCCEEDED(hres)) {
hres = IPersistMoniker_GetClassID(persist_mon, NULL);
@@ -872,12 +878,18 @@ static const OLECMDF expect_cmds[OLECMDI
OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
};
-static void test_OleCommandTarget(IOleCommandTarget *cmdtrg)
+static void test_OleCommandTarget(IUnknown *unk)
{
+ IOleCommandTarget *cmdtrg;
OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
int i;
HRESULT hres;
+ hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
+ ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08lx\n", hres);
+ if(FAILED(hres))
+ return;
+
for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
cmds[i].cmdID = i+1;
cmds[i].cmdf = 0xf0f0;
@@ -891,20 +903,63 @@ static void test_OleCommandTarget(IOleCo
ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%lx, expected %x\n",
i+1, cmds[i].cmdf, expect_cmds[i+1]);
}
+
+ IOleCommandTarget_Release(cmdtrg);
}
-static void test_HTMLDocument(void)
+static void test_OleCommandTarget_fail(IUnknown *unk)
{
- IOleObject *oleobj = NULL;
- IOleClientSite *clientsite = (LPVOID)0xdeadbeef;
- IOleInPlaceObjectWindowless *windowlessobj = NULL;
- IOleInPlaceActiveObject *activeobject = NULL;
- IOleCommandTarget *cmdtrg = NULL;
- GUID guid;
- RECT rect = {0,0,500,500};
+ IOleCommandTarget *cmdtrg;
+ int i;
HRESULT hres;
- ULONG ref;
+ OLECMD cmd[2] = {
+ {OLECMDID_OPEN, 0xf0f0},
+ {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
+ };
+
+ hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
+ ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08lx\n", hres);
+ if(FAILED(hres))
+ return;
+
+
+
+ hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
+ ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
+
+ hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
+ ok(hres == OLECMDERR_E_NOTSUPPORTED,
+ "QueryStatus failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
+ ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
+ "cmd[0].cmdID=%ld, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
+ ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%lx, expected 0\n", cmd[0].cmdf);
+ ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
+ "cmd[1].cmdf=%lx, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
+
+ hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
+ ok(hres == OLECMDERR_E_UNKNOWNGROUP,
+ "QueryStatus failed: %08lx, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
+
+ for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
+ if(!expect_cmds[i]) {
+ hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
+ OLECMDEXECOPT_DODEFAULT, NULL, NULL);
+ ok(hres == OLECMDERR_E_NOTSUPPORTED,
+ "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
+ }
+ }
+
+ hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
+ OLECMDEXECOPT_DODEFAULT, NULL, NULL);
+ ok(hres == OLECMDERR_E_NOTSUPPORTED,
+ "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
+
+ IOleCommandTarget_Release(cmdtrg);
+}
+
+static HWND create_container_window(void)
+{
static const WCHAR wszHTMLDocumentTest[] =
{'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
static WNDCLASSEXW wndclass = {
@@ -916,402 +971,307 @@ static void test_HTMLDocument(void)
NULL
};
- hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
- &IID_IUnknown, (void**)&htmldoc_unk);
- ok(hres == S_OK, "CoCreateInstance failed: %08lx\n", hres);
- if(FAILED(hres))
- return;
-
RegisterClassExW(&wndclass);
- container_hwnd = CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
+ return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, NULL, NULL, NULL, NULL);
+}
- test_Persist();
+static HRESULT test_DoVerb(IOleObject *oleobj)
+{
+ RECT rect = {0,0,500,500};
+ HRESULT hres;
- hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleInPlaceObjectWindowless,
- (void**)&windowlessobj);
- ok(hres == S_OK, "Could not get IOleInPlaceObjectWindowless interface: %08lx\n", hres);
+ SET_EXPECT(GetContainer);
+ SET_EXPECT(LockContainer);
+ SET_EXPECT(ActivateMe);
+ expect_LockContainer_fLock = TRUE;
+ hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
- hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
- ok(hres == S_OK, "could not get IOleCommandTarget: %08lx\n", hres);
+ if(FAILED(hres))
+ return hres;
- hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleObject, (void**)&oleobj);
- ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
- if(oleobj) {
- hres = IOleObject_GetUserClassID(oleobj, NULL);
- ok(hres == E_INVALIDARG, "GetUserClassID returned: %08lx, expected E_INVALIDARG\n", hres);
-
- hres = IOleObject_GetUserClassID(oleobj, &guid);
- ok(hres == S_OK, "GetUserClassID failed: %08lx\n", hres);
- ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
+ ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
+ CHECK_CALLED(GetContainer);
+ CHECK_CALLED(LockContainer);
+ CHECK_CALLED(ActivateMe);
- hres = IOleObject_GetClientSite(oleobj, &clientsite);
- ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
- ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
+ return hres;
+}
- SET_EXPECT(GetHostInfo);
- SET_EXPECT(GetOptionKeyPath);
- SET_EXPECT(GetOverrideKeyPath);
- SET_EXPECT(GetWindow);
- hres = IOleObject_SetClientSite(oleobj, &ClientSite);
- ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
- CHECK_CALLED(GetHostInfo);
- CHECK_CALLED(GetOptionKeyPath);
- CHECK_CALLED(GetOverrideKeyPath);
- CHECK_CALLED(GetWindow);
+#define CLIENTSITE_EXPECTPATH 0x00000001
+#define CLIENTSITE_SETNULL 0x00000002
+#define CLIENTSITE_DONTSET 0x00000004
- hres = IOleObject_GetClientSite(oleobj, &clientsite);
- ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
- ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
+static void test_ClientSite(IOleObject *oleobj, DWORD flags)
+{
+ IOleClientSite *clientsite;
+ HRESULT hres;
- if(windowlessobj) {
- hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
- ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
- }
+ if(flags & CLIENTSITE_SETNULL) {
+ hres = IOleObject_GetClientSite(oleobj, &clientsite);
+ ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
- SET_EXPECT(GetContainer);
- SET_EXPECT(LockContainer);
- SET_EXPECT(ActivateMe);
- expect_LockContainer_fLock = TRUE;
- hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
- ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
- CHECK_CALLED(GetContainer);
- CHECK_CALLED(LockContainer);
- CHECK_CALLED(ActivateMe);
+ hres = IOleObject_SetClientSite(oleobj, NULL);
+ ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
}
- if(cmdtrg) {
- int i;
-
- OLECMD cmd[2] = {
- {OLECMDID_OPEN, 0xf0f0},
- {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
- };
-
- hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
- ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
-
- hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
- ok(hres == OLECMDERR_E_NOTSUPPORTED,
- "QueryStatus failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
- ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
- "cmd[0].cmdID=%ld, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
- ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%lx, expected 0\n", cmd[0].cmdf);
- ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
- "cmd[1].cmdf=%lx, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
-
- hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
- ok(hres == OLECMDERR_E_UNKNOWNGROUP,
- "QueryStatus failed: %08lx, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
-
- for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
- if(!expect_cmds[i]) {
- hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
- OLECMDEXECOPT_DODEFAULT, NULL, NULL);
- ok(hres == OLECMDERR_E_NOTSUPPORTED,
- "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
- }
- }
+ if(flags & CLIENTSITE_DONTSET)
+ return;
- hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
- OLECMDEXECOPT_DODEFAULT, NULL, NULL);
- ok(hres == OLECMDERR_E_NOTSUPPORTED,
- "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
+ hres = IOleObject_GetClientSite(oleobj, &clientsite);
+ ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
+ ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
- test_OleCommandTarget(cmdtrg);
+ SET_EXPECT(GetHostInfo);
+ if(flags & CLIENTSITE_EXPECTPATH) {
+ SET_EXPECT(GetOptionKeyPath);
+ SET_EXPECT(GetOverrideKeyPath);
}
+ SET_EXPECT(GetWindow);
+ hres = IOleObject_SetClientSite(oleobj, &ClientSite);
+ ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
+ CHECK_CALLED(GetHostInfo);
+ if(flags & CLIENTSITE_EXPECTPATH) {
+ CHECK_CALLED(GetOptionKeyPath);
+ CHECK_CALLED(GetOverrideKeyPath);
+ }
+ CHECK_CALLED(GetWindow);
- hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
- ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres);
+ hres = IOleObject_GetClientSite(oleobj, &clientsite);
+ ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
+ ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
+}
- if(activeobject) {
- HWND tmp_hwnd;
- hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
- ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
- ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
- }
+static void test_Close(IUnknown *unk, BOOL set_client)
+{
+ IOleObject *oleobj = NULL;
+ HRESULT hres;
- if(view) {
- SET_EXPECT(SetActiveObject);
- SET_EXPECT(HideUI);
- SET_EXPECT(OnUIDeactivate);
- expect_SetActiveObject_active = FALSE;
- hres = IOleDocumentView_UIActivate(view, FALSE);
- ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
- CHECK_CALLED(SetActiveObject);
- CHECK_CALLED(HideUI);
- CHECK_CALLED(OnUIDeactivate);
- }
+ hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
+ ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
+ if(FAILED(hres))
+ return;
- if(cmdtrg)
- test_OleCommandTarget(cmdtrg);
+ SET_EXPECT(GetContainer);
+ SET_EXPECT(LockContainer);
+ expect_LockContainer_fLock = FALSE;
+ hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
+ ok(hres == S_OK, "Close failed: %08lx\n", hres);
+ CHECK_CALLED(GetContainer);
+ CHECK_CALLED(LockContainer);
- if(activeobject) {
- HWND tmp_hwnd;
- hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
- ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
- ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
- }
-
- if(windowlessobj) {
- SET_EXPECT(OnInPlaceDeactivate);
- hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
- ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
- CHECK_CALLED(OnInPlaceDeactivate);
- }
+ if(set_client)
+ test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
- /* Calling test_OleCommandTarget here couses Segmentation Fault with native
- * MSHTML. It doesn't with Wine. */
+ IOleObject_Release(oleobj);
+}
- if(activeobject) {
- HWND tmp_hwnd;
- hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
- ok(hres == E_FAIL, "GetWindow returned %08lx, expected E_FAIL\n", hres);
- ok(IsWindow(hwnd), "hwnd is destroyed\n");
- }
+static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
+{
+ IOleInPlaceObjectWindowless *windowlessobj = NULL;
+ HRESULT hres;
- if(view) {
- hres = IOleDocumentView_Show(view, FALSE);
- ok(hres == S_OK, "Show failed: %08lx\n", hres);
- }
- if(windowlessobj) {
- hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
- ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
- }
+ hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
+ (void**)&windowlessobj);
+ ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08lx\n", hres);
+ if(FAILED(hres))
+ return;
- if(view) {
- IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
+ if(expect_call) SET_EXPECT(OnInPlaceDeactivate);
+ hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
+ ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
+ if(expect_call) CHECK_CALLED(OnInPlaceDeactivate);
- hres = IOleDocumentView_Show(view, FALSE);
- ok(hres == S_OK, "Show failed: %08lx\n", hres);
+ IOleInPlaceObjectWindowless_Release(windowlessobj);
+}
- hres = IOleDocumentView_CloseView(view, 0);
- ok(hres == S_OK, "CloseVire failed: %08lx\n", hres);
+static HRESULT test_Activate(IUnknown *unk, DWORD flags)
+{
+ IOleObject *oleobj = NULL;
+ GUID guid;
+ HRESULT hres;
- hres = IOleDocumentView_SetInPlaceSite(view, NULL);
- ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
+ last_hwnd = hwnd;
- hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
- ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
- ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
- }
+ if(view)
+ IOleDocumentView_Release(view);
+ view = NULL;
- if(oleobj) {
- SET_EXPECT(GetContainer);
- SET_EXPECT(LockContainer);
- expect_LockContainer_fLock = FALSE;
- hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
- ok(hres == S_OK, "Close failed: %08lx\n", hres);
- CHECK_CALLED(GetContainer);
- CHECK_CALLED(LockContainer);
+ hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
+ ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
+ if(FAILED(hres))
+ return hres;
- if(view)
- IOleDocumentView_Release(view);
+ hres = IOleObject_GetUserClassID(oleobj, NULL);
+ ok(hres == E_INVALIDARG, "GetUserClassID returned: %08lx, expected E_INVALIDARG\n", hres);
- /* Activate HTMLDocument again */
- last_hwnd = hwnd;
+ hres = IOleObject_GetUserClassID(oleobj, &guid);
+ ok(hres == S_OK, "GetUserClassID failed: %08lx\n", hres);
+ ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
- hres = IOleObject_GetClientSite(oleobj, &clientsite);
- ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
+ test_ClientSite(oleobj, flags);
+ test_InPlaceDeactivate(unk, FALSE);
- hres = IOleObject_SetClientSite(oleobj, NULL);
- ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
+ hres = test_DoVerb(oleobj);
- hres = IOleObject_GetClientSite(oleobj, &clientsite);
- ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
- ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
+ IOleObject_Release(oleobj);
+ return hres;
+}
- SET_EXPECT(GetHostInfo);
- SET_EXPECT(GetWindow);
- hres = IOleObject_SetClientSite(oleobj, &ClientSite);
- ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
- CHECK_CALLED(GetHostInfo);
- CHECK_CALLED(GetWindow);
+static void test_Window(IUnknown *unk, BOOL expect_success)
+{
+ IOleInPlaceActiveObject *activeobject = NULL;
+ HWND tmp_hwnd;
+ HRESULT hres;
- if(windowlessobj) {
- hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
- ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
- }
+ hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
+ ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres);
+ if(FAILED(hres))
+ return;
- SET_EXPECT(GetContainer);
- SET_EXPECT(LockContainer);
- SET_EXPECT(ActivateMe);
- expect_LockContainer_fLock = TRUE;
- hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
- ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
- CHECK_CALLED(GetContainer);
- CHECK_CALLED(LockContainer);
- CHECK_CALLED(ActivateMe);
- }
+ hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
- if(activeobject) {
- HWND tmp_hwnd;
- hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
+ if(expect_success) {
ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
+ }else {
+ ok(hres == E_FAIL, "GetWindow returned %08lx, expected E_FAIL\n", hres);
+ ok(IsWindow(hwnd), "hwnd is destroyed\n");
}
- if(cmdtrg)
- test_OleCommandTarget(cmdtrg);
-
- if(view) {
- SET_EXPECT(SetActiveObject);
- SET_EXPECT(HideUI);
- SET_EXPECT(OnUIDeactivate);
- expect_SetActiveObject_active = FALSE;
- hres = IOleDocumentView_UIActivate(view, FALSE);
- ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
- CHECK_CALLED(SetActiveObject);
- CHECK_CALLED(HideUI);
- CHECK_CALLED(OnUIDeactivate);
- }
-
- if(windowlessobj) {
- SET_EXPECT(OnInPlaceDeactivate);
- hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
- ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
- CHECK_CALLED(OnInPlaceDeactivate);
- }
+ IOleInPlaceActiveObject_Release(activeobject);
+}
- if(oleobj) {
- SET_EXPECT(GetContainer);
- SET_EXPECT(LockContainer);
- expect_LockContainer_fLock = FALSE;
- hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
- ok(hres == S_OK, "Close failed: %08lx\n", hres);
- CHECK_CALLED(GetContainer);
- CHECK_CALLED(LockContainer);
+static void test_CloseView(void)
+{
+ IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
+ HRESULT hres;
- if(view)
- IOleDocumentView_Release(view);
+ if(!view)
+ return;
- hres = IOleObject_GetClientSite(oleobj, &clientsite);
- ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
+ hres = IOleDocumentView_Show(view, FALSE);
+ ok(hres == S_OK, "Show failed: %08lx\n", hres);
- hres = IOleObject_SetClientSite(oleobj, NULL);
- ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
+ hres = IOleDocumentView_CloseView(view, 0);
+ ok(hres == S_OK, "CloseView failed: %08lx\n", hres);
- hres = IOleObject_GetClientSite(oleobj, &clientsite);
- ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
- ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
+ hres = IOleDocumentView_SetInPlaceSite(view, NULL);
+ ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
- SET_EXPECT(GetHostInfo);
- SET_EXPECT(GetWindow);
- hres = IOleObject_SetClientSite(oleobj, &ClientSite);
- ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
- CHECK_CALLED(GetHostInfo);
- CHECK_CALLED(GetWindow);
+ hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
+ ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
+ ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
+}
- /* Activate HTMLDocument again, this time without UIActivate */
- last_hwnd = hwnd;
- call_UIActivate = FALSE;
-
- SET_EXPECT(GetContainer);
- SET_EXPECT(LockContainer);
- SET_EXPECT(ActivateMe);
- expect_LockContainer_fLock = TRUE;
- hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
- ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
- CHECK_CALLED(GetContainer);
- CHECK_CALLED(LockContainer);
- CHECK_CALLED(ActivateMe);
- }
+static void test_UIDeactivate(void)
+{
+ HRESULT hres;
- if(activeobject) {
- HWND tmp_hwnd;
- hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
- ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
- ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
+ if(call_UIActivate) {
+ SET_EXPECT(SetActiveObject);
+ SET_EXPECT(HideUI);
+ SET_EXPECT(OnUIDeactivate);
}
- if(view) {
- expect_SetActiveObject_active = FALSE;
- hres = IOleDocumentView_UIActivate(view, FALSE);
- ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
- }
+ expect_SetActiveObject_active = FALSE;
+ hres = IOleDocumentView_UIActivate(view, FALSE);
+ ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
- if(windowlessobj) {
- SET_EXPECT(OnInPlaceDeactivate);
- hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
- ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
- CHECK_CALLED(OnInPlaceDeactivate);
+ if(call_UIActivate) {
+ CHECK_CALLED(SetActiveObject);
+ CHECK_CALLED(HideUI);
+ CHECK_CALLED(OnUIDeactivate);
}
+}
- if(view) {
- IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
-
- hres = IOleDocumentView_Show(view, FALSE);
- ok(hres == S_OK, "Show failed: %08lx\n", hres);
+static void test_Hide(void)
+{
+ HRESULT hres;
- hres = IOleDocumentView_CloseView(view, 0);
- ok(hres == S_OK, "CloseView failed: %08lx\n", hres);
+ if(!view)
+ return;
- hres = IOleDocumentView_SetInPlaceSite(view, NULL);
- ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
+ hres = IOleDocumentView_Show(view, FALSE);
+ ok(hres == S_OK, "Show failed: %08lx\n", hres);
+}
- hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
- ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
- ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
- }
+static void test_HTMLDocument(void)
+{
+ IUnknown *unk;
+ HRESULT hres;
+ ULONG ref;
- if(view) {
- IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
+ hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
+ &IID_IUnknown, (void**)&unk);
+ ok(hres == S_OK, "CoCreateInstance failed: %08lx\n", hres);
+ if(FAILED(hres))
+ return;
- hres = IOleDocumentView_Show(view, FALSE);
- ok(hres == S_OK, "Show failed: %08lx\n", hres);
+ test_Persist(unk);
- hres = IOleDocumentView_CloseView(view, 0);
- ok(hres == S_OK, "CloseVire failed: %08lx\n", hres);
+ hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
+ if(FAILED(hres)) {
+ IUnknown_Release(unk);
+ return;
+ }
- hres = IOleDocumentView_SetInPlaceSite(view, NULL);
- ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
-
- hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
- ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
- ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
-
- SET_EXPECT(GetContainer);
- SET_EXPECT(LockContainer);
- expect_LockContainer_fLock = FALSE;
- hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
- ok(hres == S_OK, "Close failed: %08lx\n", hres);
- CHECK_CALLED(GetContainer);
- CHECK_CALLED(LockContainer);
+ test_OleCommandTarget_fail(unk);
+ test_OleCommandTarget(unk);
+ test_Window(unk, TRUE);
+ test_UIDeactivate();
+ test_OleCommandTarget(unk);
+ test_Window(unk, TRUE);
+ test_InPlaceDeactivate(unk, TRUE);
- hres = IOleObject_GetClientSite(oleobj, &clientsite);
- ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
+ /* Calling test_OleCommandTarget here couses Segmentation Fault with native
+ * MSHTML. It doesn't with Wine. */
- hres = IOleObject_SetClientSite(oleobj, NULL);
- ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
- }
+ test_Window(unk, FALSE);
+ test_Hide();
+ test_InPlaceDeactivate(unk, FALSE);
+ test_CloseView();
+ test_Close(unk, FALSE);
+
+ /* Activate HTMLDocument again */
+ test_Activate(unk, CLIENTSITE_SETNULL);
+ test_Window(unk, TRUE);
+ test_OleCommandTarget(unk);
+ test_UIDeactivate();
+ test_InPlaceDeactivate(unk, TRUE);
+ test_Close(unk, FALSE);
+
+ /* Activate HTMLDocument again, this time without UIActivate */
+ call_UIActivate = FALSE;
+ test_Activate(unk, CLIENTSITE_SETNULL);
+ test_Window(unk, TRUE);
+ test_UIDeactivate();
+ test_InPlaceDeactivate(unk, TRUE);
+ test_CloseView();
+ test_CloseView();
+ test_Close(unk, TRUE);
- if(cmdtrg)
- IOleCommandTarget_Release(cmdtrg);
- if(windowlessobj)
- IOleInPlaceObjectWindowless_Release(windowlessobj);
- if(oleobj)
- IOleObject_Release(oleobj);
if(view)
IOleDocumentView_Release(view);
- if(activeobject)
- IOleInPlaceActiveObject_Release(activeobject);
+ view = NULL;
ok(IsWindow(hwnd), "hwnd is destroyed\n");
- ref = IUnknown_Release(htmldoc_unk);
+ ref = IUnknown_Release(unk);
ok(ref == 0, "ref=%ld, expected 0\n", ref);
ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
- DestroyWindow(container_hwnd);
}
START_TEST(htmldoc)
{
CoInitialize(NULL);
+ container_hwnd = create_container_window();
test_HTMLDocument();
+ DestroyWindow(container_hwnd);
CoUninitialize();
}