Module: wine Branch: master Commit: c2759cb80d8fc046a9b11d9a4b458758b06db73e URL: http://source.winehq.org/git/wine.git/?a=commit;h=c2759cb80d8fc046a9b11d9a4b...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Jun 24 15:22:54 2008 -0500
mshtml: Added IHTMLSelectElement::put_value implementation.
---
dlls/mshtml/htmlselect.c | 14 ++++++++++++-- dlls/mshtml/tests/dom.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index 1783bab..433945d 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -228,8 +228,18 @@ static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v) { HTMLSelectElement *This = HTMLSELECT_THIS(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + nsAString value_str; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + nsAString_Init(&value_str, v); + nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str); + nsAString_Finish(&value_str); + if(NS_FAILED(nsres)) + ERR("SetValue failed: %08x\n", nsres); + + return S_OK; }
static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 9ee1f07..f909c4f 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -43,7 +43,7 @@ static const char elem_test_str[] = "<body>text test<!-- a comment -->" "<a href="http://test%5C" name="x">link</a>" "<input id="in" class="testclass" tabIndex="2" />" - "<select id="s"><option id="x">opt1</option><option id="y">opt2</option></select>" + "<select id="s"><option id="x" value="val1">opt1</option><option id="y">opt2</option></select>" "<textarea id="X">text text</textarea>" "<table><tbody></tbody></table>" "<script id="sc" type="text/javascript"></script>" @@ -630,6 +630,32 @@ static void _test_select_put_selidx(unsigned line, IHTMLSelectElement *select, l _test_select_selidx(line, select, index); }
+#define test_select_value(s,v) _test_select_value(__LINE__,s,v) +static void _test_select_value(unsigned line, IHTMLSelectElement *select, const char *exval) +{ + BSTR val; + HRESULT hres; + + hres = IHTMLSelectElement_get_value(select, &val); + ok_(__FILE__,line) (hres == S_OK, "get_value failed: %08x\n", hres); + if(exval) + ok_(__FILE__,line) (!strcmp_wa(val, exval), "unexpected value %s\n", dbgstr_w(val)); + else + ok_(__FILE__,line) (val == NULL, "val=%s, expected NULL\n", dbgstr_w(val)); +} + +#define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v) +static void _test_select_set_value(unsigned line, IHTMLSelectElement *select, const char *val) +{ + BSTR bstr; + HRESULT hres; + + bstr = a2bstr(val); + hres = IHTMLSelectElement_put_value(select, bstr); + SysFreeString(bstr); + ok_(__FILE__,line) (hres == S_OK, "put_value failed: %08x\n", hres); +} + #define test_range_text(r,t) _test_range_text(__LINE__,r,t) static void _test_range_text(unsigned line, IHTMLTxtRange *range, const char *extext) { @@ -1301,6 +1327,9 @@ static void test_select_elem(IHTMLSelectElement *select) test_select_length(select, 2); test_select_selidx(select, 0); test_select_put_selidx(select, 1); + + test_select_set_value(select, "val1"); + test_select_value(select, "val1"); }
static void test_create_option_elem(IHTMLDocument2 *doc)