Skip to content

Commit

Permalink
fix #638 testcase for radiobutton issue in IE7
Browse files Browse the repository at this point in the history
radio button needs a name to get selected by a click. As there is no need for a name in this widget,
the workaround is to call the onbind method on every radio button bound to the model.
  • Loading branch information
MatthieuDadou authored and Fabio Crisci committed Jul 26, 2013
1 parent cd6a255 commit 06baf62
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/aria/jsunit/helpers/OutObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Aria.classDefinition({

/**
* Write something in the store. This implements the TemplateCtxt interface
* @param {String} str Markup
* @param {String} str Markup
*/
write : function (str) {
this.store += str;
Expand All @@ -87,7 +87,8 @@ Aria.classDefinition({
* Put the stored markup in the test area
*/
putInDOM : function () {
this.testArea.innerHTML = this.store;
aria.utils.Dom.insertAdjacentHTML(this.testArea, "beforeEnd", this.store);
this.store = "";
},

/**
Expand Down
1 change: 1 addition & 0 deletions test/aria/html/HTMLTestSuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ Aria.classDefinition({
this.addTests("test.aria.html.select.SelectTest");
this.addTests("test.aria.html.select.bodycontent.BodyContentTestCase");
this.addTests("test.aria.html.DisabledTraitTest");
this.addTests("test.aria.html.radioButton.IEbug.RadioButtonTestCase");
}
});
64 changes: 64 additions & 0 deletions test/aria/html/radioButton/IEbug/RadioButtonTestCase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

Aria.classDefinition({
$classpath : "test.aria.html.radioButton.IEbug.RadioButtonTestCase",
$extends : "aria.jsunit.RobotTestCase",
$dependencies : ["aria.utils.Dom", "aria.html.RadioButton"],
$constructor : function () {
this.$TemplateTestCase.constructor.call(this);
this.setTestEnv({
data : {
selectedValue : ""
}
});
},
$prototype : {
runTemplateTest : function () {

var document = Aria.$window.document;
var selectWidgets = this.testDiv.getElementsByTagName("input");

var widget1 = selectWidgets[0];
var widget2 = selectWidgets[1];
var widget3 = selectWidgets[2];

this.assertEquals(widget1.checked, false, "Check before click on widget 1: " + widget1.checked);
this.assertEquals(widget2.checked, false, "Check before click on widget 2: " + widget2.checked);
this.assertEquals(widget3.checked, false, "Check before click on widget 3: " + widget3.checked);

this.widget1 = widget1;
this.widget2 = widget2;
this.widget3 = widget3;

this.synEvent.click(widget1, {
fn : this.afterFirstClick,
scope : this
});
},

afterFirstClick : function () {

this.assertEquals(this.widget1.checked, true, "Check after click on widget 1: " + this.widget1.checked);
this.assertEquals(this.widget2.checked, false, "Check after click on widget 2: " + this.widget2.checked);
this.assertEquals(this.widget3.checked, false, "Check after click on widget 3: " + this.widget3.checked);

this.assertEquals(this.templateCtxt.data.selectedValue, "a", "Check click on data: expected value was %2 but got %1.");

this.end();
}

}
});
60 changes: 60 additions & 0 deletions test/aria/html/radioButton/IEbug/RadioButtonTestCaseTpl.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

{Template {
$classpath : "test.aria.html.radioButton.IEbug.RadioButtonTestCaseTpl",
$wlibs : {
html : "aria.html.HtmlLibrary"
}
}}

{macro main()}

{@html:RadioButton {
value : "a",
bind : {
selectedValue : {
inside : data,
to : "selectedValue"
}
}
}/}
label 1 associated to value 'a'<br>

{@html:RadioButton {
value : "b",
bind : {
selectedValue : {
inside : data,
to : "selectedValue"
}
}
}/}
label 2 associated to value 'b'<br>

{@html:RadioButton {
value : "c",
bind : {
selectedValue : {
inside : data,
to : "selectedValue"
}
}
}/}
label 3 associated to value 'c'<br>


{/macro}
{/Template}
29 changes: 22 additions & 7 deletions test/aria/html/radioButton/RadioButtonTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ Aria.classDefinition({
},

testReactOnClick : function () {
var container = {};
var container = {
selectedRadioButton : 'a'
};

var cfg = {
value : "a",
Expand All @@ -148,16 +150,29 @@ Aria.classDefinition({
}
};

var widget = this.createAndInit("aria.html.RadioButton", cfg);
var cfg2 = {
value : "b",
bind : {
selectedValue : {
inside : container,
to : "selectedRadioButton"
}
}
};

this.assertEquals(widget._domElt.checked, false, "Radio button should not have been checked before click");
var widget1 = this.createAndInit("aria.html.RadioButton", cfg);
var widget2 = this.createAndInit("aria.html.RadioButton", cfg2);

aria.utils.FireDomEvent.fireEvent("click", widget._domElt);
this.assertEquals(widget1._domElt.checked, true, "Radio button should not have been checked before click");

this.assertEquals(widget._domElt.checked, true, "Check click on dom: " + widget._domElt.checked);
this.assertEquals(container.selectedRadioButton, "a", "Check click on data: expected value was %2 but got %1.");
aria.utils.FireDomEvent.fireEvent("click", widget2._domElt);
this.assertEquals(widget1._domElt.checked, false, "Check click on widget 1: " + widget1._domElt.checked);
this.assertEquals(widget2._domElt.checked, true, "Check click on widget 2: " + widget2._domElt.checked);

widget.$dispose();
this.assertEquals(container.selectedRadioButton, "b", "Check click on data: expected value was %2 but got %1.");

widget1.$dispose();
widget2.$dispose();
this.outObj.clearAll();
},

Expand Down
5 changes: 3 additions & 2 deletions test/aria/widgets/container/splitter/SplitterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Aria.classDefinition({
dom : this.outObj.testArea.childNodes[0]
};
},


testBaseSplitterHorizontal : function () {
this._orientation = null;
var cfg = {
Expand Down Expand Up @@ -71,7 +73,6 @@ Aria.classDefinition({
_testBaseNormalMarkup : function (cfg) {
var splitter = this._createSplitter(cfg);
this.assertTrue(!!splitter.o);
this.assertNotEquals(this.outObj.store, "");
this.assertNotEquals(this.outObj.testArea.innerHTML, "");

var instance = splitter.o;
Expand Down Expand Up @@ -491,4 +492,4 @@ Aria.classDefinition({

}
}
});
});

0 comments on commit 06baf62

Please sign in to comment.