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.

AbstractColorPickerDeclarativeTest.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.colorpicker;
  17. import org.junit.Test;
  18. import com.vaadin.shared.ui.colorpicker.Color;
  19. import com.vaadin.tests.design.DeclarativeTestBase;
  20. import com.vaadin.ui.AbstractColorPicker;
  21. import com.vaadin.ui.AbstractColorPicker.PopupStyle;
  22. import com.vaadin.ui.ColorPicker;
  23. import com.vaadin.ui.ColorPickerArea;
  24. public class AbstractColorPickerDeclarativeTest extends
  25. DeclarativeTestBase<AbstractColorPicker> {
  26. @Test
  27. public void testAllAbstractColorPickerFeatures() {
  28. String design = "<vaadin-color-picker color='#fafafa' default-caption-enabled position='100,100'"
  29. + " popup-style='simple' rgb-visibility='false' hsv-visibility='false'"
  30. + " history-visibility=false textfield-visibility=false />";
  31. ColorPicker colorPicker = new ColorPicker();
  32. int colorInt = Integer.parseInt("fafafa", 16);
  33. colorPicker.setColor(new Color(colorInt));
  34. colorPicker.setDefaultCaptionEnabled(true);
  35. colorPicker.setPosition(100, 100);
  36. colorPicker.setPopupStyle(PopupStyle.POPUP_SIMPLE);
  37. colorPicker.setRGBVisibility(false);
  38. colorPicker.setHSVVisibility(false);
  39. colorPicker.setSwatchesVisibility(true);
  40. colorPicker.setHistoryVisibility(false);
  41. colorPicker.setTextfieldVisibility(false);
  42. testWrite(design, colorPicker);
  43. testRead(design, colorPicker);
  44. }
  45. @Test
  46. public void testEmptyColorPicker() {
  47. String design = "<vaadin-color-picker />";
  48. ColorPicker colorPicker = new ColorPicker();
  49. testRead(design, colorPicker);
  50. testWrite(design, colorPicker);
  51. }
  52. @Test
  53. public void testAllAbstractColorPickerAreaFeatures() {
  54. String design = "<vaadin-color-picker-area color='#fafafa' default-caption-enabled position='100,100'"
  55. + " popup-style='simple' rgb-visibility='false' hsv-visibility='false'"
  56. + " history-visibility=false textfield-visibility=false />";
  57. AbstractColorPicker colorPicker = new ColorPickerArea();
  58. int colorInt = Integer.parseInt("fafafa", 16);
  59. colorPicker.setColor(new Color(colorInt));
  60. colorPicker.setDefaultCaptionEnabled(true);
  61. colorPicker.setPosition(100, 100);
  62. colorPicker.setPopupStyle(PopupStyle.POPUP_SIMPLE);
  63. colorPicker.setRGBVisibility(false);
  64. colorPicker.setHSVVisibility(false);
  65. colorPicker.setSwatchesVisibility(true);
  66. colorPicker.setHistoryVisibility(false);
  67. colorPicker.setTextfieldVisibility(false);
  68. testWrite(design, colorPicker);
  69. testRead(design, colorPicker);
  70. }
  71. @Test
  72. public void testEmptyColorPickerArea() {
  73. String design = "<vaadin-color-picker-area />";
  74. AbstractColorPicker colorPicker = new ColorPickerArea();
  75. testRead(design, colorPicker);
  76. testWrite(design, colorPicker);
  77. }
  78. }