You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/07/27 13:56:58 UTC
svn commit: r979655 - in
/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp:
script/test-utils.js tx/in/in.xhtml
Author: lofwyr
Date: Tue Jul 27 11:56:57 2010
New Revision: 979655
URL: http://svn.apache.org/viewvc?rev=979655&view=rev
Log:
test also jQuery addressed objects
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/test-utils.js
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tx/in/in.xhtml
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/test-utils.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/test-utils.js?rev=979655&r1=979654&r2=979655&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/test-utils.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/test-utils.js Tue Jul 27 11:56:57 2010
@@ -19,49 +19,59 @@
* Utilities to make client side tests easier.
*/
-function checkLeft(id, left) {
- var element = document.getElementById(id);
+function checkLeft(element, left) {
var offsetLeft = element.offsetLeft;
- while (element.offsetParent != null) {
- element = element.offsetParent;
- offsetLeft += element.offsetLeft;
+ var parent = element;
+ while (parent.offsetParent != null) {
+ parent = parent.offsetParent;
+ offsetLeft += parent.offsetLeft;
}
if (offsetLeft != left) {
- LOG.error("The element with id=" + id + " has wrong left: expected=" + left + " actual=" + offsetLeft);
+ LOG.error("The element '" + element.tagName + "' with id='" + element.id + "' has wrong left: expected=" + left + " actual=" + offsetLeft);
}
}
-function checkTop(id, top) {
- var element = document.getElementById(id);
+function checkTop(element, top) {
var offsetTop = element.offsetTop;
- while (element.offsetParent != null) {
- element = element.offsetParent;
- offsetTop += element.offsetTop;
+ var parent = element;
+ while (parent.offsetParent != null) {
+ parent = parent.offsetParent;
+ offsetTop += parent.offsetTop;
}
- if (offsetTop != top) {
- LOG.error("The element with id=" + id + " has wrong top: expected=" + top + " actual=" + offsetTop);
+ if (offsetTop != top) {
+ LOG.error("The element '" + element.tagName + "' with id='" + element.id + "' has wrong top: expected=" + top + " actual=" + offsetTop);
}
}
-function checkWidth(id, width) {
- var offsetWidth = document.getElementById(id).offsetWidth;
+function checkWidth(element, width) {
+ var offsetWidth = element.offsetWidth;
if (offsetWidth != width) {
- LOG.error("The element with id=" + id + " has wrong width: expected=" + width + " actual=" + offsetWidth);
+ LOG.error("The element '" + element.tagName + "' with id='" + element.id + "' has wrong width: expected=" + width + " actual=" + offsetWidth);
}
}
-function checkHeight(id, height) {
- var offsetHeight = document.getElementById(id).offsetHeight;
+function checkHeight(element, height) {
+ var offsetHeight = element.offsetHeight;
if (offsetHeight != height) {
- LOG.error("The element with id=" + id + " has wrong height: expected=" + height + " actual=" + offsetHeight);
+ LOG.error("The element '" + element.tagName + "' with id='" + element.id + "' has wrong height: expected=" + height + " actual=" + offsetHeight);
}
}
-function checkLayout(id, left, top, width, height) {
- checkLeft(id, left);
- checkTop(id, top);
- checkWidth(id, width);
- checkHeight(id, height);
+function checkLayout(elementOrId, left, top, width, height) {
+ var element;
+ if (typeof elementOrId == "string") {
+ element = document.getElementById(elementOrId);
+ checkLeft(element, left);
+ checkTop(element, top);
+ checkWidth(element, width);
+ checkHeight(element, height);
+ } else { // JQuery Object Array
+ element = elementOrId.get(0);
+ checkLeft(element, left);
+ checkTop(element, top);
+ checkWidth(element, width);
+ checkHeight(element, height);
+ }
}
function checkAbsence(id) {
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tx/in/in.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tx/in/in.xhtml?rev=979655&r1=979654&r2=979655&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tx/in/in.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tx/in/in.xhtml Tue Jul 27 11:56:57 2010
@@ -29,10 +29,14 @@
</f:facet>
<tc:gridLayoutConstraint width="600px" height="60px"/>
- <tx:in label="Label" value="Some Value"/>
- <tx:in label="Label" value="Some Value"/>
- <tx:in label="Label" value="Some Value"/>
- <tx:in label="Label" value="Some Value"/>
+ <tx:in label="Label 1" value="Some Value 1"/>
+ <tx:in label="Label 2" value="Some Value 2"/>
+ <tx:in label="Label 3" value="Some Value 3"/>
+ <tx:in label="Label 4" value="Some Value 4"/>
+
+ <tc:script file="script/test-utils.js"/>
+
+ <tc:script onload="checkLayout(jQuery('#j_id1\\:j_id17'), 0, 75, 120, 20);"/>
</tc:page>
</f:view>