You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TabSheetDeclarativeTest.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.server.component.tabsheet;
  17. import org.junit.Test;
  18. import com.vaadin.server.ExternalResource;
  19. import com.vaadin.shared.ui.ContentMode;
  20. import com.vaadin.tests.design.DeclarativeTestBase;
  21. import com.vaadin.ui.Label;
  22. import com.vaadin.ui.TabSheet;
  23. import com.vaadin.ui.TabSheet.Tab;
  24. import com.vaadin.ui.TextField;
  25. /**
  26. * Tests declarative support for TabSheet.
  27. *
  28. * @since
  29. * @author Vaadin Ltd
  30. */
  31. public class TabSheetDeclarativeTest extends DeclarativeTestBase<TabSheet> {
  32. @Test
  33. public void testFeatures() {
  34. String design = "<vaadin-tab-sheet tabindex=5><tab caption=test-caption "
  35. + "visible=false closable enabled=false icon=http://www.vaadin.com/test.png"
  36. + " icon-alt=OK description=test-desc style-name=test-style "
  37. + "id=test-id><vaadin-text-field/></tab></vaadin-tab-sheet>";
  38. TabSheet ts = new TabSheet();
  39. ts.setTabIndex(5);
  40. TextField tf = new TextField();
  41. Tab tab = ts.addTab(tf);
  42. tab.setCaption("test-caption");
  43. tab.setVisible(false);
  44. tab.setClosable(true);
  45. tab.setEnabled(false);
  46. tab.setIcon(new ExternalResource("http://www.vaadin.com/test.png"));
  47. tab.setIconAlternateText("OK");
  48. tab.setDescription("test-desc");
  49. tab.setStyleName("test-style");
  50. tab.setId("test-id");
  51. ts.setSelectedTab(tf);
  52. testRead(design, ts);
  53. testWrite(design, ts);
  54. }
  55. @Test
  56. public void testSelected() {
  57. String design = "<vaadin-tab-sheet><tab selected><vaadin-text-field/></tab></vaadin-tab-sheet>";
  58. TabSheet ts = new TabSheet();
  59. TextField tf = new TextField();
  60. ts.addTab(tf);
  61. ts.setSelectedTab(tf);
  62. testRead(design, ts);
  63. testWrite(design, ts);
  64. }
  65. @Test
  66. public void tabsNotShown() {
  67. String design = "<vaadin-tab-sheet tabs-visible=\"false\">\n"
  68. + " <tab caption=\"My Tab\" selected>\n"
  69. + " <vaadin-label>My Content</vaadin-label>\n" + " </tab>\n"
  70. + "</vaadin-tab-sheet>\n";
  71. TabSheet ts = new TabSheet();
  72. ts.setTabsVisible(false);
  73. Label l = new Label("My Content", ContentMode.HTML);
  74. Tab tab = ts.addTab(l);
  75. tab.setCaption("My Tab");
  76. ts.setSelectedTab(tab);
  77. testRead(design, ts);
  78. testWrite(design, ts);
  79. }
  80. }