diff options
Diffstat (limited to 'uitest/src')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/tabsheet/HtmlInTabCaption.java | 72 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/tabsheet/HtmlInTabCaptionTest.java | 73 |
2 files changed, 145 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/HtmlInTabCaption.java b/uitest/src/com/vaadin/tests/components/tabsheet/HtmlInTabCaption.java new file mode 100644 index 0000000000..66a27a10b5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/HtmlInTabCaption.java @@ -0,0 +1,72 @@ +/* + * 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.tabsheet; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Accordion; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; + +public class HtmlInTabCaption extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + getLayout().setSpacing(true); + TabSheet ts = new TabSheet(); + ts.setCaption("TabSheet - no <u>html</u> in tab captions"); + ts.setCaptionAsHtml(true); + ts.addTab(new Label(), "<font color='red'>red</font>"); + ts.addTab(new Label(), "<font color='blue'>blue</font>"); + addComponent(ts); + + ts = new TabSheet(); + ts.setCaption("TabSheet - <b>html</b> in tab captions"); + ts.setCaptionAsHtml(false); + ts.setTabCaptionsAsHtml(true); + ts.addTab(new Label(), "<font color='red'>red</font>"); + ts.addTab(new Label(), "<font color='blue'>blue</font>"); + addComponent(ts); + + Accordion acc = new Accordion(); + acc.setCaption("Accordion - no <u>html</u> in tab captions"); + acc.setCaptionAsHtml(true); + acc.addTab(new Label(), "<font color='red'>red</font>"); + acc.addTab(new Label(), "<font color='blue'>blue</font>"); + addComponent(acc); + + acc = new Accordion(); + acc.setCaption("Accordion - <b>html</b> in tab captions"); + acc.setCaptionAsHtml(false); + acc.setTabCaptionsAsHtml(true); + acc.addTab(new Label(), "<font color='red'>red</font>"); + acc.addTab(new Label(), "<font color='blue'>blue</font>"); + addComponent(acc); + + } + + @Override + protected Integer getTicketNumber() { + return 14609; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/HtmlInTabCaptionTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/HtmlInTabCaptionTest.java new file mode 100644 index 0000000000..41b7037b09 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/HtmlInTabCaptionTest.java @@ -0,0 +1,73 @@ +/* + * 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.tabsheet; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.AccordionElement; +import com.vaadin.testbench.elements.TabSheetElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class HtmlInTabCaptionTest extends SingleBrowserTest { + static final String PLAIN_TEXT_RED = "<font color='red'>red</font>"; + static final String HTML_TEXT_RED = "red"; + static final String PLAIN_TEXT_BLUE = "<font color='blue'>blue</font>"; + static final String HTML_TEXT_BLUE = "blue"; + + @Test + public void tabsheetWithoutHtmlCaptions() { + openTestURL(); + TabSheetElement ts = $(TabSheetElement.class).get(0); + Assert.assertEquals(PLAIN_TEXT_RED, getTab(ts, 0).getText()); + Assert.assertEquals(PLAIN_TEXT_BLUE, getTab(ts, 1).getText()); + } + + private WebElement getTab(TabSheetElement tabSheetElement, int i) { + String className = "v-tabsheet-tabitem"; + if (tabSheetElement instanceof AccordionElement) { + className = "v-accordion-item"; + } + return tabSheetElement.findElements(By.className(className)).get(i); + } + + @Test + public void tabsheetWithHtmlCaptions() { + openTestURL(); + TabSheetElement ts = $(TabSheetElement.class).get(1); + Assert.assertEquals(HTML_TEXT_RED, getTab(ts, 0).getText()); + Assert.assertEquals(HTML_TEXT_BLUE, getTab(ts, 1).getText()); + } + + @Test + public void accordionWithoutHtmlCaptions() { + openTestURL(); + AccordionElement acc = $(AccordionElement.class).get(0); + Assert.assertEquals(PLAIN_TEXT_RED, getTab(acc, 0).getText()); + Assert.assertEquals(PLAIN_TEXT_BLUE, getTab(acc, 1).getText()); + + } + + @Test + public void accordionWithHtmlCaptions() { + openTestURL(); + AccordionElement acc = $(AccordionElement.class).get(1); + Assert.assertEquals(HTML_TEXT_RED, getTab(acc, 0).getText()); + Assert.assertEquals(HTML_TEXT_BLUE, getTab(acc, 1).getText()); + } +} |