summaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
authorpag <gabi.antal88@gmail.com>2015-11-13 17:10:45 +0100
committerpag <gabi.antal88@gmail.com>2015-11-13 17:10:45 +0100
commit2edab81c8f280a36924cd60ca1df2181465cfcbb (patch)
treeb948f26a97323b4562f20bffe2db4b9214a44737 /uitest/src/com
parent8953147d96087582a7fea2c5284d585e70d768df (diff)
downloadvaadin-framework-2edab81c8f280a36924cd60ca1df2181465cfcbb.tar.gz
vaadin-framework-2edab81c8f280a36924cd60ca1df2181465cfcbb.zip
Use TabState.id for Accordion tab items as well (#18456)
Change-Id: I17206081109b2ec356d175915a16b0002a858bb4
Diffstat (limited to 'uitest/src/com')
-rw-r--r--uitest/src/com/vaadin/tests/components/accordion/AccordionTabIds.java57
-rw-r--r--uitest/src/com/vaadin/tests/components/accordion/AccordionTabIdsTest.java54
2 files changed, 111 insertions, 0 deletions
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"));
+ }
+}