mshtml: Add IHTMLOptionElement::defaultSelected property implementation.
This commit is contained in:
parent
b471b217b2
commit
85c31979de
|
@ -166,15 +166,53 @@ static HRESULT WINAPI HTMLOptionElement_get_value(IHTMLOptionElement *iface, BST
|
|||
static HRESULT WINAPI HTMLOptionElement_put_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL v)
|
||||
{
|
||||
HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
|
||||
FIXME("(%p)->(%x)\n", This, v);
|
||||
return E_NOTIMPL;
|
||||
cpp_bool val, selected;
|
||||
nsresult nsres;
|
||||
|
||||
TRACE("(%p)->(%x)\n", This, v);
|
||||
|
||||
val = (v == VARIANT_TRUE);
|
||||
|
||||
nsres = nsIDOMHTMLOptionElement_GetSelected(This->nsoption, &selected);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("GetSelected failed: %08x\n", nsres);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
nsres = nsIDOMHTMLOptionElement_SetDefaultSelected(This->nsoption, val);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("SetDefaultSelected failed: %08x\n", nsres);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if(val != selected) {
|
||||
nsres = nsIDOMHTMLOptionElement_SetSelected(This->nsoption, selected); /* WinAPI will reserve selected property */
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("SetSelected failed: %08x\n", nsres);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLOptionElement_get_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL *p)
|
||||
{
|
||||
HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
|
||||
FIXME("(%p)->(%p)\n", This, p);
|
||||
return E_NOTIMPL;
|
||||
cpp_bool val;
|
||||
nsresult nsres;
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, p);
|
||||
if(!p)
|
||||
return E_POINTER;
|
||||
nsres = nsIDOMHTMLOptionElement_GetDefaultSelected(This->nsoption, &val);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("GetDefaultSelected failed: %08x\n", nsres);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
*p = val ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLOptionElement_put_index(IHTMLOptionElement *iface, LONG v)
|
||||
|
|
|
@ -1692,6 +1692,60 @@ static void _test_option_get_index(unsigned line, IHTMLOptionElement *option, LO
|
|||
"value = %d, expected = %d\n", val, exval);
|
||||
}
|
||||
|
||||
#define test_option_put_defaultSelected(o,d) _test_option_put_defaultSelected(__LINE__,o,d)
|
||||
static void _test_option_put_defaultSelected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL b)
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
hres = IHTMLOptionElement_put_defaultSelected(option, b);
|
||||
ok_(__FILE__,line)(hres == S_OK, "put_defaultSelected %08x\n", hres);
|
||||
}
|
||||
|
||||
#define test_option_defaultSelected(o,e) _test_option_defaultSelected(__LINE__,o,e)
|
||||
static void _test_option_defaultSelected(unsigned line, IHTMLOptionElement *option, VARIANT_BOOL ex)
|
||||
{
|
||||
HRESULT hres;
|
||||
VARIANT_BOOL b;
|
||||
|
||||
hres = IHTMLOptionElement_get_defaultSelected(option, NULL);
|
||||
ok_(__FILE__,line)(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres);
|
||||
|
||||
b = 0x100;
|
||||
hres = IHTMLOptionElement_get_defaultSelected(option, &b);
|
||||
ok_(__FILE__,line)(hres == S_OK, "get_defaultSelected failed: %08x\n", hres);
|
||||
ok_(__FILE__,line)(b == ex, "b = %x, expected = %x\n", b, ex);
|
||||
}
|
||||
|
||||
static void test_option_defaultSelected_property(IHTMLOptionElement *option)
|
||||
{
|
||||
test_option_defaultSelected(option, VARIANT_FALSE);
|
||||
test_option_selected(option, VARIANT_FALSE);
|
||||
|
||||
test_option_put_defaultSelected(option, 0x100); /* Invalid value */
|
||||
test_option_defaultSelected(option, VARIANT_FALSE);
|
||||
test_option_selected(option, VARIANT_FALSE);
|
||||
|
||||
test_option_put_defaultSelected(option, VARIANT_TRUE);
|
||||
test_option_defaultSelected(option, VARIANT_TRUE);
|
||||
test_option_selected(option, VARIANT_FALSE);
|
||||
|
||||
test_option_put_defaultSelected(option, 0x100); /* Invalid value */
|
||||
test_option_defaultSelected(option, VARIANT_FALSE);
|
||||
test_option_selected(option, VARIANT_FALSE);
|
||||
|
||||
test_option_put_selected(option, VARIANT_TRUE);
|
||||
test_option_selected(option, VARIANT_TRUE);
|
||||
test_option_defaultSelected(option, VARIANT_FALSE);
|
||||
|
||||
test_option_put_defaultSelected(option, VARIANT_TRUE);
|
||||
test_option_defaultSelected(option, VARIANT_TRUE);
|
||||
test_option_selected(option, VARIANT_TRUE);
|
||||
|
||||
/* Restore defaultSelected */
|
||||
test_option_put_defaultSelected(option, VARIANT_TRUE);
|
||||
test_option_put_selected(option, VARIANT_FALSE);
|
||||
}
|
||||
|
||||
#define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
|
||||
static void _test_textarea_value(unsigned line, IUnknown *unk, const char *exval)
|
||||
{
|
||||
|
@ -5085,6 +5139,7 @@ static void test_create_option_elem(IHTMLDocument2 *doc)
|
|||
test_option_put_text(option, "new text");
|
||||
test_option_put_value(option, "new value");
|
||||
test_option_get_index(option, 0);
|
||||
test_option_defaultSelected_property(option);
|
||||
test_option_put_selected(option, VARIANT_TRUE);
|
||||
test_option_put_selected(option, VARIANT_FALSE);
|
||||
|
||||
|
|
Loading…
Reference in New Issue