This repository has been archived by the owner on Nov 17, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge functional tests for pickList + the base for ftest setup
- Loading branch information
Showing
16 changed files
with
1,258 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Running Integration Tests | ||
------------------------- | ||
|
||
See "How To Run Fundamental Tests":https://github.com/richfaces/build/blob/develop/fundamental-tests.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...emo/src/test/integration/org/richfaces/bootstrap/demo/ftest/AbstractBootsrapDemoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, 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.bootstrap.demo.ftest; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.importer.ZipImporter; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* @author <a href="mailto:jstefek@redhat.com">Jiri Stefek</a> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class AbstractBootsrapDemoTest { | ||
|
||
@ArquillianResource | ||
protected URL deploymentURL; | ||
|
||
@Deployment(testable = false) | ||
public static WebArchive createTestArchive() { | ||
// TODO doesn't work | ||
// return ShrinkWrap.create(MavenImporter.class, "bootstrap-demo.war").loadPomFromFile("pom.xml").importBuildOutput() | ||
// .as(WebArchive.class); | ||
return ShrinkWrap.create(ZipImporter.class, "bootstrap-demo.war").importFrom(new File("target/bootstrap-demo.war")) | ||
.as(WebArchive.class); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
.../test/integration/org/richfaces/bootstrap/demo/ftest/webdriver/AbstractWebDriverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, 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.bootstrap.demo.ftest.webdriver; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import org.jboss.arquillian.drone.api.annotation.Drone; | ||
import org.junit.Before; | ||
import org.openqa.selenium.WebDriver; | ||
import org.richfaces.bootstrap.demo.ftest.AbstractBootsrapDemoTest; | ||
|
||
/** | ||
* @author <a href="mailto:jstefek@redhat.com">Jiri Stefek</a> | ||
*/ | ||
public abstract class AbstractWebDriverTest extends AbstractBootsrapDemoTest { | ||
|
||
private static final String PREFIX_TEST_URL = "component/"; | ||
// | ||
@Drone | ||
protected WebDriver driver; | ||
|
||
abstract protected String getComponentName(); | ||
|
||
private URL getPathURL() throws MalformedURLException { | ||
return new URL(deploymentURL, getTestURL()); | ||
} | ||
|
||
private String getTestURL() { | ||
return PREFIX_TEST_URL + getComponentName(); | ||
} | ||
|
||
@Before | ||
public void initialize() throws MalformedURLException { | ||
initializePageUrl(); | ||
} | ||
|
||
public void initializePageUrl() throws MalformedURLException { | ||
driver.get(getPathURL().toString()); | ||
} | ||
} |
200 changes: 200 additions & 0 deletions
200
.../test/integration/org/richfaces/bootstrap/demo/ftest/webdriver/pickList/TestPickList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
/** | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, 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.bootstrap.demo.ftest.webdriver.pickList; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Before; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.openqa.selenium.support.FindBy; | ||
import org.richfaces.bootstrap.demo.ftest.webdriver.AbstractWebDriverTest; | ||
import org.richfaces.bootstrap.demo.ftest.webdriver.pickList.fragment.BootstrapPickListImpl; | ||
import org.richfaces.bootstrap.demo.ftest.webdriver.pickList.fragment.PickListList; | ||
import org.richfaces.bootstrap.demo.ftest.webdriver.pickList.fragment.PickListSelection.With; | ||
|
||
/** | ||
* @author <a href="mailto:jstefek@redhat.com">Jiri Stefek</a> | ||
*/ | ||
public class TestPickList extends AbstractWebDriverTest { | ||
|
||
private static final String[] CAPITALS = new String[]{ "Montgomery", "Phoenix", "Denver", "Atlanta" }; | ||
private int initListSize; | ||
// | ||
@FindBy(css = "div[class='pickList outer']") | ||
BootstrapPickListImpl pickList; | ||
|
||
private void assertListContainsCapitals(PickListList list, String... capitals) { | ||
for (String capital : capitals) { | ||
assertTrue("List don't contains capital " + capital, list.contains(capital)); | ||
} | ||
} | ||
|
||
private void assertListDontContainsCapitals(PickListList list, String... capitals) { | ||
for (String capital : capitals) { | ||
assertFalse("List contains capital " + capital, list.contains(capital)); | ||
} | ||
} | ||
|
||
private void assertLeftListSize(int size) { | ||
assertListSize(pickList.getSourceList(), size); | ||
} | ||
|
||
private void assertRightListSize(int size) { | ||
assertListSize(pickList.getTargetList(), size); | ||
} | ||
|
||
private void assertListSize(PickListList list, int size) { | ||
assertEquals(size, list.size()); | ||
} | ||
|
||
private void assertCapitalsInOrderInRightList(String... capitals) { | ||
assertCapitalsInOrderInList(pickList.getTargetList(), capitals); | ||
} | ||
|
||
private void assertCapitalsInOrderInList(PickListList list, String... capitals) { | ||
assertEquals(list.size(), capitals.length); | ||
for (int i = 0; i < capitals.length; i++) { | ||
String capital = list.getKeyAtIndex(i); | ||
assertEquals(capitals[i], capital); | ||
} | ||
} | ||
|
||
@Override | ||
protected String getComponentName() { | ||
return "pickList"; | ||
} | ||
|
||
@Before | ||
public void initializeInitListSize() { | ||
this.initListSize = pickList.getSourceList().size(); | ||
assertTrue(initListSize > 0); | ||
} | ||
|
||
@Test | ||
public void testAddAllRemoveAllButtons() { | ||
pickList.addAll(); | ||
assertLeftListSize(0); | ||
assertRightListSize(initListSize); | ||
pickList.removeAll(); | ||
assertLeftListSize(initListSize); | ||
assertRightListSize(0); | ||
} | ||
|
||
@Test | ||
public void testAddButtonSimple() { | ||
pickList.selectFromSourceList(CAPITALS[1]).transferByOne(With.button); | ||
assertListContainsCapitals(pickList.getTargetList(), CAPITALS[1]); | ||
assertListDontContainsCapitals(pickList.getSourceList(), CAPITALS[1]); | ||
assertLeftListSize(initListSize - 1); | ||
assertRightListSize(1); | ||
} | ||
|
||
@Test | ||
public void testAddByDnD() { | ||
pickList.selectFromSourceList(CAPITALS[1]).transferByOne(With.dnd); | ||
assertListContainsCapitals(pickList.getTargetList(), CAPITALS[1]); | ||
assertListDontContainsCapitals(pickList.getSourceList(), CAPITALS[1]); | ||
assertLeftListSize(initListSize - 1); | ||
assertRightListSize(1); | ||
} | ||
|
||
@Ignore("cannot select multiple elements with ctrl") | ||
@Test | ||
public void testAddMultipleByButton() { | ||
pickList.selectFromSourceList(CAPITALS).transferMultiple(With.button); | ||
|
||
assertRightListSize(CAPITALS.length); | ||
assertLeftListSize(initListSize - CAPITALS.length); | ||
assertListContainsCapitals(pickList.getTargetList(), CAPITALS); | ||
assertListDontContainsCapitals(pickList.getSourceList(), CAPITALS); | ||
} | ||
|
||
@Ignore(value = "cannot select multiple elements with ctrl") | ||
@Test | ||
public void testAddMultipleByDnD() { | ||
pickList.selectFromSourceList(CAPITALS).transferMultiple(With.dnd); | ||
|
||
assertRightListSize(CAPITALS.length); | ||
assertLeftListSize(initListSize - CAPITALS.length); | ||
assertListContainsCapitals(pickList.getTargetList(), CAPITALS); | ||
assertListDontContainsCapitals(pickList.getSourceList(), CAPITALS); | ||
} | ||
|
||
@Test | ||
public void testInit() { | ||
assertTrue("PickList is not visible", pickList.isVisible()); | ||
assertFalse("Source list of pickList should not be empty", pickList.getSourceList().isEmpty()); | ||
assertTrue("Target list of pickList should be empty", pickList.getTargetList().isEmpty()); | ||
} | ||
|
||
@Test | ||
public void testListOrderingSimpleByButtons() { | ||
pickList.selectFromSourceList(CAPITALS[2], CAPITALS[1], CAPITALS[0]).transferByOne(With.button); | ||
//reverse order, the last added will be on peak | ||
assertCapitalsInOrderInRightList(CAPITALS[0], CAPITALS[1], CAPITALS[2]); | ||
|
||
//test 'first' button | ||
pickList.selectFromTargetList(CAPITALS[2]).first(); | ||
assertCapitalsInOrderInRightList(CAPITALS[2], CAPITALS[0], CAPITALS[1]); | ||
pickList.selectFromTargetList(CAPITALS[2]).first(); | ||
assertCapitalsInOrderInRightList(CAPITALS[2], CAPITALS[0], CAPITALS[1]); | ||
|
||
//test 'up' button | ||
pickList.selectFromTargetList(CAPITALS[0]).up(); | ||
assertCapitalsInOrderInRightList(CAPITALS[0], CAPITALS[2], CAPITALS[1]); | ||
pickList.selectFromTargetList(CAPITALS[0]).up(); | ||
assertCapitalsInOrderInRightList(CAPITALS[0], CAPITALS[2], CAPITALS[1]); | ||
|
||
//test 'down' button | ||
pickList.selectFromTargetList(CAPITALS[2]).down(); | ||
assertCapitalsInOrderInRightList(CAPITALS[0], CAPITALS[1], CAPITALS[2]); | ||
pickList.selectFromTargetList(CAPITALS[2]).down(); | ||
assertCapitalsInOrderInRightList(CAPITALS[0], CAPITALS[1], CAPITALS[2]); | ||
|
||
//test 'last' button | ||
pickList.selectFromTargetList(CAPITALS[0]).last(); | ||
assertCapitalsInOrderInRightList(CAPITALS[1], CAPITALS[2], CAPITALS[0]); | ||
pickList.selectFromTargetList(CAPITALS[0]).last(); | ||
assertCapitalsInOrderInRightList(CAPITALS[1], CAPITALS[2], CAPITALS[0]); | ||
} | ||
|
||
@Test | ||
public void testRemoveButtonSimple() { | ||
pickList.selectFromSourceList(CAPITALS[1]).transferByOne(With.button); | ||
pickList.selectFromTargetList(CAPITALS[1]).transferByOne(With.button); | ||
assertLeftListSize(initListSize); | ||
assertListContainsCapitals(pickList.getSourceList(), CAPITALS[1]); | ||
assertRightListSize(0); | ||
} | ||
|
||
@Test | ||
public void testRemoveByDnD() { | ||
pickList.selectFromSourceList(CAPITALS[1]).transferByOne(With.dnd); | ||
pickList.selectFromTargetList(CAPITALS[1]).transferByOne(With.dnd); | ||
assertLeftListSize(initListSize); | ||
assertListContainsCapitals(pickList.getSourceList(), CAPITALS[1]); | ||
assertRightListSize(0); | ||
} | ||
} |
Oops, something went wrong.