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.

PopupViewDeclarativeTest.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.popupview;
  17. import org.junit.Test;
  18. import com.vaadin.tests.design.DeclarativeTestBase;
  19. import com.vaadin.ui.Component;
  20. import com.vaadin.ui.Label;
  21. import com.vaadin.ui.PopupView;
  22. import com.vaadin.ui.VerticalLayout;
  23. import com.vaadin.ui.declarative.DesignContext;
  24. public class PopupViewDeclarativeTest extends DeclarativeTestBase<PopupView> {
  25. @Test
  26. public void testEmptyPopupView() {
  27. PopupView component = new PopupView();
  28. Component popup = component.getContent().getPopupComponent();
  29. String design = "<vaadin-popup-view><popup-content>"
  30. + new DesignContext().createElement(popup)
  31. + "</popup-content></vaadin-popup-view>";
  32. testWrite(design, component);
  33. testRead(design, component);
  34. }
  35. @Test
  36. public void testVisiblePopupDesign() {
  37. final VerticalLayout verticalLayout = new VerticalLayout();
  38. verticalLayout.setWidth("300px");
  39. verticalLayout.setHeight("400px");
  40. PopupView component = new PopupView("Click <u>here</u> to open",
  41. verticalLayout);
  42. component.setHideOnMouseOut(true);
  43. component.setPopupVisible(true);
  44. // hide-on-mouse-out is true by default. not seen in design
  45. String design = "<vaadin-popup-view popup-visible>" //
  46. + "Click <u>here</u> to open"
  47. + "<popup-content>"
  48. + new DesignContext().createElement(verticalLayout)
  49. + "</popup-content>" //
  50. + "</vaadin-popup-view>";
  51. testWrite(design, component);
  52. testRead(design, component);
  53. }
  54. @Test
  55. public void testHideOnMouseOutDisabled() {
  56. final Label label = new Label("Foo");
  57. PopupView component = new PopupView("Click Me!", label);
  58. component.setHideOnMouseOut(false);
  59. String design = "<vaadin-popup-view hide-on-mouse-out='false'>" //
  60. + "Click Me!"
  61. + "<popup-content>"
  62. + new DesignContext().createElement(label) + "</popup-content>" //
  63. + "</vaadin-popup-view>";
  64. testWrite(design, component);
  65. testRead(design, component);
  66. }
  67. }