Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add few visual tests (using @screenshot)

These tests are able run with screenshots profile and taking screenshots during run on every selenium action
  • Loading branch information...
commit 30c1beb5ef13be7e8baf2b8bdc3c520b65c24186 1 parent af897a7
Ján Jamrich authored August 20, 2012
311  metamer/ftest/src/test/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordionVisual.java
... ...
@@ -0,0 +1,311 @@
  1
+/*******************************************************************************
  2
+ * JBoss, Home of Professional Open Source
  3
+ * Copyright 2010-2012, Red Hat, Inc. and individual contributors
  4
+ * by the @authors tag. See the copyright.txt in the distribution for a
  5
+ * full listing of individual contributors.
  6
+ *
  7
+ * This is free software; you can redistribute it and/or modify it
  8
+ * under the terms of the GNU Lesser General Public License as
  9
+ * published by the Free Software Foundation; either version 2.1 of
  10
+ * the License, or (at your option) any later version.
  11
+ *
  12
+ * This software is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this software; if not, write to the Free
  19
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21
+ *******************************************************************************/
  22
+package org.richfaces.tests.metamer.ftest.richAccordion;
  23
+
  24
+import static org.jboss.arquillian.ajocado.Graphene.elementVisible;
  25
+import static org.jboss.arquillian.ajocado.Graphene.guardHttp;
  26
+import static org.jboss.arquillian.ajocado.Graphene.guardNoRequest;
  27
+import static org.jboss.arquillian.ajocado.Graphene.guardXhr;
  28
+import static org.jboss.arquillian.ajocado.Graphene.retrieveText;
  29
+import static org.jboss.arquillian.ajocado.Graphene.waitGui;
  30
+import static org.jboss.arquillian.ajocado.utils.URLUtils.buildUrl;
  31
+import static org.jboss.test.selenium.locator.utils.LocatorEscaping.jq;
  32
+import static org.richfaces.tests.metamer.ftest.attributes.AttributeList.accordionAttributes;
  33
+import static org.testng.Assert.assertEquals;
  34
+import static org.testng.Assert.assertFalse;
  35
+import static org.testng.Assert.assertTrue;
  36
+
  37
+import java.net.URL;
  38
+
  39
+import org.jboss.arquillian.ajocado.css.CssProperty;
  40
+import org.jboss.arquillian.ajocado.dom.Attribute;
  41
+import org.jboss.arquillian.ajocado.javascript.JavaScript;
  42
+import org.jboss.arquillian.ajocado.locator.JQueryLocator;
  43
+import org.jboss.arquillian.ajocado.locator.attribute.AttributeLocator;
  44
+import org.richfaces.tests.metamer.ftest.AbstractGrapheneTest;
  45
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
  46
+import org.richfaces.tests.metamer.ftest.annotations.RegressionTest;
  47
+import org.richfaces.tests.metamer.ftest.checker.IconsChecker;
  48
+import org.testng.annotations.Test;
  49
+
  50
+/**
  51
+ * Test case for page /faces/components/richAccordion/simple.xhtml
  52
+ *
  53
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
  54
+ * @version $Revision: 22733 $
  55
+ */
  56
