Author: lfryc(a)redhat.com
Date: 2010-07-28 09:43:29 -0400 (Wed, 28 Jul 2010)
New Revision: 18259
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AbstractModel.java
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
Log:
derived new AbstractModel for component part models encapsulation such as DataTable,
DataScroller
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java 2010-07-28
13:42:37 UTC (rev 18258)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java 2010-07-28
13:43:29 UTC (rev 18259)
@@ -45,4 +45,9 @@
public void setLocator(T locator) {
this.reference = locator;
}
+
+ @Override
+ public String toString() {
+ return "ref@" + reference;
+ }
}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AbstractModel.java
(from rev 18258,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AbstractModel.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AbstractModel.java 2010-07-28
13:43:29 UTC (rev 18259)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.model;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+import org.jboss.test.selenium.locator.IterableLocator;
+import org.jboss.test.selenium.locator.reference.LocatorReference;
+
+/**
+ * Abstract DataModel defining root reference for deriving all other locators.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ *
+ * @param <T>
+ * the iterable locator type of root
+ */
+public abstract class AbstractModel<T extends IterableLocator<T>> {
+
+ protected LocatorReference<T> root = new LocatorReference<T>(null);
+
+ public AbstractModel(T root) {
+ setRoot(root);
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this,
ToStringStyle.SIMPLE_STYLE).append(root).toString();
+ }
+
+ public void setRoot(T root) {
+ this.root.setLocator(root);
+ }
+
+ public T getRoot() {
+ return root.getLocator();
+ }
+}
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2010-07-28
13:42:37 UTC (rev 18258)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2010-07-28
13:43:29 UTC (rev 18259)
@@ -22,29 +22,26 @@
package org.richfaces.tests.metamer.ftest.model;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
+
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.locator.reference.LocatorReference;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
-import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
-
/**
* Provides DataScroller control methods.
*
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class DataScroller {
+public class DataScroller extends AbstractModel<JQueryLocator> {
protected static final String CLASS_DISABLED = "rf-ds-dis";
AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- LocatorReference<JQueryLocator> root = new
LocatorReference<JQueryLocator>(null);
-
ReferencedLocator<JQueryLocator> numberedPages = ref(root, ">
.rf-ds-dtl");
ReferencedLocator<JQueryLocator> specificNumberedPage = ref(root, ">
.rf-ds-dtl:textEquals('{0}')");
@@ -61,17 +58,9 @@
Integer lastPage = null;
public DataScroller(JQueryLocator root) {
- setRoot(root);
+ super(root);
}
- public JQueryLocator getRoot() {
- return root.getLocator();
- }
-
- public void setRoot(JQueryLocator root) {
- this.root.setLocator(root);
- }
-
public void setFastStep(int fastStep) {
this.fastStep = fastStep;
}
@@ -208,6 +197,4 @@
public void clickFastRewind() {
guardXhr(selenium).click(fastRewindButton);
}
-
-
}
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java 2010-07-28
13:42:37 UTC (rev 18258)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java 2010-07-28
13:43:29 UTC (rev 18259)
@@ -24,7 +24,6 @@
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.locator.reference.LocatorReference;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
@@ -35,16 +34,14 @@
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class DataTable {
+public class DataTable extends AbstractModel<JQueryLocator> {
AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- LocatorReference<JQueryLocator> root = new
LocatorReference<JQueryLocator>(null);
-
ReferencedLocator<JQueryLocator> tableRows = ref(root, "> div.rf-edt-b
table table tr");
- public DataTable(JQueryLocator tableRoot) {
- root.setLocator(tableRoot);
+ public DataTable(JQueryLocator root) {
+ super(root);
}
public int getCountOfTableRows() {