diff options
author | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2012-03-13 09:09:21 +0000 |
---|---|---|
committer | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2012-03-13 09:09:21 +0000 |
commit | 3201228f110968ef54ca15822285c808f03512e2 (patch) | |
tree | 04ceea0d3a7775c4f63bcd2a94100f24ea1201ac | |
parent | 574472d49597eb1711c964741a621f0cf88966be (diff) | |
download | vaadin-framework-3201228f110968ef54ca15822285c808f03512e2.tar.gz vaadin-framework-3201228f110968ef54ca15822285c808f03512e2.zip |
Improved #5100 test case: test server-side focus, focus/blur listeners, disabled tabs
svn changeset:23224/svn branch:6.8
-rw-r--r-- | tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java index 43f3380e16..5aab30c8e8 100644 --- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java +++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java @@ -1,11 +1,21 @@ package com.vaadin.tests.components.tabsheet; +import java.util.ArrayList; + +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; +import com.vaadin.ui.TabSheet.SelectedTabChangeListener; import com.vaadin.ui.TabSheet.Tab; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; @@ -13,29 +23,65 @@ import com.vaadin.ui.VerticalLayout; public class TabKeyboardNavigation extends TestBase { int index = 1; + ArrayList<Component> tabs = new ArrayList<Component>(); TabSheet ts = new TabSheet(); + Label focusblur = new Label("No focus"); @Override protected void setup() { ts.setWidth("500px"); ts.setHeight("500px"); - for (int i = 0; i < 4; ++i) { + // ts.setTabIndex(0); + + ts.addListener(new FocusListener() { + public void focus(FocusEvent event) { + focusblur.setValue("Tabsheet focused!"); + } + }); + + ts.addListener(new BlurListener() { + public void blur(BlurEvent event) { + focusblur.setValue("Tabsheet blurred!"); + } + }); + + ts.addListener(new SelectedTabChangeListener() { + + public void selectedTabChange(SelectedTabChangeEvent event) { + // ts.setSelectedTab(tabs.get(Math.max(0, + // tabs.indexOf(ts.getSelectedTab()) - 1))); + } + }); + + for (int i = 0; i < 5; ++i) { addTab(); } - Button b = new Button("Add a tab", new Button.ClickListener() { + + Button addTab = new Button("Add a tab", new ClickListener() { public void buttonClick(ClickEvent event) { addTab(); } }); - addComponent(b); - addComponent(new TextField()); + Button focus = new Button("Focus tabsheet", new ClickListener() { + public void buttonClick(ClickEvent event) { + ts.focus(); + } + }); + + addComponent(addTab); + addComponent(focus); + + TextField tf = new TextField(); + addComponent(tf); + addComponent(focusblur); addComponent(ts); - addComponent(new TextField()); + tf = new TextField(); + addComponent(tf); } @Override protected String getDescription() { - return "The tab bar should be focusable and arrow keys should switch tabs"; + return "The tab bar should be focusable and arrow keys should switch tabs. The del key should close a tab if closable."; } @Override @@ -45,10 +91,17 @@ public class TabKeyboardNavigation extends TestBase { private Tab addTab() { Layout content = new VerticalLayout(); + tabs.add(content); content.addComponent(new Label("Tab " + index)); content.addComponent(new TextField()); - Tab tab = ts.addTab(content, "Tab " + index++, null); - tab.setClosable(true); + Tab tab = ts.addTab(content, "Tab " + index, null); + if (index == 2) { + tab.setClosable(true); + } + if (index == 4) { + tab.setEnabled(false); + } + index++; return tab; } } |