Module: wine Branch: master Commit: 529a7ed55fa63b48afb27f7f454696c880a3039b URL: http://source.winehq.org/git/wine.git/?a=commit;h=529a7ed55fa63b48afb27f7f45...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Apr 4 18:02:04 2016 +0200
mshtml: Event tests code clean up.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mshtml/tests/events.c | 51 ++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 31 deletions(-)
diff --git a/dlls/mshtml/tests/events.c b/dlls/mshtml/tests/events.c index c3aa352..ad0547e 100644 --- a/dlls/mshtml/tests/events.c +++ b/dlls/mshtml/tests/events.c @@ -295,6 +295,7 @@ static IHTMLElement *_get_elem_id(unsigned line, IHTMLDocument2 *doc, const char SysFreeString(str); IHTMLDocument3_Release(doc3); ok_(__FILE__,line) (hres == S_OK, "getElementById failed: %08x\n", hres); + ok_(__FILE__,line) (elem != NULL, "elem == NULL\n");
return elem; } @@ -2206,48 +2207,36 @@ static void test_timeout(IHTMLDocument2 *doc) IHTMLWindow3_Release(win3); }
-static IHTMLElement* find_element_by_id(IHTMLDocument2 *doc, const char *id) +static IHTMLWindow2 *get_iframe_window(IHTMLIFrameElement *iframe) { + IHTMLWindow2 *window; + IHTMLFrameBase2 *base; HRESULT hres; - IHTMLDocument3 *doc3; - IHTMLElement *result; - BSTR idW = a2bstr(id);
- hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3); - ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres); + hres = IHTMLIFrameElement_QueryInterface(iframe, &IID_IHTMLFrameBase2, (void**)&base); + ok(hres == S_OK, "QueryInterface(IID_IHTMLFrameBase2) failed: %08x\n", hres);
- hres = IHTMLDocument3_getElementById(doc3, idW, &result); - ok(hres == S_OK, "getElementById failed: %08x\n", hres); - ok(result != NULL, "result == NULL\n"); - SysFreeString(idW); + hres = IHTMLFrameBase2_get_contentWindow(base, &window); + ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres); + ok(window != NULL, "window == NULL\n");
- IHTMLDocument3_Release(doc3); - return result; + if(base) IHTMLFrameBase2_Release(base); + return window; }
-static IHTMLDocument2* get_iframe_doc(IHTMLIFrameElement *iframe) +static IHTMLDocument2 *get_iframe_doc(IHTMLIFrameElement *iframe) { - HRESULT hres; - IHTMLFrameBase2 *base; IHTMLDocument2 *result = NULL; + IHTMLWindow2 *window; + HRESULT hres;
- hres = IHTMLIFrameElement_QueryInterface(iframe, &IID_IHTMLFrameBase2, (void**)&base); - ok(hres == S_OK, "QueryInterface(IID_IHTMLFrameBase2) failed: %08x\n", hres); - if(hres == S_OK) { - IHTMLWindow2 *window; + window = get_iframe_window(iframe);
- hres = IHTMLFrameBase2_get_contentWindow(base, &window); - ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres); - ok(window != NULL, "window == NULL\n"); - if(window) { - hres = IHTMLWindow2_get_document(window, &result); - ok(hres == S_OK, "get_document failed: %08x\n", hres); - ok(result != NULL, "result == NULL\n"); - IHTMLWindow2_Release(window); - } - } - if(base) IHTMLFrameBase2_Release(base); + hres = IHTMLWindow2_get_document(window, &result); + ok(hres == S_OK, "get_document failed: %08x\n", hres); + ok(result != NULL, "result == NULL\n");
+ IHTMLWindow2_Release(window); return result; }
@@ -2263,7 +2252,7 @@ static void test_iframe_connections(IHTMLDocument2 *doc)
trace("iframe tests...\n");
- element = find_element_by_id(doc, "ifr"); + element = get_elem_id(doc, "ifr"); iframe = get_iframe_iface((IUnknown*)element); IHTMLElement_Release(element);