+public class TestRichAccordionVisual extends AbstractGrapheneTest {
  57
+
  58
+    private JQueryLocator accordion = pjq("div[id$=accordion]");
  59
+    private JQueryLocator[] itemHeaders = { pjq("div[id$=item1:header]"), pjq("div[id$=item2:header]"),
  60
+            pjq("div[id$=item3:header]"), pjq("div[id$=item4:header]"), pjq("div[id$=item5:header]") };
  61
+    private JQueryLocator[] itemContents = { pjq("div[id$=item1:content]"), pjq("div[id$=item2:content]"),
  62
+            pjq("div[id$=item3:content]"), pjq("div[id$=item4:content]"), pjq("div[id$=item5:content]") };
  63
+    private JQueryLocator leftIcon = pjq("div[id$=item{0}] td.rf-ac-itm-ico");
  64
+    private JQueryLocator rightIcon = pjq("div[id$=item{0}] td.rf-ac-itm-exp-ico");
  65
+
  66
+    @Override
  67
+    public URL getTestUrl() {
  68
+        return buildUrl(contextPath, "faces/components/richAccordion/simple.xhtml");
  69
+    }
  70
+
  71
+    @Test
  72
+    public void testInit() {
  73
+
  74
+        boolean accordionDisplayed = selenium.isVisible(accordion);
  75
+        assertTrue(accordionDisplayed, "Accordion is not present on the page.");
  76
+
  77
+        for (int i = 0; i < 5; i++) {
  78
+            accordionDisplayed = selenium.isVisible(itemHeaders[i]);
  79
+            assertTrue(accordionDisplayed, "Item" + (i + 1) + "'s header should be visible.");
  80
+        }
  81
+
  82
+        accordionDisplayed = selenium.isVisible(itemContents[0]);
  83
+        assertTrue(accordionDisplayed, "Content of item1 should be visible.");
  84
+
  85
+        for (int i = 1; i < 5; i++) {
  86
+            accordionDisplayed = selenium.isVisible(itemContents[i]);
  87
+            assertFalse(accordionDisplayed, "Item" + (i + 1) + "'s content should not be visible.");
  88
+        }
  89
+    }
  90
+
  91
+    @Test( groups = {"screenshot"} )
  92
+    public void testActiveItem() {
  93
+        accordionAttributes.set(AccordionAttributes.activeItem, "item5");
  94
+
  95
+        boolean accordionDisplayed = selenium.isVisible(accordion);
  96
+        assertTrue(accordionDisplayed, "Accordion is not present on the page.");
  97
+
  98
+        for (int i = 0; i < 5; i++) {
  99
+            accordionDisplayed = selenium.isVisible(itemHeaders[i]);
  100
+            assertTrue(accordionDisplayed, "Item" + (i + 1) + "'s header should be visible.");
  101
+        }
  102
+
  103
+        accordionDisplayed = selenium.isVisible(itemContents[4]);
  104
+        assertTrue(accordionDisplayed, "Content of item5 should be visible.");
  105
+
  106
+        for (int i = 0; i < 4; i++) {
  107
+            accordionDisplayed = selenium.isVisible(itemContents[i]);
  108
+            assertFalse(accordionDisplayed, "Item" + (i + 1) + "'s content should not be visible.");
  109
+        }
  110
+
  111
+        accordionAttributes.set(AccordionAttributes.activeItem, "item4");
  112
+
  113
+        for (int i = 0; i < 5; i++) {
  114
+            accordionDisplayed = selenium.isVisible(itemHeaders[i]);
  115
+            assertTrue(accordionDisplayed, "Item" + (i + 1) + "'s header should be visible.");
  116
+        }
  117
+
  118
+        accordionDisplayed = selenium.isVisible(itemContents[0]);
  119
+        assertTrue(accordionDisplayed, "Content of item1 should be visible.");
  120
+
  121
+        for (int i = 1; i < 5; i++) {
  122
+            accordionDisplayed = selenium.isVisible(itemContents[i]);
  123
+            assertFalse(accordionDisplayed, "Item" + (i + 1) + "'s content should not be visible.");
  124
+        }
  125
+    }
  126
+
  127
+    @Test( groups = {"screenshot"} )
  128
+    public void testCycledSwitching() {
  129
+        String accordionId = selenium.getEval(new JavaScript("window.testedComponentId"));
  130
+        String result = null;
  131
+
  132
+        // RichFaces.$('form:accordion').nextItem('item4') will be null
  133
+        result = selenium.getEval(new JavaScript("window.RichFaces.$('" + accordionId + "').nextItem('item4')"));
  134
+        assertEquals(result, "null", "Result of function nextItem('item4')");
  135
+
  136
+        // RichFaces.$('form:accordion').prevItem('item1') will be null
  137
+        result = selenium.getEval(new JavaScript("window.RichFaces.$('" + accordionId + "').prevItem('item1')"));
  138
+        assertEquals(result, "null", "Result of function prevItem('item1')");
  139
+
  140
+        accordionAttributes.set(AccordionAttributes.cycledSwitching, true);
  141
+
  142
+        // RichFaces.$('form:accordion').nextItem('item5') will be item1
  143
+        result = selenium.getEval(new JavaScript("window.RichFaces.$('" + accordionId + "').nextItem('item5')"));
  144
+        assertEquals(result, "item1", "Result of function nextItem('item5')");
  145
+
  146
+        // RichFaces.$('form:accordion').prevItem('item1') will be item5
  147
+        result = selenium.getEval(new JavaScript("window.RichFaces.$('" + accordionId + "').prevItem('item1')"));
  148
+        assertEquals(result, "item5", "Result of function prevItem('item1')");
  149
+    }
  150
+
  151
+    @Test( groups = {"screenshot"} )
  152
+    public void testHeight() {
  153
+        AttributeLocator<?> attribute = accordion.getAttribute(new Attribute("style"));
  154
+
  155
+        // height = null
  156
+        assertFalse(selenium.isAttributePresent(attribute), "Attribute style should not be present.");
  157
+
  158
+        // height = 300px
  159
+        accordionAttributes.set(AccordionAttributes.height, "300px");
  160
+
  161
+        assertTrue(selenium.isAttributePresent(attribute), "Attribute style should be present.");
  162
+        String value = selenium.getStyle(accordion, CssProperty.HEIGHT);
  163
+        assertEquals(value, "300px", "Attribute width");
  164
+    }
  165
+
  166
+    @RegressionTest("https://issues.jboss.org/browse/RF-10352")
  167
+    public void testItemActiveLeftIcon() {
  168
+        JQueryLocator icon = leftIcon.format(1).getDescendant(jq("div.rf-ac-itm-ico-act"));
  169
+        JQueryLocator input = pjq("select[id$=itemActiveLeftIconInput]");
  170
+        JQueryLocator image = leftIcon.format(1).getChild(jq("img"));
  171
+
  172
+        // icon=null
  173
+        for (int i = 1; i < 6; i++) {
  174
+            assertFalse(selenium.isElementPresent(leftIcon.format(i)), "Left icon of item" + i
  175
+                + " should not be present on the page.");
  176
+        }
  177
+
  178
+        verifyStandardIcons(input, icon, image, "");
  179
+    }
  180
+
  181
+    @Test( groups = {"screenshot"} )
  182
+    public void testItemActiveRightIcon() {
  183
+        JQueryLocator icon = rightIcon.format(1).getDescendant(jq("div.rf-ac-itm-ico-act"));
  184
+        JQueryLocator input = pjq("select[id$=itemActiveRightIconInput]");
  185
+        JQueryLocator image = rightIcon.format(1).getChild(jq("img"));
  186
+
  187
+        // icon=null
  188
+        for (int i = 1; i < 6; i++) {
  189
+            assertFalse(selenium.isElementPresent(rightIcon.format(i)), "Right icon of item" + i
  190
+                + " should not be present on the page.");
  191
+        }
  192
+
  193
+        verifyStandardIcons(input, icon, image, "");
  194
+    }
  195
+
  196
+    @Test( groups = {"screenshot"} )
  197
+    public void testItemDisabledLeftIcon() {
  198
+        JQueryLocator icon = leftIcon.format(4).getDescendant(jq("div.rf-ac-itm-ico-inact"));
  199
+        JQueryLocator input = pjq("select[id$=itemDisabledLeftIconInput]");
  200
+        JQueryLocator image = leftIcon.format(4).getChild(jq("img"));
  201
+
  202
+        verifyStandardIcons(input, icon, image, "-dis");
  203
+    }
  204
+
  205
+    @Test( groups = {"screenshot"} )
  206
+    public void testItemDisabledRightIcon() {
  207
+        JQueryLocator icon = rightIcon.format(4).getDescendant(jq("div.rf-ac-itm-ico-inact"));
  208
+        JQueryLocator input = pjq("select[id$=itemDisabledRightIconInput]");
  209
+        JQueryLocator image = rightIcon.format(4).getChild(jq("img"));
  210
+
  211
+        verifyStandardIcons(input, icon, image, "-dis");
  212
+    }
  213
+
  214
+    @Test( groups = {"screenshot"} )
  215
+    @IssueTracking("https://issues.jboss.org/browse/RF-10352")
  216
+    public void testItemInactiveLeftIcon() {
  217
+        JQueryLocator icon = leftIcon.format(3).getDescendant(jq("div.rf-ac-itm-ico-inact"));
  218
+        JQueryLocator input = pjq("select[id$=itemInactiveLeftIconInput]");
  219
+        JQueryLocator image = leftIcon.format(3).getChild(jq("img"));
  220
+
  221
+        verifyStandardIcons(input, icon, image, "");
  222
+    }
  223
+
  224
+    @Test( groups = {"screenshot"} )
  225
+    public void testItemInactiveRightIcon() {
  226
+        JQueryLocator icon = rightIcon.format(3).getDescendant(jq("div.rf-ac-itm-ico-inact"));
  227
+        JQueryLocator input = pjq("select[id$=itemInactiveRightIconInput]");
  228
+        JQueryLocator image = rightIcon.format(3).getChild(jq("img"));
  229
+
  230
+        verifyStandardIcons(input, icon, image, "");
  231
+    }
  232
+
  233
+    @Test
  234
+    public void testItemchangeEvents() {
  235
+        accordionAttributes.set(AccordionAttributes.onbeforeitemchange, "metamerEvents += \"beforeitemchange \"");
  236
+        accordionAttributes.set(AccordionAttributes.onitemchange, "metamerEvents += \"itemchange \"");
  237
+
  238
+        selenium.getEval(new JavaScript("window.metamerEvents = \"\";"));
  239
+        String time1Value = selenium.getText(time);
  240
+
  241
+        guardXhr(selenium).click(itemHeaders[2]);
  242
+        waitGui.failWith("Page was not updated").waitForChange(time1Value, retrieveText.locator(time));
  243
+
  244
+        String[] events = selenium.getEval(new JavaScript("window.metamerEvents")).split(" ");
  245
+
  246
+        assertEquals(events[0], "beforeitemchange", "Attribute onbeforeitemchange doesn't work");
  247
+        assertEquals(events[1], "itemchange", "Attribute onbeforeitemchange doesn't work");
  248
+    }
  249
+
  250
+    @Test( groups = {"screenshot"} )
  251
+    public void testSwitchTypeNull() {
  252
+        for (int i = 2; i >= 0; i--) {
  253
+            final int index = i;
  254
+            guardXhr(selenium).click(itemHeaders[index]);
  255
+            waitGui.failWith("Item " + index + " is not displayed.").until(elementVisible.locator(itemContents[index]));
  256
+        }
  257
+    }
  258
+
  259
+    @Test( groups = {"screenshot"} )
  260
+    public void testSwitchTypeAjax() {
  261
+        accordionAttributes.set(AccordionAttributes.switchType, "ajax");
  262
+
  263
+        testSwitchTypeNull();
  264
+    }
  265
+
  266
+    @Test( groups = {"screenshot"} )
  267
+    public void testSwitchTypeClient() {
  268
+        accordionAttributes.set(AccordionAttributes.switchType, "client");
  269
+
  270
+        for (int i = 2; i >= 0; i--) {
  271
+            final int index = i;
  272
+            guardNoRequest(selenium).click(itemHeaders[index]);
  273
+            waitGui.failWith("Item " + index + " is not displayed.").until(elementVisible.locator(itemContents[index]));
  274
+        }
  275
+    }
  276
+
  277
+    @Test( groups = {"screenshot"} )
  278
+    @RegressionTest("https://issues.jboss.org/browse/RF-10040")
  279
+    public void testSwitchTypeServer() {
  280
+        accordionAttributes.set(AccordionAttributes.switchType, "server");
  281
+
  282
+        for (int i = 2; i >= 0; i--) {
  283
+            final int index = i;
  284
+            guardHttp(selenium).click(itemHeaders[index]);
  285
+            waitGui.failWith("Item " + index + " is not displayed.").until(elementVisible.locator(itemContents[index]));
  286
+        }
  287
+    }
  288
+
  289
+    @Test( groups = {"screenshot"} )
  290
+    public void testWidth() {
  291
+        AttributeLocator<?> attribute = accordion.getAttribute(new Attribute("style"));
  292
+
  293
+        // width = null
  294
+        assertFalse(selenium.isAttributePresent(attribute), "Attribute style should not be present.");
  295
+
  296
+        // width = 50%
  297
+        accordionAttributes.set(AccordionAttributes.width, "356px");
  298
+
  299
+        assertTrue(selenium.isAttributePresent(attribute), "Attribute style should be present.");
  300
+        String value = selenium.getStyle(accordion, CssProperty.WIDTH);
  301
+        assertEquals(value, "356px", "Attribute width");
  302
+    }
  303
+
  304
+    private void verifyStandardIcons(JQueryLocator input, JQueryLocator icon, JQueryLocator image, String classSuffix) {
  305
+        IconsChecker checker = new IconsChecker(selenium, "rf-ico-", "-hdr");
  306
+        checker.checkCssImageIcons(input, icon, classSuffix);
  307
+        checker.checkCssNoImageIcons(input, icon, classSuffix);
  308
+        checker.checkImageIcons(input, icon, image, classSuffix);
  309
+        checker.checkNone(input, icon, classSuffix);
  310
+    }
  311
+}
211  metamer/ftest/src/test/java/org/richfaces/tests/metamer/ftest/richAutocomplete/TestAutocompleteVisual.java
... ...
@@ -0,0 +1,211 @@
  1
