Author: lfryc(a)redhat.com
Date: 2011-01-28 08:09:56 -0500 (Fri, 28 Jan 2011)
New Revision: 21302
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/AbstractDragNDropTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragSource/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragSource/DragSourceAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragSource/TestDragSource.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/Indicator.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/TestDragIndicator.java
Log:
rich:dragSource - automated (RFPL-992)
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/AbstractDragNDropTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/AbstractDragNDropTest.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/AbstractDragNDropTest.java 2011-01-28
13:09:56 UTC (rev 21302)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.richDragIndicator;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static
org.richfaces.tests.metamer.ftest.richDragIndicator.Indicator.IndicatorState.ACCEPTING;
+import static
org.richfaces.tests.metamer.ftest.richDragIndicator.Indicator.IndicatorState.DRAGGING;
+import static
org.richfaces.tests.metamer.ftest.richDragIndicator.Indicator.IndicatorState.REJECTING;
+
+import org.jboss.test.selenium.actions.Drag;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.richDragIndicator.Indicator.IndicatorState;
+import org.testng.annotations.BeforeMethod;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class AbstractDragNDropTest extends AbstractMetamerTest {
+
+ protected Draggable drg1 = new Draggable("drg1",
jq("[id$=draggable1]"));
+ protected Draggable drg2 = new Draggable("drg2",
jq("[id$=draggable2]"));
+ protected Draggable drg3 = new Draggable("drg3",
jq("[id$=draggable3]"));
+
+ protected Droppable drop1 = new Droppable("drop1",
jq("[id$=droppable1]"));
+ protected Droppable drop2 = new Droppable("drop2",
jq("[id$=droppable2]"));
+
+ protected Drag drag;
+ protected Indicator indicator;
+
+ @BeforeMethod
+ public void setupIndicator() {
+ indicator = new Indicator("ind",
jq("div.rf-ind[id$=indicator]"));
+ }
+
+ protected void testMovingOverDifferentStates() {
+ enterAndVerify(drop2, REJECTING);
+ enterAndVerify(drop1, ACCEPTING);
+ enterAndVerify(drg1, DRAGGING);
+ enterAndVerify(drop1, ACCEPTING);
+ enterAndVerify(drg2, DRAGGING);
+ enterAndVerify(drop2, REJECTING);
+ enterAndVerify(drg2, DRAGGING);
+ enterAndVerify(drop1, ACCEPTING);
+ enterAndVerify(drop2, REJECTING);
+ }
+
+ protected void enterAndVerify(ElementLocator<?> target, IndicatorState state)
{
+ drag.setDropTarget(target);
+ drag.enter();
+ indicator.verifyState(state);
+ }
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/Indicator.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/Indicator.java 2011-01-28
13:09:13 UTC (rev 21301)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/Indicator.java 2011-01-28
13:09:56 UTC (rev 21302)
@@ -38,6 +38,7 @@
private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+ private boolean defaultIndicator = false;
private String acceptClass;
private String rejectClass;
private String draggingClass;
@@ -45,6 +46,10 @@
public Indicator(String name, JQueryLocator root) {
super(name, root);
}
+
+ public void setDefaultIndicator(boolean defaultIndicator) {
+ this.defaultIndicator = defaultIndicator;
+ }
public void setAcceptClass(String acceptClass) {
this.acceptClass = acceptClass;
@@ -74,6 +79,9 @@
}
public boolean isDragging() {
+ if (defaultIndicator) {
+ return isVisible();
+ }
return isVisible() && selenium.belongsClass(this,
"rf-ind-drag");
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/TestDragIndicator.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/TestDragIndicator.java 2011-01-28
13:09:13 UTC (rev 21301)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragIndicator/TestDragIndicator.java 2011-01-28
13:09:56 UTC (rev 21302)
@@ -21,7 +21,6 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richDragIndicator;
-import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -30,7 +29,6 @@
import org.jboss.test.selenium.actions.Drag;
import org.jboss.test.selenium.request.RequestType;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.richfaces.tests.metamer.ftest.richDragIndicator.Indicator.IndicatorState;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -39,23 +37,14 @@
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class TestDragIndicator extends AbstractMetamerTest {
+public class TestDragIndicator extends AbstractDragNDropTest {
private final static String ACCEPT_CLASS = "sample-accept-class";
private final static String REJECT_CLASS = "sample-reject-class";
private final static String DRAGGING_CLASS = "sample-dragging-class";
- Draggable drg1 = new Draggable("drg1", pjq("[id$=draggable1]"));
- Draggable drg2 = new Draggable("drg2", pjq("[id$=draggable2]"));
- Draggable drg3 = new Draggable("drg3", pjq("[id$=draggable3]"));
+ private DragIndicatorAttributes attributes = new DragIndicatorAttributes();
- Droppable drop1 = new Droppable("drop1",
pjq("[id$=droppable1]"));
- Droppable drop2 = new Droppable("drop2",
pjq("[id$=droppable2]"));
-
- Indicator indicator = new Indicator("ind",
jq("div.rf-ind[id$=indicator]"));
-
- DragIndicatorAttributes attributes = new DragIndicatorAttributes();
-
@Override
public URL getTestUrl() {
return buildUrl(contextPath,
"faces/components/richDragIndicator/simple.xhtml");
@@ -74,11 +63,11 @@
@Test
public void testRendered() {
attributes.setRendered(false);
-
selenium.getPageExtensions().install();
selenium.getRequestInterceptor().clearRequestTypeDone();
- Drag drag = new Drag(drg1, drop1);
+ drag = new Drag(drg1, drop1);
+ drag.setDragIndicator(indicator);
drag.start();
assertFalse(selenium.isElementPresent(indicator));
drag.enter();
@@ -92,7 +81,8 @@
@Test
public void testDragging() {
- Drag drag = new Drag(drg1, drg2);
+ drag = new Drag(drg1, drg2);
+ drag.setDragIndicator(indicator);
indicator.verifyState(IndicatorState.HIDDEN);
drag.start();
@@ -107,7 +97,8 @@
@Test
public void testAccepting() {
- Drag drag = new Drag(drg1, drop1);
+ drag = new Drag(drg1, drop1);
+ drag.setDragIndicator(indicator);
indicator.verifyState(IndicatorState.HIDDEN);
drag.start();
@@ -122,7 +113,8 @@
@Test
public void testRejecting() {
- Drag drag = new Drag(drg1, drop2);
+ drag = new Drag(drg1, drop2);
+ drag.setDragIndicator(indicator);
indicator.verifyState(IndicatorState.HIDDEN);
drag.start();
@@ -137,41 +129,10 @@
@Test
public void testMovingOverDifferentStates() {
- Drag drag = new Drag(drg1, drop2);
- drag.enter();
- indicator.verifyState(IndicatorState.REJECTING);
-
- drag.setDropTarget(drop1);
- drag.enter();
- indicator.verifyState(IndicatorState.ACCEPTING);
-
- drag.setDropTarget(drg1);
- drag.enter();
- indicator.verifyState(IndicatorState.DRAGGING);
-
- drag.setDropTarget(drop1);
- drag.enter();
- indicator.verifyState(IndicatorState.ACCEPTING);
-
- drag.setDropTarget(drg2);
- drag.enter();
- indicator.verifyState(IndicatorState.DRAGGING);
-
- drag.setDropTarget(drop2);
- drag.enter();
- indicator.verifyState(IndicatorState.REJECTING);
-
- drag.setDropTarget(drg2);
- drag.enter();
- indicator.verifyState(IndicatorState.DRAGGING);
-
- drag.setDropTarget(drop1);
- drag.enter();
- indicator.verifyState(IndicatorState.ACCEPTING);
-
- drag.setDropTarget(drop2);
- drag.enter();
- indicator.verifyState(IndicatorState.REJECTING);
+ drag = new Drag(drg1, drop2);
+ drag.setDragIndicator(indicator);
+ drag.setNumberOfSteps(20);
+ super.testMovingOverDifferentStates();
}
}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragSource/DragSourceAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragSource/DragSourceAttributes.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragSource/DragSourceAttributes.java 2011-01-28
13:09:56 UTC (rev 21302)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.richDragSource;
+
+import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DragSourceAttributes extends AbstractComponentAttributes {
+ public void setDragIndicator(String dragIndicator) {
+ setProperty("dragIndicator", dragIndicator);
+ }
+
+ public void setType(String type) {
+ setProperty("type", type);
+ }
+
+ public void setRendered(Boolean rendered) {
+ setProperty("rendered", rendered);
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragSource/TestDragSource.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragSource/TestDragSource.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDragSource/TestDragSource.java 2011-01-28
13:09:56 UTC (rev 21302)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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.richDragSource;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.actions.Drag;
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.tests.metamer.ftest.richDragIndicator.AbstractDragNDropTest;
+import org.richfaces.tests.metamer.ftest.richDragIndicator.Indicator;
+import org.richfaces.tests.metamer.ftest.richDragIndicator.Indicator.IndicatorState;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestDragSource extends AbstractDragNDropTest {
+
+ DragSourceAttributes attributes = new DragSourceAttributes();
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richDragSource/simple.xhtml");
+ }
+
+ @Test
+ public void testDefaultIndicator() {
+ indicator = new Indicator("defaultIndicator",
drg1.getNthOccurence(2));
+ indicator.setDefaultIndicator(true);
+ attributes.setDragIndicator("");
+
+ drag = new Drag(drg1, drop1);
+ drag.setDragIndicator(indicator);
+ drag.setNumberOfSteps(10);
+ testMovingOverDifferentStates();
+ }
+
+ @Test
+ public void testCustomIndicator() {
+ indicator = new Indicator("ind",
jq("div.rf-ind[id$=indicator2]"));
+ attributes.setDragIndicator("indicator2");
+
+ drag = new Drag(drg1, drop1);
+ drag.setDragIndicator(indicator);
+ drag.setNumberOfSteps(20);
+ testMovingOverDifferentStates();
+ }
+
+ @Test
+ public void testRendered() {
+ attributes.setRendered(false);
+ selenium.getPageExtensions().install();
+ selenium.getRequestInterceptor().clearRequestTypeDone();
+
+ drag = new Drag(drg1, drop1);
+ drag.setDragIndicator(indicator);
+ drag.start();
+ assertFalse(indicator.isVisible());
+ drag.enter();
+ assertFalse(indicator.isVisible());
+
+ drag.drop();
+
+ waitModel.timeout(5000).waitForTimeout();
+ assertEquals(selenium.getRequestInterceptor().getRequestTypeDone(),
RequestType.NONE);
+ }
+
+ @Test
+ public void testType() {
+ attributes.setType("drg3");
+ drag = new Drag(drg1, drop2);
+ drag.setDragIndicator(indicator);
+ enterAndVerify(drop2, IndicatorState.ACCEPTING);
+ enterAndVerify(drg2, IndicatorState.DRAGGING);
+ enterAndVerify(drop1, IndicatorState.REJECTING);
+ }
+
+}