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.

AbstractSplitPanelDeclarativeTest.java 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 2000-2014 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.abstractsplitpanel;
  17. import org.junit.Test;
  18. import com.vaadin.server.Sizeable.Unit;
  19. import com.vaadin.tests.design.DeclarativeTestBase;
  20. import com.vaadin.ui.AbstractSplitPanel;
  21. import com.vaadin.ui.Button;
  22. import com.vaadin.ui.HorizontalSplitPanel;
  23. import com.vaadin.ui.Table;
  24. import com.vaadin.ui.VerticalLayout;
  25. import com.vaadin.ui.VerticalSplitPanel;
  26. /**
  27. * Tests declarative support for AbstractSplitPanel.
  28. *
  29. * @since
  30. * @author Vaadin Ltd
  31. */
  32. public class AbstractSplitPanelDeclarativeTest extends
  33. DeclarativeTestBase<AbstractSplitPanel> {
  34. @Test
  35. public void testWithBothChildren() {
  36. String design = "<v-horizontal-split-panel split-position=20.5% "
  37. + "min-split-position=20% max-split-position=50px locked='' "
  38. + "reversed=\"\"> <v-table /> <v-vertical-layout />"
  39. + "</v-horizontal-split-panel>";
  40. AbstractSplitPanel sp = new HorizontalSplitPanel();
  41. sp.setSplitPosition(20.5f, Unit.PERCENTAGE, true);
  42. sp.setMinSplitPosition(20, Unit.PERCENTAGE);
  43. sp.setMaxSplitPosition(50, Unit.PIXELS);
  44. sp.setLocked(true);
  45. sp.addComponent(new Table());
  46. sp.addComponent(new VerticalLayout());
  47. testRead(design, sp);
  48. testWrite(design, sp);
  49. }
  50. @Test
  51. public void testWithFirstChild() {
  52. String design = "<v-vertical-split-panel><v-table caption=\"First slot\"/>"
  53. + "</v-vertical-split-panel>";
  54. AbstractSplitPanel sp = new VerticalSplitPanel();
  55. Table t = new Table();
  56. t.setCaption("First slot");
  57. sp.addComponent(t);
  58. testRead(design, sp);
  59. testWrite(design, sp);
  60. }
  61. @Test
  62. public void testWithSecondChild() {
  63. String design = "<v-horizontal-split-panel><v-button :second>Second slot</v-button>"
  64. + "</v-vertical-split-panel>";
  65. AbstractSplitPanel sp = new HorizontalSplitPanel();
  66. Button b = new Button("Second slot");
  67. b.setCaptionAsHtml(true);
  68. sp.setSecondComponent(b);
  69. testRead(design, sp);
  70. testWrite(design, sp);
  71. }
  72. @Test
  73. public void testEmpty() {
  74. String design = "<v-horizontal-split-panel/>";
  75. AbstractSplitPanel sp = new HorizontalSplitPanel();
  76. testRead(design, sp);
  77. testWrite(design, sp);
  78. }
  79. }