+/*******************************************************************************
  2
+ * JBoss, Home of Professional Open Source
  3
+ * Copyright 2010-2012, Red Hat, Inc. and individual contributors
  4
+ * by the @authors tag. See the copyright.txt in the distribution for a
  5
+ * full listing of individual contributors.
  6
+ *
  7
+ * This is free software; you can redistribute it and/or modify it
  8
+ * under the terms of the GNU Lesser General Public License as
  9
+ * published by the Free Software Foundation; either version 2.1 of
  10
+ * the License, or (at your option) any later version.
  11
+ *
  12
+ * This software is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this software; if not, write to the Free
  19
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21
+ *******************************************************************************/
  22
+package org.richfaces.tests.metamer.ftest.richAutocomplete;
  23
+
  24
+import static org.jboss.arquillian.ajocado.utils.URLUtils.buildUrl;
  25
+import static org.jboss.test.selenium.RequestTypeModelGuard.guardXhr;
  26
+import static org.richfaces.tests.metamer.ftest.attributes.AttributeList.autocompleteAttributes;
  27
+import static org.testng.Assert.assertEquals;
  28
+import static org.testng.Assert.assertFalse;
  29
+import static org.testng.Assert.assertTrue;
  30
+
  31
+import java.net.URL;
  32
+import java.util.LinkedList;
  33
