Commit 666004cd authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Removed code duplication in frame collection tests.

parent f83762e6
...@@ -5832,27 +5832,12 @@ static void test_frame(IDispatch *disp, const char *exp_id) ...@@ -5832,27 +5832,12 @@ static void test_frame(IDispatch *disp, const char *exp_id)
IHTMLDocument2_Release(top_doc); IHTMLDocument2_Release(top_doc);
} }
static void test_frameset(IHTMLDocument2 *doc) static void test_frames_collection(IHTMLFramesCollection2 *frames, const char *frid)
{ {
IHTMLWindow2 *window;
IHTMLFramesCollection2 *frames;
IHTMLElement *elem;
IHTMLFrameBase *fbase;
LONG length;
VARIANT index_var, result_var; VARIANT index_var, result_var;
BSTR str; LONG length;
HRESULT hres; HRESULT hres;
window = get_doc_window(doc);
/* test using IHTMLFramesCollection object */
hres = IHTMLWindow2_get_frames(window, &frames);
ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
IHTMLWindow2_Release(window);
if(FAILED(hres))
return;
/* test result length */ /* test result length */
hres = IHTMLFramesCollection2_get_length(frames, &length); hres = IHTMLFramesCollection2_get_length(frames, &length);
ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres); ok(hres == S_OK, "IHTMLFramesCollection2_get_length failed: 0x%08x\n", hres);
...@@ -5888,12 +5873,12 @@ static void test_frameset(IHTMLDocument2 *doc) ...@@ -5888,12 +5873,12 @@ static void test_frameset(IHTMLDocument2 *doc)
/* string argument (element id lookup) */ /* string argument (element id lookup) */
V_VT(&index_var) = VT_BSTR; V_VT(&index_var) = VT_BSTR;
V_BSTR(&index_var) = a2bstr("fr1"); V_BSTR(&index_var) = a2bstr(frid);
hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var); hres = IHTMLFramesCollection2_item(frames, &index_var, &result_var);
ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres); ok(hres == S_OK, "IHTMLFramesCollection2_item failed: 0x%08x\n", hres);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var)); ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
test_frame(V_DISPATCH(&result_var), "fr1"); test_frame(V_DISPATCH(&result_var), frid);
} }
VariantClear(&result_var); VariantClear(&result_var);
VariantClear(&index_var); VariantClear(&index_var);
...@@ -5905,63 +5890,31 @@ static void test_frameset(IHTMLDocument2 *doc) ...@@ -5905,63 +5890,31 @@ static void test_frameset(IHTMLDocument2 *doc)
ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have" ok(hres == E_INVALIDARG, "IHTMLFramesCollection2_item should have"
"failed with E_INVALIDARG, instead: 0x%08x\n", hres); "failed with E_INVALIDARG, instead: 0x%08x\n", hres);
VariantClear(&result_var); VariantClear(&result_var);
}
IHTMLFramesCollection2_Release(frames); static void test_frameset(IHTMLDocument2 *doc)
{
/* test using IHTMLWindow2 inheritance */ IHTMLWindow2 *window;
IHTMLFramesCollection2 *frames;
/* test result length */ IHTMLElement *elem;
hres = IHTMLWindow2_get_length(window, &length); IHTMLFrameBase *fbase;
ok(hres == S_OK, "IHTMLWindow2_get_length failed: 0x%08x\n", hres); BSTR str;
ok(length == 3, "IHTMLWindow2_get_length should have been 3, was: %d\n", length); HRESULT hres;
/* test first frame */ window = get_doc_window(doc);
V_VT(&index_var) = VT_I4;
V_I4(&index_var) = 0;
hres = IHTMLWindow2_item(window, &index_var, &result_var);
ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
if(SUCCEEDED(hres)) {
ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
test_frame((IDispatch*)V_DISPATCH(&result_var), "fr1");
}
VariantClear(&result_var);
/* test second frame */ /* test using IHTMLFramesCollection object */
V_I4(&index_var) = 1;
hres = IHTMLWindow2_item(window, &index_var, &result_var);
ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
if(SUCCEEDED(hres)) {
ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
}
VariantClear(&result_var);
/* fail on next frame */ hres = IHTMLWindow2_get_frames(window, &frames);
V_I4(&index_var) = 3; ok(hres == S_OK, "IHTMLWindow2_get_frames failed: 0x%08x\n", hres);
hres = IHTMLWindow2_item(window, &index_var, &result_var); if(FAILED(hres))
ok(hres == DISP_E_MEMBERNOTFOUND, "IHTMLWindow2_item should have" return;
"failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08x\n", hres);
VariantClear(&result_var);
/* string argument (element id lookup) */ test_frames_collection(frames, "fr1");
V_VT(&index_var) = VT_BSTR; IHTMLFramesCollection2_Release(frames);
V_BSTR(&index_var) = a2bstr("fr2");
hres = IHTMLWindow2_item(window, &index_var, &result_var);
ok(hres == S_OK, "IHTMLWindow2_item failed: 0x%08x\n", hres);
if(SUCCEEDED(hres)) {
ok(V_VT(&result_var) == VT_DISPATCH, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var));
test_frame((IDispatch*)V_DISPATCH(&result_var), "fr2");
}
VariantClear(&result_var);
VariantClear(&index_var);
/* invalid argument */ /* test using IHTMLWindow2 inheritance */
V_VT(&index_var) = VT_BOOL; test_frames_collection((IHTMLFramesCollection2*)window, "fr2");
V_BOOL(&index_var) = VARIANT_TRUE;
hres = IHTMLWindow2_item(window, &index_var, &result_var);
ok(hres == E_INVALIDARG, "IHTMLWindow2_item should have"
"failed with E_INVALIDARG, instead: 0x%08x\n", hres);
VariantClear(&result_var);
/* getElementById with node name attributes */ /* getElementById with node name attributes */
elem = get_doc_elem_by_id(doc, "nm1"); elem = get_doc_elem_by_id(doc, "nm1");
...@@ -6018,6 +5971,7 @@ static void test_frameset(IHTMLDocument2 *doc) ...@@ -6018,6 +5971,7 @@ static void test_frameset(IHTMLDocument2 *doc)
IHTMLFrameBase_Release(fbase); IHTMLFrameBase_Release(fbase);
IHTMLElement_Release(elem); IHTMLElement_Release(elem);
IHTMLWindow2_Release(window);
} }
static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc) static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
......
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