From: Zhenbo Li Subject: [3/3] mshtml/tests: Add tests for modifying IHTMLTable. Message-Id: <53D76493.70406@gmail.com> Date: Tue, 29 Jul 2014 17:08:35 +0800 To avoid affecting other tests, I squashed the tests for insertRow / deleteRow. --- dlls/mshtml/tests/dom.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 33645c8..52293e3 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -5797,6 +5797,35 @@ static void _test_tr_possess(unsigned line, IHTMLElement *elem, IHTMLElementCollection_Release(col); } +#define test_table_possess(e,r,l,i) _test_table_possess(__LINE__,e,r,l,i) +static void _test_table_possess(unsigned line, IHTMLElement *elem, + IHTMLTable *table, LONG len, const char *id) +{ + IHTMLElementCollection *rows; + IDispatch *disp; + HRESULT hres; + LONG lval; + VARIANT var; + + hres = IHTMLTable_get_rows(table, &rows); + ok_(__FILE__, line)(hres == S_OK, "get_rows failed: %08x\n", hres); + ok_(__FILE__, line)(rows != NULL, "get_rows returned NULL\n"); + + hres = IHTMLElementCollection_get_length(rows, &lval); + ok_(__FILE__, line)(hres == S_OK, "get length failed: %08x\n", hres); + ok_(__FILE__, line)(lval == len, "expected len = %d, got %d\n", len, lval); + + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = a2bstr(id); + hres = IHTMLElementCollection_tags(rows, var, &disp); + ok_(__FILE__, line)(hres == S_OK, "search by tags(%s) failed: %08x\n", id, hres); + ok_(__FILE__, line)(disp != NULL, "disp == NULL\n"); + + VariantClear(&var); + IDispatch_Release(disp); + IHTMLElementCollection_Release(rows); +} + static void test_tr_modify(IHTMLElement *elem, IHTMLTableRow *row) { HRESULT hres; @@ -5818,6 +5847,28 @@ static void test_tr_modify(IHTMLElement *elem, IHTMLTableRow *row) IDispatch_Release(disp); } +static void test_table_modify(IHTMLElement *elem, IHTMLTable *table) +{ + HRESULT hres; + IDispatch *disp; + IUnknown *unk; + + hres = IHTMLTable_insertRow(table, 0, &disp); + ok(hres == S_OK, "insertRow failed: %08x\n", hres); + ok(disp != NULL, "disp == NULL\n"); + hres = IDispatch_QueryInterface(disp, &IID_IHTMLTableRow, (void **)&unk); + ok(hres == S_OK, "Could not get IID_IHTMLTableCell interface: %08x\n", hres); + if (SUCCEEDED(hres)) + IUnknown_Release(unk); + test_table_possess(elem, table, 3, "tr1"); + + hres = IHTMLTable_deleteRow(table, 0); + ok(hres == S_OK, "deleteRow failed: %08x\n", hres); + test_table_possess(elem, table, 2, "tr1"); + + IDispatch_Release(disp); +} + static void test_tr_elem(IHTMLElement *elem) { IHTMLElementCollection *col; @@ -6161,6 +6212,9 @@ static void test_table_elem(IHTMLElement *elem) ok(!strcmp_wa(bstr, "summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); + test_table_possess(elem, table, 2, "tr1"); + test_table_modify(elem, table); + IHTMLTable3_Release(table3); IHTMLTable_Release(table); }