Jacek Caban : mshtml: Added IHTMLOptionElement:: selected property implementation.
Alexandre Julliard
julliard at winehq.org
Tue May 11 12:09:40 CDT 2010
Module: wine
Branch: master
Commit: 85f079362f9e9712732209c5721a80d0f0e0ecc8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=85f079362f9e9712732209c5721a80d0f0e0ecc8
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue May 11 17:56:29 2010 +0200
mshtml: Added IHTMLOptionElement::selected property implementation.
---
dlls/mshtml/htmloption.c | 28 ++++++++++++++++++++++++----
dlls/mshtml/tests/dom.c | 24 ++++++++++++++++++++++++
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmloption.c b/dlls/mshtml/htmloption.c
index 3e03762..b816634 100644
--- a/dlls/mshtml/htmloption.c
+++ b/dlls/mshtml/htmloption.c
@@ -98,15 +98,35 @@ static HRESULT WINAPI HTMLOptionElement_Invoke(IHTMLOptionElement *iface, DISPID
static HRESULT WINAPI HTMLOptionElement_put_selected(IHTMLOptionElement *iface, VARIANT_BOOL v)
{
HTMLOptionElement *This = HTMLOPTION_THIS(iface);
- FIXME("(%p)->(%x)\n", This, v);
- return E_NOTIMPL;
+ nsresult nsres;
+
+ TRACE("(%p)->(%x)\n", This, v);
+
+ nsres = nsIDOMHTMLOptionElement_SetSelected(This->nsoption, v != VARIANT_FALSE);
+ if(NS_FAILED(nsres)) {
+ ERR("SetSelected failed: %08x\n", nsres);
+ return E_FAIL;
+ }
+
+ return S_OK;
}
static HRESULT WINAPI HTMLOptionElement_get_selected(IHTMLOptionElement *iface, VARIANT_BOOL *p)
{
HTMLOptionElement *This = HTMLOPTION_THIS(iface);
- FIXME("(%p)->(%p)\n", This, p);
- return E_NOTIMPL;
+ PRBool selected;
+ nsresult nsres;
+
+ TRACE("(%p)->(%p)\n", This, p);
+
+ nsres = nsIDOMHTMLOptionElement_GetSelected(This->nsoption, &selected);
+ if(NS_FAILED(nsres)) {
+ ERR("GetSelected failed: %08x\n", nsres);
+ return E_FAIL;
+ }
+
+ *p = selected ? VARIANT_TRUE : VARIANT_FALSE;
+ return S_OK;
}
static HRESULT WINAPI HTMLOptionElement_put_value(IHTMLOptionElement *iface, BSTR v)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 69c87cd..ad5fb26 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -1135,6 +1135,27 @@ static void _test_option_put_value(unsigned line, IHTMLOptionElement *option, co
_test_option_value(line, option, value);
}
+#define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
+static void _test_option_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
+{
+ VARIANT_BOOL b = 0x100;
+ HRESULT hres;
+
+ hres = IHTMLOptionElement_get_selected(option, &b);
+ ok_(__FILE__,line)(hres == S_OK, "get_selected failed: %08x\n", hres);
+ ok_(__FILE__,line)(b == ex, "selected = %x, expected %x\n", b, ex);
+}
+
+#define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
+static void _test_option_put_selected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
+{
+ HRESULT hres;
+
+ hres = IHTMLOptionElement_put_selected(option, b);
+ ok_(__FILE__,line)(hres == S_OK, "put_selected failed: %08x\n", hres);
+ _test_option_selected(line, option, b);
+}
+
#define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
static void _test_comment_text(unsigned line, IUnknown *unk, const char *extext)
{
@@ -1183,6 +1204,7 @@ static IHTMLOptionElement *_create_option_elem(unsigned line, IHTMLDocument2 *do
_test_option_text(line, option, txt);
_test_option_value(line, option, val);
+ _test_option_selected(line, option, VARIANT_FALSE);
return option;
}
@@ -2872,6 +2894,8 @@ static void test_create_option_elem(IHTMLDocument2 *doc)
test_option_put_text(option, "new text");
test_option_put_value(option, "new value");
+ test_option_put_selected(option, VARIANT_TRUE);
+ test_option_put_selected(option, VARIANT_FALSE);
IHTMLOptionElement_Release(option);
}
More information about the wine-cvs
mailing list