+import java.util.List;
  34
+
  35
+import org.jboss.arquillian.ajocado.locator.JQueryLocator;
  36
+import org.richfaces.tests.metamer.bean.Model;
  37
+import org.richfaces.tests.metamer.ftest.AbstractGrapheneTest;
  38
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
  39
+import org.richfaces.tests.metamer.ftest.annotations.Use;
  40
+import org.richfaces.tests.metamer.ftest.model.Autocomplete;
  41
+import org.richfaces.tests.metamer.model.Capital;
  42
+import org.testng.annotations.BeforeMethod;
  43
+import org.testng.annotations.Test;
  44
+
  45
+
  46
+/**
  47
+ * Test for example with formatted suggestions on page faces/components/richAutocomplete/autocomplete.xhtml
  48
+ *
  49
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
  50
+ *
  51
+ * @version $Revision$
  52
+ */
  53
+public class TestAutocompleteVisual extends AbstractGrapheneTest {
  54
+
  55
+    Autocomplete autocomplete = new Autocomplete();
  56
+    StringBuilder partialInput;
  57
+
  58
+    List<Capital> capitals = Model.unmarshallCapitals();
  59
+
  60
+    @Inject
  61
+    @Use(booleans = { true, false })
  62
+    Boolean autofill;
  63
+
  64
+    @Inject
  65
+    @Use(booleans = { true, false })
  66
+    Boolean selectFirst;
  67
+
  68
+    @Override
  69
+    public URL getTestUrl() {
  70
+        return buildUrl(contextPath, "faces/components/richAutocomplete/fetchValueAttr.xhtml");
  71
+    }
  72
+
  73
+    @BeforeMethod( groups={"arquillian"} )
  74
+    public void prepareProperties() {
  75
+        autocompleteAttributes.set(AutocompleteAttributes.autofill, autofill);
  76
+        autocompleteAttributes.set(AutocompleteAttributes.selectFirst, selectFirst);
  77
+        if (autofill == null) {
  78
+            autofill = false;
  79
+        }
  80
+        if (selectFirst == null) {
  81
+            selectFirst = false;
  82
+        }
  83
+        autocomplete.clearInputValue();
  84
+    }
  85
+
  86
+    /**
  87
+     * This should test combination of @var and @fetchValue attributes of autocomplete
  88
+     */
  89
+    @Test( groups={"screenshot"} )
  90
+    public void testFormatting() {
  91
+        assertFalse(autocomplete.isCompletionVisible());
  92
+        autocomplete.clearInputValue();
  93
+        typePrefix("ala");
  94
+        assertTrue(autocomplete.isCompletionVisible());
  95
+        confirm();
  96
+        assertFalse(autocomplete.isCompletionVisible());
  97
+        assertTrue(autocomplete.getInputText().toLowerCase().startsWith(getExpectedStateForPrefix().toLowerCase()));
  98
+    }
  99
+
  100
+    @Test( groups={"screenshot"} )
  101
+    public void testLayout() {
  102
+
  103
+        JQueryLocator suggestionsGridDiv = new JQueryLocator("div.rf-au-lst-scrl > div[id$=autocompleteItems] > div:contains({0})");
  104
+        JQueryLocator suggestionsList = new JQueryLocator("div.rf-au-lst-scrl > ul[id$=autocompleteItems] > li:contains({0})");
  105
+        JQueryLocator suggestionsTable = new JQueryLocator("div.rf-au-lst-scrl > table[id$=autocompleteItems] tr>td:contains({0})");
  106
+
  107
+        verifyLayout("div", suggestionsGridDiv);
  108
+
  109
+//        verifyLayout("grid", suggestionsGridDiv);
  110
+
  111
+        verifyLayout("list", suggestionsList);
  112
+
  113
+        verifyLayout("table", suggestionsTable);
  114
+
  115
+    }
  116
+
  117
+    private void verifyLayout(String layout, JQueryLocator suggestionLocatorFormat) {
  118
+
  119
+        autocompleteAttributes.set(AutocompleteAttributes.layout, layout);
  120
+
  121
+        autocomplete.clearInputValue();
  122
+        autocomplete.typeKeys("Co");
  123
+        waitFor(2000);
  124
+
  125
+        assertTrue(selenium.isElementPresent(suggestionLocatorFormat.format("Colorado")));
  126
+        assertTrue(selenium.isElementPresent(suggestionLocatorFormat.format("[Denver]")));
  127
+
  128
+        assertTrue(selenium.isElementPresent(suggestionLocatorFormat.format("Connecticut")));
  129
+        assertTrue(selenium.isElementPresent(suggestionLocatorFormat.format("[Hartford]")));
  130
+    }
  131
+
  132
+    public void typePrefix(String wholeInput) {
  133
+        partialInput = new StringBuilder(autocomplete.getInputText());
  134
+
  135
+        for (int i = 0; i < wholeInput.length(); i++) {
  136
+            String chr = String.valueOf(wholeInput.charAt(i));
  137
+
  138
+            guardXhr(autocomplete).typeKeys(chr);
  139
+            partialInput.append(chr);
  140
+
  141
+            assertEquals(autocomplete.getInputText(), getExpectedStateForPrefix());
  142
+            assertEquals(autocomplete.getSelectedOptionIndex(), getExpectedSelectedOptionIndex());
  143
+        }
  144
+    }
  145
+
  146
+    public String getExpectedStateForPrefix() {
  147
+        if (selectFirst && autofill && partialInput.length() > 0) {
  148
+            return getStatesByPrefix(partialInput.toString()).get(0).toLowerCase();
  149
+        }
  150
+
  151
+        return partialInput.toString();
  152
+    }
  153
+
  154
+    public String getExpectedCompletionForPrefix() {
  155
+        if (selectFirst && autofill && partialInput.length() > 0) {
  156
+            return getCompletionByPrefix(partialInput.toString()).get(0).toLowerCase();
  157
+        }
  158
+
  159
+        return partialInput.toString();
  160
+    }
  161
+
  162
+    public List<String> getStatesByPrefix(String prefix) {
  163
+        List<String> states = new LinkedList<String>();
  164
+
  165
+        for (Capital cap : capitals) {
  166
+            if (cap.getState().toLowerCase().startsWith(prefix)) {
  167
+                states.add(cap.getState());
  168
+            }
  169
+        }
  170
+
  171
+        return states;
  172
+    }
  173
+
  174
+    public List<String> getCompletionByPrefix(String prefix) {
  175
+        List<String> states = new LinkedList<String>();
  176
+
  177
+        for (Capital cap : capitals) {
  178
+            if (cap.getState().toLowerCase().startsWith(prefix)) {
  179
+                states.add(cap.getState() + " [" + cap.getName() + "]");
  180
+            }
  181
+        }
  182
+
  183
+        return states;
  184
+    }
  185
+
  186
+    public int getExpectedSelectedOptionIndex() {
  187
+        return (selectFirst && partialInput.length() > 0) ? 0 : -1;
  188
+    }
  189
+
  190
+    public void confirm() {
  191
+        autocomplete.confirmByKeys();
  192
+        autocomplete.waitForCompletionVisible();
  193
+    }
  194
+
  195
+    public Boolean getAutofill() {
  196
+        return autofill;
  197
+    }
  198
+
  199
+    public void setAutofill(Boolean autofill) {
  200
+        this.autofill = autofill;
  201
+    }
  202
+
  203
+    public Boolean getSelectFirst() {
  204
+        return selectFirst;
  205
+    }
  206
+
  207
+    public void setSelectFirst(Boolean selectFirst) {
  208
+        this.selectFirst = selectFirst;
  209
+    }
  210
+}
  211
