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.

DragAndDropWrapperDeclarativeTest.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.components.draganddropwrapper;
  17. import org.junit.Test;
  18. import com.vaadin.tests.design.DeclarativeTestBase;
  19. import com.vaadin.ui.Button;
  20. import com.vaadin.ui.DragAndDropWrapper;
  21. import com.vaadin.ui.DragAndDropWrapper.DragStartMode;
  22. import com.vaadin.ui.declarative.DesignContext;
  23. public class DragAndDropWrapperDeclarativeTest extends
  24. DeclarativeTestBase<DragAndDropWrapper> {
  25. @Test
  26. public void testDefaultDnDWrapper() {
  27. Button okButton = new Button("OK");
  28. String input = "<vaadin-drag-and-drop-wrapper>"
  29. + new DesignContext().createElement(okButton)
  30. + "</vaadin-drag-and-drop-wrapper>";
  31. DragAndDropWrapper wrapper = new DragAndDropWrapper(okButton);
  32. testWrite(input, wrapper);
  33. testRead(input, wrapper);
  34. }
  35. @Test
  36. public void testNoDragImage() {
  37. Button okButton = new Button("OK");
  38. String input = "<vaadin-drag-and-drop-wrapper drag-start-mode='wrapper'>"
  39. + new DesignContext().createElement(okButton)
  40. + "</vaadin-drag-and-drop-wrapper>";
  41. DragAndDropWrapper wrapper = new DragAndDropWrapper(okButton);
  42. wrapper.setDragStartMode(DragStartMode.WRAPPER);
  43. testWrite(input, wrapper);
  44. testRead(input, wrapper);
  45. }
  46. @Test
  47. public void testWithDragImage() {
  48. Button dragImage = new Button("Cancel");
  49. Button okButton = new Button("OK");
  50. String input = "<vaadin-drag-and-drop-wrapper drag-start-mode='component_other'>"
  51. + new DesignContext().createElement(okButton)
  52. + new DesignContext().createElement(dragImage).attr(
  53. ":drag-image", true)
  54. + "</vaadin-drag-and-drop-wrapper>";
  55. DragAndDropWrapper wrapper = new DragAndDropWrapper(okButton);
  56. wrapper.setDragStartMode(DragStartMode.COMPONENT_OTHER);
  57. wrapper.setDragImageComponent(dragImage);
  58. testWrite(input, wrapper);
  59. testRead(input, wrapper);
  60. }
  61. }