-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARQGRA-199: Provide a way to create Page Fragments dynamically
* To enable this PageFragmentEnricher#createPageFragment and related methods were made static. * Test which creates PageFragment from TabPanel dynamically added. * Static Arquillian#createPageFragment added
- Loading branch information
Juraj Huska
committed
Feb 13, 2013
1 parent
d16dcfb
commit 7637bfd
Showing
12 changed files
with
372 additions
and
16 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
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
32 changes: 32 additions & 0 deletions
32
...ava/org/jboss/arquillian/graphene/component/object/api/switchable/ComponentContainer.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,32 @@ | ||
/** | ||
* 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.jboss.arquillian.graphene.component.object.api.switchable; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:jhuska@redhat.com">Juraj Huska</a> | ||
* | ||
*/ | ||
public interface ComponentContainer { | ||
|
||
<T> T getContent(Class<T> clazz); | ||
} |
33 changes: 33 additions & 0 deletions
33
...va/org/jboss/arquillian/graphene/component/object/api/switchable/SwitchableComponent.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,33 @@ | ||
/** | ||
* 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.jboss.arquillian.graphene.component.object.api.switchable; | ||
|
||
|
||
/** | ||
* | ||
* @author <a href="mailto:jhuska@redhat.com">Juraj Huska</a> | ||
* | ||
*/ | ||
public interface SwitchableComponent { | ||
|
||
ComponentContainer switchTo(int i); | ||
} |
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
74 changes: 74 additions & 0 deletions
74
...t/src/test/java/org/jboss/arquillian/graphene/enricher/TestEnrichingContainerElement.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,74 @@ | ||
/** | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, 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.jboss.arquillian.graphene.enricher; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.net.URL; | ||
|
||
import org.jboss.arquillian.drone.api.annotation.Drone; | ||
import org.jboss.arquillian.graphene.enricher.findby.FindBy; | ||
import org.jboss.arquillian.graphene.enricher.page.fragment.Panel; | ||
import org.jboss.arquillian.graphene.enricher.page.fragment.TabPanel; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
|
||
/** | ||
* @author <a href="mailto:jhuska@redhat.com">Juraj Huska</a> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class TestEnrichingContainerElement { | ||
|
||
@Drone | ||
private WebDriver browser; | ||
|
||
@FindBy(className = "tabpanel") | ||
private TabPanel tabPanel; | ||
|
||
@Before | ||
public void loadPage() { | ||
URL page = this.getClass().getClassLoader() | ||
.getResource("org/jboss/arquillian/graphene/ftest/enricher/container-elements.html"); | ||
browser.get(page.toString()); | ||
} | ||
|
||
@Test | ||
public void testTabPanelSwitching() { | ||
Panel tab3 = tabPanel.switchTo(2); | ||
ContentOfTab content = tab3.getContent(ContentOfTab.class); | ||
assertEquals("The tab panel was not switched to third tab correctly!", "Content of the tab 3", content.text.getText()); | ||
|
||
Panel tab1 = tabPanel.switchTo(0); | ||
content = tab1.getContent(ContentOfTab.class); | ||
assertEquals("The tab panel was not switched to first tab correctly!", "Content of the tab 1", content.text.getText()); | ||
} | ||
|
||
private static class ContentOfTab { | ||
|
||
@FindBy(className = "tab-text") | ||
public WebElement text; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...river-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/fragment/Panel.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,42 @@ | ||
/** | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, 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.jboss.arquillian.graphene.enricher.page.fragment; | ||
|
||
import org.jboss.arquillian.graphene.component.object.api.switchable.ComponentContainer; | ||
import org.jboss.arquillian.graphene.enricher.PageFragmentEnricher; | ||
import org.jboss.arquillian.graphene.spi.annotations.Root; | ||
import org.openqa.selenium.WebElement; | ||
|
||
/** | ||
* @author <a href="mailto:jhuska@redhat.com">Juraj Huska</a> | ||
*/ | ||
public class Panel implements ComponentContainer { | ||
|
||
@Root | ||
private WebElement root; | ||
|
||
@Override | ||
public <T> T getContent(Class<T> clazz) { | ||
return PageFragmentEnricher.createPageFragment(clazz, root); | ||
} | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
...er-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/fragment/TabPanel.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,75 @@ | ||
/** | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011, 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.jboss.arquillian.graphene.enricher.page.fragment; | ||
|
||
import static org.jboss.arquillian.graphene.Graphene.guardHttp; | ||
import static org.jboss.arquillian.graphene.Graphene.guardXhr; | ||
|
||
import java.util.List; | ||
|
||
import org.jboss.arquillian.graphene.Graphene; | ||
import org.jboss.arquillian.graphene.component.object.api.switchable.SwitchableComponent; | ||
import org.jboss.arquillian.graphene.enricher.findby.FindBy; | ||
import org.openqa.selenium.WebElement; | ||
|
||
/** | ||
* @author <a href="mailto:jhuska@redhat.com">Juraj Huska</a> | ||
*/ | ||
public class TabPanel implements SwitchableComponent { | ||
|
||
@FindBy(className = "tabpanel-tab-inact") | ||
private List<WebElement> tabs; | ||
|
||
@FindBy(jquery = ".tabpanel-tab:visible") | ||
private Panel actualTab; | ||
|
||
private SwitchType switchType = SwitchType.CLIENT; | ||
|
||
public enum SwitchType { | ||
CLIENT, | ||
AJAX, | ||
HTTP | ||
} | ||
|
||
@Override | ||
public Panel switchTo(int i) { | ||
switch (switchType) { | ||
case CLIENT: | ||
tabs.get(i).click(); | ||
Graphene.waitGui(); | ||
break; | ||
case AJAX: | ||
guardXhr(tabs.get(i)).click(); | ||
break; | ||
case HTTP: | ||
guardHttp(tabs.get(i)).click(); | ||
break; | ||
} | ||
|
||
return actualTab; | ||
} | ||
|
||
public void setSwitchType(SwitchType switchType) { | ||
this.switchType = switchType; | ||
} | ||
|
||
} |
Oops, something went wrong.