From 2edab81c8f280a36924cd60ca1df2181465cfcbb Mon Sep 17 00:00:00 2001 From: pag Date: Fri, 13 Nov 2015 17:10:45 +0100 Subject: Use TabState.id for Accordion tab items as well (#18456) Change-Id: I17206081109b2ec356d175915a16b0002a858bb4 --- .../components/accordion/AccordionTabIds.java | 57 ++++++++++++++++++++++ .../components/accordion/AccordionTabIdsTest.java | 54 ++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/accordion/AccordionTabIds.java create mode 100644 uitest/src/com/vaadin/tests/components/accordion/AccordionTabIdsTest.java (limited to 'uitest/src/com') diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionTabIds.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionTabIds.java new file mode 100644 index 0000000000..31bd8d99fb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionTabIds.java @@ -0,0 +1,57 @@ +package com.vaadin.tests.components.accordion; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Accordion; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet.Tab; + +@SuppressWarnings("serial") +public class AccordionTabIds extends AbstractTestUI { + + protected static final String FIRST_TAB_ID = "ID 1"; + protected static final String FIRST_TAB_MESSAGE = "First tab"; + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + Accordion accordion = new Accordion(); + final Tab firstTab = accordion.addTab(new Label(FIRST_TAB_MESSAGE)); + firstTab.setId(FIRST_TAB_ID); + Button setIdButton = new Button("Set id"); + setIdButton.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + firstTab.setId(FIRST_TAB_ID); + } + }); + Button clearIdButton = new Button("Clear id"); + clearIdButton.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + firstTab.setId(null); + } + }); + addComponents(setIdButton, clearIdButton, accordion); + } + + @Override + protected String getTestDescription() { + return "Accordion should set server side defined ids on Tabs."; + } + + @Override + protected Integer getTicketNumber() { + return 18456; + } +} diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionTabIdsTest.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionTabIdsTest.java new file mode 100644 index 0000000000..17c7fe6804 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionTabIdsTest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2014 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.accordion; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for Accordion: Tab.setId should be propagated to client side tabs. + * + * @since + * @author Vaadin Ltd + */ +public class AccordionTabIdsTest extends MultiBrowserTest { + + @Test + public void testGeTabByIds() { + openTestURL(); + ButtonElement setIdButton = $(ButtonElement.class).first(); + ButtonElement clearIdbutton = $(ButtonElement.class).get(1); + + WebElement firstItem = driver + .findElement(By.id(AccordionTabIds.FIRST_TAB_ID)); + WebElement label = $(LabelElement.class).context(firstItem).first(); + assertEquals(AccordionTabIds.FIRST_TAB_MESSAGE, label.getText()); + + clearIdbutton.click(); + assertEquals("", firstItem.getAttribute("id")); + + setIdButton.click(); + assertEquals(AccordionTabIds.FIRST_TAB_ID, + firstItem.getAttribute("id")); + } +} -- cgit v1.2.3