Author: lfryc(a)redhat.com
Date: 2009-09-02 11:01:21 -0400 (Wed, 02 Sep 2009)
New Revision: 15442
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/style/StyleTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/style/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/style/messages.properties
Log:
- refactored Style test cases to follow conventions
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/style/StyleTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/style/StyleTestCase.java 2009-09-02
14:44:59 UTC (rev 15441)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/style/StyleTestCase.java 2009-09-02
15:01:21 UTC (rev 15442)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces
+ *
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This code is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This code 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 test suite; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.jboss.richfaces.integrationTest.style;
import java.util.LinkedHashMap;
@@ -3,8 +23,9 @@
import java.util.Map;
-import junit.framework.Assert;
+import static org.testng.Assert.*;
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
import org.jboss.test.selenium.waiting.Wait;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -14,44 +35,50 @@
* @version $Revision$
*/
public class StyleTestCase extends AbstractSeleniumRichfacesTestCase {
- /**
- * Opens specified page
- */
- private void openPage() {
- selenium.open(contextPath
- + "/richfaces/style.jsf?c=loadStyle&tab=usage");
- scrollIntoView(header, true);
- }
- private String header = getLoc("style--header");
- private String linkDeepMarine = getLoc("style--link--deep-marine");
- private String linkBlueSky = getLoc("style--link--blue-sky");
- private String linkJapanCherry = getLoc("style--link--japan-cherry");
- private String tableOutput = getLoc("style--table--output");
- private String colorDeepMarine = getMess("style--color--deep-marine");
- private String colorBlueSky = getMess("style--color--blue-sky");
- private String colorJapanCherry = getMess("style--color--japan-cherry");
+ private String LOC_FIELDSET_HEADER = getLoc("FIELDSET_HEADER");
+ private String LOC_LINK_DEEP_MARINE = getLoc("LINK_DEEP_MARINE");
+ private String LOC_LINK_BLUE_SKY = getLoc("LINK_BLUE_SKY");
+ private String LOC_LINK_JAPAN_CHERRY = getLoc("LINK_JAPAN_CHERRY");
+ private String LOC_PANEL = getLoc("PANEL");
+ private String MSG_COLOR_DEEP_MARINE = getMsg("COLOR_DEEP_MARINE");
+ private String MSG_COLOR_BLUE_SKY = getMsg("COLOR_BLUE_SKY");
+ private String MSG_COLOR_JAPAN_CHERRY = getMsg("COLOR_JAPAN_CHERRY");
+
Map<String, String> relation = new LinkedHashMap<String, String>() {
+ private static final long serialVersionUID = 1576758688687867261L;
{
- put(linkDeepMarine, colorDeepMarine);
- put(linkBlueSky, colorBlueSky);
- put(linkJapanCherry, colorJapanCherry);
+ put(LOC_LINK_DEEP_MARINE, MSG_COLOR_DEEP_MARINE);
+ put(LOC_LINK_BLUE_SKY, MSG_COLOR_BLUE_SKY);
+ put(LOC_LINK_JAPAN_CHERRY, MSG_COLOR_JAPAN_CHERRY);
}
};
+ /**
+ * Clicks on the skin names and waits for background-color changes
+ * appropriately.
+ */
@Test
public void testBackgroundColor() {
- openPage();
+ for (final String locLink : relation.keySet()) {
+ final String msgColor = relation.get(locLink);
- for (final String link : relation.keySet()) {
- final String color = relation.get(link);
-
- selenium.click(link);
+ selenium.click(locLink);
selenium.waitForPageToLoad(Long.toString(Wait.DEFAULT_TIMEOUT));
- scrollIntoView(header, true);
- Assert.assertEquals(color, getStyle(tableOutput, "background-color"));
+ scrollIntoView(LOC_FIELDSET_HEADER, true);
+
+ assertEquals(msgColor, getStyle(LOC_PANEL, "background-color"), format(
+ "background-color for '{0}' skin does not match",
selenium.getText(locLink)));
}
}
+
+ @SuppressWarnings("unused")
+ @BeforeMethod
+ private void loadPage() {
+ openComponent("Style");
+
+ scrollIntoView(LOC_FIELDSET_HEADER, true);
+ }
}
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/style/locators.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/style/locators.properties 2009-09-02
14:44:59 UTC (rev 15441)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/style/locators.properties 2009-09-02
15:01:21 UTC (rev 15442)
@@ -1,5 +1,5 @@
-style--header=//legend[text()\='Style demo']
-style--link--deep-marine=//a[text()\='DeepMarine']
-style--link--blue-sky=//a[text()\='BlueSky']
-style--link--japan-cherry=//a[text()\='JapanCherry']
-style--table--output=//table[@class\='rsPanel']
\ No newline at end of file
+FIELDSET_HEADER=//legend[text()\='Style demo']
+LINK_DEEP_MARINE=//a[text()\='DeepMarine']
+LINK_BLUE_SKY=//a[text()\='BlueSky']
+LINK_JAPAN_CHERRY=//a[text()\='JapanCherry']
+PANEL=//table[@class\='rsPanel']
\ No newline at end of file
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/style/messages.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/style/messages.properties 2009-09-02
14:44:59 UTC (rev 15441)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/style/messages.properties 2009-09-02
15:01:21 UTC (rev 15442)
@@ -1,3 +1,3 @@
-style--color--deep-marine=rgb(0, 136, 148)
-style--color--blue-sky=rgb(190, 214, 248)
-style--color--japan-cherry=rgb(232, 189, 189)
+COLOR_DEEP_MARINE=rgb(0, 136, 148)
+COLOR_BLUE_SKY=rgb(190, 214, 248)
+COLOR_JAPAN_CHERRY=rgb(232, 189, 189)