diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-03-05 13:28:51 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-04-16 10:16:36 +0000 |
commit | 522c3dd8f3b64e772f7e41205308fc24a56426f4 (patch) | |
tree | 54b2f1fff6e253674c377120718a7c4ef6b1198d /uitest/src/com/vaadin/tests/fields | |
parent | ab8a0268652b81b20be8d5dbf0deeb7029e9edec (diff) | |
download | vaadin-framework-522c3dd8f3b64e772f7e41205308fc24a56426f4.tar.gz vaadin-framework-522c3dd8f3b64e772f7e41205308fc24a56426f4.zip |
Convert some TB2 tests to TB4
- components/ui/CurrentUiRetainedTest
- components/ui/InitiallyEmptyFragmentTest
- components/ui/PollListeningTest
- components/ui/RpcInvocationHandlerToStringTest
- components/ui/UIAccessExceptionHandlingTest
- components/ui/UIInitBrowserDetailsTest
- components/ui/UIInitExceptionTest
- components/ui/UIPollingTest
- components/ui/UITabIndexTest
- components/ui/UIsInMultipleTabsTest
- components/window/CloseSubWindowTest
- components/window/ExtraWindowShownTest
- components/window/RepaintWindowContentsTest
- components/window/WindowShouldRemoveActionHandlerTest
- components/window/WindowWithInvalidCloseListenerTest
- containers/sqlcontainer/TableQueryWithNonUniqueFirstPrimaryKeyTest
- converter/ConverterThatEnforcesAFormatTest
- dd/DnDOnSubtreeTest
- fieldgroup/BasicPersonFormTest
- fieldgroup/CommitHandlerFailuresTest
- fieldgroup/CommitWithValidationOrConversionErrorTest
- fieldgroup/DateFormTest
- fieldgroup/FieldGroupDiscardTest
- fields/TabIndexesTest
renamed:
- components/ui/PollListenerTest -> PollListening
Change-Id: Iac3c153709f6edca28d9f75a85246f1a70176963
Diffstat (limited to 'uitest/src/com/vaadin/tests/fields')
-rw-r--r-- | uitest/src/com/vaadin/tests/fields/TabIndexes.java | 19 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/fields/TabIndexesTest.java | 164 |
2 files changed, 172 insertions, 11 deletions
diff --git a/uitest/src/com/vaadin/tests/fields/TabIndexes.java b/uitest/src/com/vaadin/tests/fields/TabIndexes.java index cf2e253d08..32fb36815b 100644 --- a/uitest/src/com/vaadin/tests/fields/TabIndexes.java +++ b/uitest/src/com/vaadin/tests/fields/TabIndexes.java @@ -4,8 +4,7 @@ import java.util.ArrayList; import java.util.List; import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.tests.util.Log; +import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.AbstractField; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -30,14 +29,13 @@ import com.vaadin.ui.Tree; import com.vaadin.ui.TreeTable; import com.vaadin.ui.TwinColSelect; -public class TabIndexes extends AbstractTestUI { +@SuppressWarnings("rawtypes") +public class TabIndexes extends AbstractTestUIWithLog { private List<AbstractField> fields; - private Log log = new Log(5); @Override protected void setup(VaadinRequest request) { - addComponent(log); HorizontalLayout buttonLayout = new HorizontalLayout(); addComponent(buttonLayout); Button clearTabIndexes = new Button("Set all tab indexes to 0"); @@ -45,7 +43,7 @@ public class TabIndexes extends AbstractTestUI { @Override public void buttonClick(ClickEvent event) { - log.log("Setting tab indexes to 0"); + log("Setting tab indexes to 0"); for (AbstractField f : fields) { f.setTabIndex(0); } @@ -57,7 +55,7 @@ public class TabIndexes extends AbstractTestUI { @Override public void buttonClick(ClickEvent event) { - log.log("Setting tab indexes to 1"); + log("Setting tab indexes to 1"); for (AbstractField f : fields) { f.setTabIndex(1); } @@ -70,7 +68,7 @@ public class TabIndexes extends AbstractTestUI { @Override public void buttonClick(ClickEvent event) { int tabIndex = 1; - log.log("Setting tab indexes to 1..N"); + log("Setting tab indexes to 1..N"); for (AbstractField f : fields) { f.setTabIndex(tabIndex++); } @@ -84,7 +82,7 @@ public class TabIndexes extends AbstractTestUI { @Override public void buttonClick(ClickEvent event) { int tabIndex = fields.size(); - log.log("Setting tab indexes to N..1"); + log("Setting tab indexes to N..1"); for (AbstractField f : fields) { f.setTabIndex(tabIndex--); } @@ -153,8 +151,7 @@ public class TabIndexes extends AbstractTestUI { @Override protected String getTestDescription() { - // TODO Auto-generated method stub - return null; + return "Tab index should be propagated into html"; } } diff --git a/uitest/src/com/vaadin/tests/fields/TabIndexesTest.java b/uitest/src/com/vaadin/tests/fields/TabIndexesTest.java new file mode 100644 index 0000000000..6bd456c7e2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/fields/TabIndexesTest.java @@ -0,0 +1,164 @@ +package com.vaadin.tests.fields; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TabIndexesTest extends MultiBrowserTest { + + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + } + + @Test + public void testTabIndexesSetToZero() { + // clicked by default + assertLogText("1. Setting tab indexes to 0"); + for (WebElement element : getFieldElements()) { + assertTabIndex("0", element); + } + } + + @Test + public void testTabIndexesSetToOne() { + setTabIndexesTo("1"); + for (WebElement element : getFieldElements()) { + assertTabIndex("1", element); + } + } + + @Test + public void testTabIndexesSetToOneThroughN() { + setTabIndexesTo("1..N"); + int counter = 0; + for (WebElement element : getFieldElements()) { + ++counter; + assertTabIndex(String.valueOf(counter), element); + } + } + + @Test + public void testTabIndexesSetToNThroughOne() { + setTabIndexesTo("N..1"); + List<WebElement> fieldElements = getFieldElements(); + int counter = fieldElements.size(); + for (WebElement element : fieldElements) { + assertTabIndex(String.valueOf(counter), element); + --counter; + } + } + + private void setTabIndexesTo(String expected) { + String caption = String.format("Set %stab indexes to %s", + (expected.contains("N") ? "" : "all "), expected); + $(ButtonElement.class).caption(caption).first().click(); + assertLogText("2. Setting tab indexes to " + expected); + } + + private void assertLogText(String expected) { + Assert.assertEquals("Unexpected log contents,", expected, getLogRow(0)); + } + + private void assertTabIndex(String expected, WebElement element) { + Assert.assertEquals("Unexpected tab index,", expected, + element.getAttribute("tabIndex")); + } + + private List<WebElement> getFieldElements() { + List<WebElement> fieldElements = new ArrayList<WebElement>(); + fieldElements.add(getElement1()); + fieldElements.add(getElement2()); + fieldElements.add(getElement3()); + fieldElements.add(getElement4()); + fieldElements.add(getElement5()); + fieldElements.add(getElement6()); + fieldElements.add(getElement7()); + fieldElements.add(getElement8()); + fieldElements.add(getElement9()); + fieldElements.add(getElement10()); + fieldElements.add(getElement11()); + fieldElements.add(getElement12()); + fieldElements.add(getElement13()); + fieldElements.add(getElement14()); + fieldElements.add(getElement15()); + fieldElements.add(getElement16()); + fieldElements.add(getElement17()); + return fieldElements; + } + + private WebElement getElement1() { + return vaadinElement("PID_Sfield-1/domChild[1]/domChild[1]"); + } + + private WebElement getElement2() { + return vaadinElement("PID_Sfield-2/domChild[0]"); + } + + private WebElement getElement3() { + return vaadinElement("PID_Sfield-3/domChild[0]"); + } + + private WebElement getElement4() { + return vaadinElement("PID_Sfield-4/domChild[0]"); + } + + private WebElement getElement5() { + return vaadinElement("PID_Sfield-5"); + } + + private WebElement getElement6() { + return vaadinElement("PID_Sfield-6/domChild[0]"); + } + + private WebElement getElement7() { + return vaadinElement("PID_Sfield-7/domChild[0]"); + } + + private WebElement getElement8() { + return vaadinElement("PID_Sfield-8/domChild[0]/domChild[0]"); + } + + private WebElement getElement9() { + return vaadinElement("PID_Sfield-9/domChild[1]/domChild[1]"); + } + + private WebElement getElement10() { + return vaadinElement("PID_Sfield-10/domChild[1]"); + } + + private WebElement getElement11() { + return vaadinElement("PID_Sfield-11/domChild[1]"); + } + + private WebElement getElement12() { + return vaadinElement("PID_Sfield-12"); + } + + private WebElement getElement13() { + return vaadinElement("PID_Sfield-13"); + } + + private WebElement getElement14() { + return vaadinElement("PID_Sfield-14"); + } + + private WebElement getElement15() { + return vaadinElement("PID_Sfield-15/domChild[1]"); + } + + private WebElement getElement16() { + return vaadinElement("PID_Sfield-16/domChild[0]"); + } + + private WebElement getElement17() { + return vaadinElement("PID_Sfield-17"); + } +} |