summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnsku <Ansku@users.noreply.github.com>2017-11-10 16:50:27 +0200
committerPéter Török <31210544+torok-peter@users.noreply.github.com>2017-11-10 16:50:27 +0200
commitbcdd76c6a006a8d0f27f22c6078814ff2b4b09dc (patch)
tree117759e5ef9195ae9678ab5e33ca7be67d0b12fd /uitest
parent37bd6b1a32c9d5d6a53755de8bb1a94556b4471b (diff)
downloadvaadin-framework-bcdd76c6a006a8d0f27f22c6078814ff2b4b09dc.tar.gz
vaadin-framework-bcdd76c6a006a8d0f27f22c6078814ff2b4b09dc.zip
Fix setting custom tab index for TabSheet or Accordion (#9574) (#10278)
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java9
-rw-r--r--uitest/src/test/java/com/vaadin/tests/fields/TabIndexesTest.java23
2 files changed, 25 insertions, 7 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java b/uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java
index df93a43a37..179a512403 100644
--- a/uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java
+++ b/uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java
@@ -6,6 +6,7 @@ import java.util.List;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Accordion;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
@@ -13,12 +14,14 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.DateField;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.InlineDateField;
+import com.vaadin.ui.Label;
import com.vaadin.ui.ListSelect;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.Slider;
+import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.TreeGrid;
@@ -54,6 +57,12 @@ public class TabIndexes extends AbstractTestUIWithLog {
menubar.addItem("foo", item -> {
});
fields.add(menubar);
+ TabSheet tabSheet = new TabSheet();
+ tabSheet.addTab(new Label("Tab content"), "Tab 1");
+ fields.add(tabSheet);
+ Accordion accordion = new Accordion();
+ accordion.addTab(new Label("Tab content"), "Tab 1");
+ fields.add(accordion);
HorizontalLayout buttonLayout = new HorizontalLayout();
addComponent(buttonLayout);
diff --git a/uitest/src/test/java/com/vaadin/tests/fields/TabIndexesTest.java b/uitest/src/test/java/com/vaadin/tests/fields/TabIndexesTest.java
index db61d72d8f..67f7bea44f 100644
--- a/uitest/src/test/java/com/vaadin/tests/fields/TabIndexesTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/fields/TabIndexesTest.java
@@ -8,7 +8,9 @@ import java.util.List;
import org.junit.Test;
import org.openqa.selenium.WebElement;
+import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.AbstractComponentElement;
+import com.vaadin.testbench.elements.AccordionElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.ComboBoxElement;
@@ -20,6 +22,7 @@ import com.vaadin.testbench.elements.NativeSelectElement;
import com.vaadin.testbench.elements.PasswordFieldElement;
import com.vaadin.testbench.elements.RichTextAreaElement;
import com.vaadin.testbench.elements.SliderElement;
+import com.vaadin.testbench.elements.TabSheetElement;
import com.vaadin.testbench.elements.TextAreaElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.testbench.elements.TreeGridElement;
@@ -85,12 +88,10 @@ public class TabIndexesTest extends SingleBrowserTest {
}
private void assertTabIndex(String expected, WebElement element) {
- if (!expected.equals(element.getAttribute("tabIndex"))) {
- assertEquals(
- "Unexpected tab index for element "
- + element.getAttribute("outerHTML"),
- expected, element.getAttribute("tabIndex"));
- }
+ assertEquals(
+ "Unexpected tab index for element "
+ + element.getAttribute("outerHTML"),
+ expected, element.getAttribute("tabIndex"));
}
private List<WebElement> getFocusElements() {
@@ -115,11 +116,19 @@ public class TabIndexesTest extends SingleBrowserTest {
focusElements.add($(CheckBoxElement.class).first().getInputElement());
focusElements.add($(SliderElement.class).first());
focusElements.add($(MenuBarElement.class).first());
+ TabSheetElement tabsheet = $(TabSheetElement.class).first();
+ focusElements.add(tabsheet
+ .findElement(By.className("v-tabsheet-tabitemcell-selected")));
+ AccordionElement accordion = $(AccordionElement.class).first();
+ focusElements.add(
+ accordion.findElement(By.className("v-accordion-item-open")));
List<AbstractComponentElement> components = $(
VerticalLayoutElement.class).id(TabIndexes.FIELD_CONTAINER_ID)
.$(AbstractComponentElement.class).all();
- assertEquals(components.size(), focusElements.size());
+ // the Labels within the TabSheet and Accordion are left out of the
+ // index handling
+ assertEquals(components.size(), focusElements.size() + 2);
return focusElements;
}