+
268  metamer/ftest/src/test/java/org/richfaces/tests/metamer/ftest/richCalendar/TestRichCalendarVisual.java
... ...
@@ -0,0 +1,268 @@
  1
+/*******************************************************************************
  2
+ * JBoss, Home of Professional Open Source
  3
+ * Copyright 2010-2012, Red Hat, Inc. and individual contributors
  4
+ * by the @authors tag. See the copyright.txt in the distribution for a
  5
+ * full listing of individual contributors.
  6
+ *
  7
+ * This is free software; you can redistribute it and/or modify it
  8
+ * under the terms of the GNU Lesser General Public License as
  9
+ * published by the Free Software Foundation; either version 2.1 of
  10
+ * the License, or (at your option) any later version.
  11
+ *
  12
+ * This software is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this software; if not, write to the Free
  19
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21
+ *******************************************************************************/
  22
+package org.richfaces.tests.metamer.ftest.richCalendar;
  23
+
  24
+import static org.jboss.arquillian.ajocado.Graphene.guardNoRequest;
  25
+
  26
+import static org.jboss.arquillian.ajocado.utils.URLUtils.buildUrl;
  27
+
  28
+import static org.testng.Assert.assertEquals;
  29
+import static org.testng.Assert.assertFalse;
  30
+import static org.testng.Assert.assertTrue;
  31
