Author: jjamrich
Date: 2011-06-06 08:46:33 -0400 (Mon, 06 Jun 2011)
New Revision: 22523
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanelAddPanel1.java
Log:
Save work on tabPanel dynamic tab create selenium test
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanelAddPanel1.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanelAddPanel1.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTabPanel/TestRichTabPanelAddPanel1.java 2011-06-06
12:46:33 UTC (rev 22523)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-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.richfaces.tests.metamer.ftest.richTabPanel;
+
+import static
org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardNoRequest;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/richTabPanel/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestRichTabPanelAddPanel1 extends AbstractMetamerTest {
+
+ private JQueryLocator panel = pjq("div[id$=tabPanel]");
+ private JQueryLocator[] items = {pjq("div[id$=tab1]"),
pjq("div[id$=tab2]"), pjq("div[id$=tab3]"),
pjq("div[id$=tab4]"),
+ pjq("div[id$=tab5]")};
+ private JQueryLocator[] itemContents = {pjq("div[id$=tab1] >
div.rf-tab-cnt"), pjq("div[id$=tab2] > div.rf-tab-cnt"),
+ pjq("div[id$=tab3] > div.rf-tab-cnt"), pjq("div[id$=tab4] >
div.rf-tab-cnt"), pjq("div[id$=tab5] > div.rf-tab-cnt"),
+ pjq("div[id$=tab6] > div.rf-tab-cnt"), pjq("div[id$=tab7] >
div.rf-tab-cnt"), pjq("div[id$=tab8] > div.rf-tab-cnt")};
+ private JQueryLocator[] activeHeaders = {pjq("td[id$=tab1:header:active]"),
pjq("td[id$=tab2:header:active]"),
+ pjq("td[id$=tab3:header:active]"),
pjq("td[id$=tab4:header:active]"),
pjq("td[id$=tab5:header:active]")};
+ private JQueryLocator[] inactiveHeaders =
{pjq("td[id$=tab1:header:inactive]"),
pjq("td[id$=tab2:header:inactive]"),
+ pjq("td[id$=tab3:header:inactive]"),
pjq("td[id$=tab4:header:inactive]"),
pjq("td[id$=tab5:header:inactive]"),
+ pjq("td[id$=tab6:header:inactive]"),
pjq("td[id$=tab7:header:inactive]"),
pjq("td[id$=tab8:header:inactive]") };
+ private JQueryLocator[] disabledHeaders =
{pjq("td[id$=tab1:header:disabled]"),
pjq("td[id$=tab2:header:disabled]"),
+ pjq("td[id$=tab3:header:disabled]"),
pjq("td[id$=tab4:header:disabled]"),
pjq("td[id$=tab5:header:disabled]")};
+
+ private JQueryLocator hCreateTabBtn = pjq("input[id$=hCreateTabButton]");
+ private JQueryLocator aa4jCreateTabBtn =
pjq("input[id$=a4jCreateTabButton]");
+
+ private JQueryLocator tabsCount = pjq("table.rf-tab-hdr-tabs
td.rf-tab-hdr-inact");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richTabPanel/addTab.xhtml");
+ }
+
+ @Test
+ public void testInit() {
+ boolean displayed = selenium.isDisplayed(panel);
+ assertTrue(displayed, "Tab panel is not present on the page.");
+
+ displayed = selenium.isDisplayed(activeHeaders[0]);
+ assertTrue(displayed, "Header of tab1 should be active.");
+ for (int i = 1; i < 5; i++) {
+ displayed = selenium.isDisplayed(activeHeaders[i]);
+ assertFalse(displayed, "Header of tab " + (i + 1) + " should
not be active.");
+ }
+
+ displayed = selenium.isDisplayed(inactiveHeaders[0]);
+ assertFalse(displayed, "Header of tab1 should not be inactive.");
+ displayed = selenium.isDisplayed(inactiveHeaders[1]);
+ assertTrue(displayed, "Header of tab2 should be inactive.");
+
+ displayed = selenium.isDisplayed(disabledHeaders[3]);
+ assertTrue(displayed, "Header of tab4 should be disabled.");
+ for (int i = 0; i < 3; i++) {
+ displayed = selenium.isDisplayed(disabledHeaders[i]);
+ assertFalse(displayed, "Header of tab " + (i + 1) + " should
not be disabled.");
+ }
+
+ displayed = selenium.isDisplayed(itemContents[0]);
+ assertTrue(displayed, "Content of item1 should be visible.");
+
+ for (int i = 1; i < 5; i++) {
+ displayed = selenium.isDisplayed(items[i]);
+ assertFalse(displayed, "Tab" + (i + 1) + "'s content
should not be visible.");
+ }
+ }
+
+ @Test(dependsOnMethods = {"testInit"})
+ public void testCreateTab() {
+ selenium.click(pjq("input[name$=switchTypeInput][value=client]"));
+ selenium.waitForPageToLoad();
+
+ int baseTabsCount = selenium.getCount(tabsCount);
+
+ // add 3 new tabs
+ for (int i=1; i<4; ++i){
+ selenium.click(hCreateTabBtn);
+ selenium.waitForPageToLoad();
+ waitGui.until(countEquals.count(baseTabsCount + i).locator(tabsCount));
+ }
+ }
+
+ /*
+ * Test plan:
+ * 1. click on 'create tab' btn 3 time and verify that new tabs appeared
+ * 2. verify that switch between newly created tabs still works as in previous tabs
(staticaly created)
+ * 3. verify a4j ajax btn to create new tabs
+ */
+
+ public void testSwitchTypeNull() {
+ for (int i = 7; i >= 5; i--) {
+ final int index = i;
+ guardXhr(selenium).click(inactiveHeaders[index]);
+ waitGui.failWith("Tab " + (index + 1) + " is not
displayed.").until(isDisplayed.locator(itemContents[index]));
+ }
+ }
+
+ @Test(dependsOnMethods = {"testCreateTab"})
+ public void testSwitchTypeAjax() {
+ selenium.click(pjq("input[name$=switchTypeInput][value=ajax]"));
+ selenium.waitForPageToLoad();
+
+ testSwitchTypeNull();
+ }
+
+ @Test(dependsOnMethods = {"testCreateTab"})
+ public void testSwitchTypeClient() {
+ selenium.click(pjq("input[name$=switchTypeInput][value=client]"));
+ selenium.waitForPageToLoad();
+
+ for (int i = 7; i >= 5; i--) {
+ final int index = i;
+ guardNoRequest(selenium).click(inactiveHeaders[index]);
+ waitGui.failWith("Tab " + (index + 1) + " is not
displayed.").until(isDisplayed.locator(itemContents[index]));
+ }
+ }
+
+}