diff options
author | Felype Santiago Ferreira <felype@vaadin.com> | 2014-02-26 16:05:37 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-04-08 06:34:55 +0000 |
commit | f32e3535c6ef73bca33f274e9906f57aa178d22a (patch) | |
tree | ba2453a82f97a2c68f35d363ed2c553d84d5bae9 /uitest | |
parent | ef8920661cc9d958c69cfedd0a74ce580a2a84ed (diff) | |
download | vaadin-framework-f32e3535c6ef73bca33f274e9906f57aa178d22a.tar.gz vaadin-framework-f32e3535c6ef73bca33f274e9906f57aa178d22a.zip |
Update Accordion and TabSheet to use Vaadin 7 style. (#13402).
This change also adds subpart support for TabSheet and
converts a test to TB3.
Change-Id: I23b6c81686ea6587470d8019e89a85149ec0b068
Diffstat (limited to 'uitest')
6 files changed, 130 insertions, 91 deletions
diff --git a/uitest/src/com/vaadin/tests/components/accordion/RemoveTabs.java b/uitest/src/com/vaadin/tests/components/accordion/RemoveTabs.java index d24def22dd..e82336c1e8 100644 --- a/uitest/src/com/vaadin/tests/components/accordion/RemoveTabs.java +++ b/uitest/src/com/vaadin/tests/components/accordion/RemoveTabs.java @@ -46,38 +46,34 @@ public class RemoveTabs extends TestBase { getLayout().addComponent(accordion); closeCurrent = new Button("Close current tab"); - closeCurrent.addListener(new Button.ClickListener() { + closeCurrent.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { closeCurrentTab(); - } }); closeFirst = new Button("close first tab"); - closeFirst.addListener(new Button.ClickListener() { + closeFirst.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { closeFirstTab(); - } }); closeLast = new Button("close last tab"); - closeLast.addListener(new Button.ClickListener() { + closeLast.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { closeLastTab(); - } }); reorderTabs = new Button("reorder"); - reorderTabs.addListener(new Button.ClickListener() { + reorderTabs.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { reorder(); - } }); @@ -96,11 +92,11 @@ public class RemoveTabs extends TestBase { } private void closeFirstTab() { - accordion.removeComponent(accordion.getComponentIterator().next()); + accordion.removeComponent(accordion.iterator().next()); } private void closeLastTab() { - Iterator<Component> i = accordion.getComponentIterator(); + Iterator<Component> i = accordion.iterator(); Component last = null; while (i.hasNext()) { last = i.next(); @@ -114,7 +110,7 @@ public class RemoveTabs extends TestBase { if (container != null) { List<Component> c = new ArrayList<Component>(); - Iterator<Component> i = container.getComponentIterator(); + Iterator<Component> i = container.iterator(); while (i.hasNext()) { Component comp = i.next(); c.add(comp); @@ -124,7 +120,6 @@ public class RemoveTabs extends TestBase { for (int j = c.size() - 1; j >= 0; j--) { container.addComponent(c.get(j)); } - } } diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheet.java b/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheet.java new file mode 100644 index 0000000000..3cbe624ee0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheet.java @@ -0,0 +1,27 @@ +package com.vaadin.tests.components.tabsheet; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.TabSheet; + +public class EmptyTabSheet extends TestBase { + + private TabSheet tabSheet; + + @Override + protected String getDescription() { + return "Test a TabSheet without any tabs."; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + + @Override + protected void setup() { + tabSheet = new TabSheet(); + tabSheet.setId("tabsheet"); + addComponent(tabSheet); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java new file mode 100644 index 0000000000..dabc9c8e0b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.tabsheet; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class EmptyTabSheetTest extends MultiBrowserTest { + @Test + public void emptyTabSheet() throws Exception { + openTestURL(); + + compareScreen("empty"); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.html b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.html deleted file mode 100644 index c4f5998f47..0000000000 --- a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.html +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8080/" /> -<title>PreventTabChange</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">PreventTabChange</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.tabsheet.PreventTabChange</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstabsheetPreventTabChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstabsheetPreventTabChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstabsheetPreventTabChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstabsheetPreventTabChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td></td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.java b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.java index 434c73f778..fddb036728 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.java @@ -31,7 +31,8 @@ public class PreventTabChange extends TestBase implements @Override protected void setup() { tabSheet = new TabSheet(); - tabSheet.addListener(this); + tabSheet.setId("tabsheet"); + tabSheet.addSelectedTabChangeListener(this); tab1 = new Label("Tab 1 contents"); tab2 = new Label("Tab 2 contents"); tab3 = new Label("Tab 3 contents"); @@ -48,8 +49,8 @@ public class PreventTabChange extends TestBase implements @Override public void selectedTabChange(SelectedTabChangeEvent event) { - TabSheet tabsheet = event.getTabSheet(); + if (lastTab == tab1) { if (tabsheet.getSelectedTab() != tab2) { tabsheet.setSelectedTab(lastTab); @@ -63,6 +64,7 @@ public class PreventTabChange extends TestBase implements tabsheet.setSelectedTab(lastTab); } } + lastTab = tabsheet.getSelectedTab(); } } diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java new file mode 100644 index 0000000000..31a59aaed6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.tabsheet; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class PreventTabChangeTest extends MultiBrowserTest { + @Test + public void preventTabChange() throws Exception { + openTestURL(); + + clickTab(1); + clickTab(2); + Thread.sleep(2000); + assertTabSelected(2); + Assert.assertEquals("Tab 3 contents", getSelectedTabContent().getText()); + clickTab(0); + clickTab(2); + assertTabSelected(0); + Assert.assertEquals("Tab 1 contents", getSelectedTabContent().getText()); + } + + private void assertTabSelected(int i) throws NoSuchElementException { + WebElement tabItem = findTab(i).findElement(By.xpath("..")); + Assert.assertTrue("Tab " + i + " should be selected but isn't", tabItem + .getAttribute("class").contains("v-tabsheet-tabitem-selected")); + } + + private void clickTab(int i) { + findTab(i).click(); + } + + private WebElement findTab(int i) { + return driver.findElement(com.vaadin.testbench.By + .vaadin("//TabSheet#tab[" + i + "]")); + } + + private WebElement getSelectedTabContent() { + return driver.findElement(com.vaadin.testbench.By + .vaadin("//TabSheet#tabpanel")); + } + +}
\ No newline at end of file |