+import static org.testng.Assert.fail;
  32
+
  33
+import java.net.URL;
  34
+import java.text.ParseException;
  35
+import java.text.SimpleDateFormat;
  36
+import java.util.Date;
  37
+
  38
+import org.testng.annotations.Test;
  39
+
  40
+
  41
+/**
  42
+ * Test case for basic functionality of calendar on page faces/components/richCalendar/simple.xhtml.
  43
+ *
  44
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
  45
+ * @version $Revision: 21887 $
  46
+ */
  47
+public class TestRichCalendarVisual extends AbstractCalendarTest {
  48
+
  49
+    @Override
  50
+    public URL getTestUrl() {
  51
+        return buildUrl(contextPath, "faces/components/richCalendar/simple.xhtml");
  52
+    }
  53
+
  54
+    @Test( groups={"screenshot"} )
  55
+    public void testInit() {
  56
+        boolean displayed = selenium.isVisible(calendar);
  57
+        assertTrue(displayed, "Calendar is not present on the page.");
  58
+
  59
+        displayed = selenium.isVisible(input);
  60
+        assertTrue(displayed, "Calendar's input should be visible.");
  61
+
  62
+        displayed = selenium.isVisible(image);
  63
+        assertTrue(displayed, "Calendar's image should be visible.");
  64
+
  65
+        displayed = selenium.isVisible(popup);
  66
+        assertFalse(displayed, "Popup should not be visible.");
  67
+
  68
+        displayed = selenium.isElementPresent(button);
  69
+        assertFalse(displayed, "Calendar's button should not be visible.");
  70
+    }
  71
+
  72
+    @Test( groups={"screenshot"} )
  73
+    @Override
  74
+    public void testOpenPopupClickOnInput() {
  75
+        super.testOpenPopupClickOnInput();
  76
+    }
  77
+
  78
+    @Test( groups={"screenshot"} )
  79
+    @Override
  80
+    public void testOpenPopupClickOnImage() {
  81
+        super.testOpenPopupClickOnImage();
  82
+    }
  83
+
  84
+    @Test( groups={"screenshot"} )
  85
+    @Override
  86
+    public void testHeaderButtons() {
  87
+        super.testHeaderButtons();
  88
+    }
  89
+
  90
+    @Test( groups={"screenshot"} )
  91
+    public void testHeaderMonth() {
  92
+        String month = new SimpleDateFormat("MMMM, yyyy").format(new Date());
  93
+
  94
+        selenium.click(input);
  95
+        String month2 = selenium.getText(monthLabel);
  96
+        assertEquals(month2, month, "Calendar shows wrong month or year in its header.");
  97
+    }
  98
+
  99
+    @Test( groups={"screenshot"} )
  100
+    @Override
  101
+    public void testFooterButtons() {
  102
+        super.testFooterButtons();
  103
+    }
  104
+
  105
+    @Test( groups={"screenshot"} )
  106
+    public void testWeekDaysLabels() {
  107
+        selenium.click(input);
  108
+
  109
+        String[] labels = {"", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  110
+
  111
+        for (int i = 0; i < 8; i++) {
  112
+            String label = selenium.getText(weekDayLabel.format(i));
  113
+            assertEquals(label, labels[i], "Week day label " + i);
  114
+        }
  115
+    }
  116
+
  117
+    @Test( groups={"screenshot"} )
  118
+    public void testTodayIsSelected() {
  119
+        SimpleDateFormat formatter = new SimpleDateFormat("d");
  120
+        String today = formatter.format(new Date());
  121
+
  122
+        int lowerBoundary = 0;
  123
+        int upperBoundary = 42;
  124
+
  125
+        // go through first half of popup or second half of popup depending on today's date
  126
+        // it is necessary because of dates from other months are also displayed
  127
+        if (Integer.parseInt(today) < 15) {
  128
+            upperBoundary = 28;
  129
+        } else {
  130
+            lowerBoundary = 14;
  131
+        }
  132
+
  133
+        selenium.click(input);
  134
+
  135
+        for (int i = lowerBoundary; i < upperBoundary; i++) {
  136
+            String day = selenium.getText(cellDay.format(i));
  137
+            if (day.equals(today)) {
  138
+                assertTrue(selenium.belongsClass(cellDay.format(i), "rf-cal-today"), "Today's date is not styled correctly.");
  139
+                return;
  140
+            }
  141
+        }
  142
+
  143
+        fail("Today's date is not styled correctly.");
  144
+    }
  145
+
  146
+    @Test( groups={"screenshot"} )
  147
+    public void testWeekNumbers() {
  148
+        selenium.click(input);
  149
+        String month = selenium.getText(monthLabel);
  150
+        String day = selenium.getText(cellDay.format(6));
  151
+
  152
+        Date date = null;
  153
+        try {
  154
+            date = new SimpleDateFormat("d MMMM, yyyy").parse(day + " " + month);
  155
+        } catch (ParseException ex) {
  156
+            fail(ex.getMessage());
  157
+        }
  158
+        String weekNumber = new SimpleDateFormat("w").format(date);
  159
+
  160
+        assertEquals(selenium.getText(week.format(0)), weekNumber, "Week number on the first line.");
  161
+    }
  162
+
  163
+    @Test( groups={"screenshot"} )
  164
+    public void testSelectDate() {
  165
+        selenium.click(input);
  166
+
  167
+        guardNoRequest(selenium).click(cellDay.format(6));
  168
+        assertTrue(selenium.belongsClass(cellDay.format(6), "rf-cal-sel"), "Last date in the first week is not selected.");
  169
+
  170
+        selenium.click(cellDay.format(8));
  171
+        assertFalse(selenium.belongsClass(cellDay.format(6), "rf-cal-sel"), "Last date in the first week should not be selected.");
  172
+    }
  173
+
  174
+    @Test( groups={"screenshot"} )
  175
+    public void testCleanButton() {
  176
+        selenium.click(input);
  177
+        selenium.click(cellDay.format(6));
  178
+
  179
+        guardNoRequest(selenium).click(cleanButton);
  180
+        assertFalse(selenium.belongsClass(cellDay.format(6), "rf-cal-sel"), "Last date in the first week should not be selected.");
  181
+    }
  182
+
  183
+    @Test( groups={"screenshot"} )
  184
+    public void testCloseButton() {
  185
+        selenium.click(input);
  186
+        boolean displayed = selenium.isVisible(popup);
  187
+        assertTrue(displayed, "Popup should be visible.");
  188
+
  189
+        guardNoRequest(selenium).click(closeButton);
  190
+        displayed = selenium.isVisible(popup);
  191
+        assertFalse(displayed, "Popup should not be visible.");
  192
+    }
  193
+
  194
+    @Test( groups={"screenshot"} )
  195
+    public void testPrevYearButton() {
  196
+        selenium.click(input);
  197
+        String thisYear = selenium.getText(monthLabel);
  198
+        // November, 2010 -> 2010
  199
+        thisYear = thisYear.substring(thisYear.indexOf(" ") + 1, thisYear.length());
  200
+
  201
+        guardNoRequest(selenium).click(prevYearButton);
  202
+        String prevYear = selenium.getText(monthLabel);
  203
+        prevYear = prevYear.substring(prevYear.indexOf(" ") + 1, prevYear.length());
  204
+
  205
+        assertEquals(Integer.parseInt(prevYear), Integer.parseInt(thisYear) - 1, "Year did not change correctly.");
  206
+    }
  207
+
  208
+    @Test( groups={"screenshot"} )
  209
+    public void testNextYearButton() {
  210
+        selenium.click(input);
  211
+        String thisYear = selenium.getText(monthLabel);
  212
+        // November, 2010 -> 2010
  213
+        thisYear = thisYear.substring(thisYear.indexOf(" ") + 1, thisYear.length());
  214
+
  215
+        guardNoRequest(selenium).click(nextYearButton);
  216
+        String nextYear = selenium.getText(monthLabel);
  217
+        nextYear = nextYear.substring(nextYear.indexOf(" ") + 1, nextYear.length());
  218
+
  219
+        assertEquals(Integer.parseInt(nextYear), Integer.parseInt(thisYear) + 1, "Year did not change correctly.");
  220
+    }
  221
+
  222
+    @Test( groups={"screenshot"} )
  223
+    public void testPrevMonthButton() {
  224
+        selenium.click(input);
  225
+        String thisMonth = selenium.getText(monthLabel);
  226
+        // November, 2010 -> November
  227
+        thisMonth = thisMonth.substring(0, thisMonth.indexOf(","));
  228
+
  229
+        guardNoRequest(selenium).click(prevMonthButton);
  230
+        String prevMonth = selenium.getText(monthLabel);
  231
+        prevMonth = prevMonth.substring(0, prevMonth.indexOf(","));
  232
+
  233
+        assertEquals(Month.valueOf(prevMonth), Month.valueOf(thisMonth).previous(), "Month did not change correctly.");
  234
+    }
  235
+
  236
+    @Test( groups={"screenshot"} )
  237
+    public void testNextMonthButton() {
  238
+        selenium.click(input);
  239
+        String thisMonth = selenium.getText(monthLabel);
  240
+        // November, 2010 -> November
  241
+        thisMonth = thisMonth.substring(0, thisMonth.indexOf(","));
  242
+
  243
+        guardNoRequest(selenium).click(nextMonthButton);
  244
+        String nextMonth = selenium.getText(monthLabel);
  245
+        nextMonth = nextMonth.substring(0, nextMonth.indexOf(","));
  246
+
  247
+        assertEquals(Month.valueOf(nextMonth), Month.valueOf(thisMonth).next(), "Month did not change correctly.");
  248
+    }
  249
+
  250
+    @Test( groups={"screenshot"} )
  251
+    public void testTodayButton() {
  252
+        selenium.click(input);
  253
+        String thisMonth = selenium.getText(monthLabel);
  254
+
  255
+        selenium.click(nextMonthButton);
  256
+        selenium.click(prevYearButton);
  257
+        guardNoRequest(selenium).click(todayButton);
  258
+        String thisMonth2 = selenium.getText(monthLabel);
  259
+
  260
+        assertEquals(thisMonth2, thisMonth, "Today button does not work.");
  261
+    }
  262
+
  263
+    @Test( groups={"screenshot"} )
  264
+    @Override
  265
+    public void testApplyButton() {
  266
+        super.testApplyButton();
  267
+    }
  268
+}
146  ...mer/ftest/src/test/java/org/richfaces/tests/metamer/ftest/richDragIndicator/TestDragIndicatorVisual.java
... ...
@@ -0,0 +1,146 @@
  1
+/*******************************************************************************
  2
+ * JBoss, Home of Professional Open Source
  3
+ * Copyright 2010-2012, Red Hat, Inc. and individual contributors
  4
+ * by the @authors tag. See the copyright.txt in the distribution for a
  5
+ * full listing of individual contributors.
  6
+ *
  7
+ * This is free software; you can redistribute it and/or modify it
  8
+ * under the terms of the GNU Lesser General Public License as
  9
+ * published by the Free Software Foundation; either version 2.1 of
  10
+ * the License, or (at your option) any later version.
  11
+ *
  12
+ * This software is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this software; if not, write to the Free
  19
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21
+ *******************************************************************************/
  22
+package org.richfaces.tests.metamer.ftest.richDragIndicator;
  23
+
  24
+import static org.jboss.arquillian.ajocado.Graphene.waitModel;
  25
+import static org.jboss.arquillian.ajocado.utils.URLUtils.buildUrl;
  26
+import static org.richfaces.tests.metamer.ftest.attributes.AttributeList.dragIndicatorAttributes;
  27
+import static org.richfaces.tests.metamer.ftest.richDragIndicator.DragIndicatorAttributes.acceptClass;
  28
+import static org.richfaces.tests.metamer.ftest.richDragIndicator.DragIndicatorAttributes.draggingClass;
  29
+import static org.richfaces.tests.metamer.ftest.richDragIndicator.DragIndicatorAttributes.rejectClass;
  30
+import static org.richfaces.tests.metamer.ftest.richDragIndicator.DragIndicatorAttributes.rendered;
  31
+import static org.testng.Assert.assertEquals;
  32
+import static org.testng.Assert.assertFalse;
  33
+
  34
+import java.net.URL;
  35
+
  36
+import org.jboss.arquillian.ajocado.actions.Drag;
  37
+import org.jboss.arquillian.ajocado.request.RequestType;
  38
+import org.richfaces.tests.metamer.ftest.richDragIndicator.Indicator.IndicatorState;
  39
+import org.testng.annotations.BeforeMethod;
  40
+import org.testng.annotations.Test;
  41
+
  42
+
  43
+/**
  44
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
  45
+ * @version $Revision:  $
  46
+ */
  47
+public class TestDragIndicatorVisual extends AbstractDragNDropTest {
  48
+
  49
+    private static final String ACCEPT_CLASS = "sample-accept-class";
  50
+    private static final String REJECT_CLASS = "sample-reject-class";
  51
+    private static final String DRAGGING_CLASS = "sample-dragging-class";
  52
+
  53
+    @Override
  54
+    public URL getTestUrl() {
  55
+        return buildUrl(contextPath, "faces/components/richDragIndicator/simple.xhtml");
  56
+    }
  57
+
  58
+    @BeforeMethod(groups={"arquillian"})
  59
+    public void setup() {
  60
+        super.setupIndicator();
  61
+
  62
+        dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS);
  63
+        dragIndicatorAttributes.set(acceptClass, ACCEPT_CLASS);
  64
+        dragIndicatorAttributes.set(rejectClass, REJECT_CLASS);
  65
+        indicator.setDraggingClass(DRAGGING_CLASS);
  66
+        indicator.setAcceptClass(ACCEPT_CLASS);
  67
+        indicator.setRejectClass(REJECT_CLASS);
  68
+    }
  69
+
  70
+    @Test( groups = {"screenshot"} )
  71
+    public void testRendered() {
  72
+        System.out.println(" ### testRendered... ");
  73
+        dragIndicatorAttributes.set(rendered, false);
  74
+        selenium.getPageExtensions().install();
  75
+        selenium.getRequestGuard().clearRequestDone();
  76
+
  77
+        drag = new Drag(drg1, drop1);
  78
+        drag.setDragIndicator(indicator);
  79
+        drag.start();
  80
+        assertFalse(selenium.isElementPresent(indicator));
  81
+        drag.enter();
  82
+        assertFalse(selenium.isElementPresent(indicator));
  83
+
  84
+        drag.drop();
  85
+
  86
+        waitModel.timeout(5000).waitForTimeout();
  87
+        assertEquals(selenium.getRequestGuard().getRequestDone(), RequestType.NONE);
  88
+    }
  89
+
  90
+    @Test( groups = {"screenshot"} )
  91
+    public void testDragging() {
  92
+        drag = new Drag(drg1, drg2);
  93
+        drag.setDragIndicator(indicator);
  94
+        indicator.verifyState(IndicatorState.HIDDEN);
  95
+
  96
+        drag.start();
  97
+        indicator.verifyState(IndicatorState.DRAGGING);
  98
+
  99
+        drag.mouseOut();
  100
+        indicator.verifyState(IndicatorState.DRAGGING);
  101
+
  102
+        drag.enter();
  103
+        indicator.verifyState(IndicatorState.DRAGGING);
  104
+    }
  105
+
  106
+    @Test( groups = {"screenshot"} )
  107
+    public void testAccepting() {
  108
+        drag = new Drag(drg1, drop1);
  109
+        drag.setDragIndicator(indicator);
  110
+        indicator.verifyState(IndicatorState.HIDDEN);
  111
+
  112
+        drag.start();
  113
+        indicator.verifyState(IndicatorState.DRAGGING);
  114
+
  115
+        drag.mouseOut();