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.

GridDeclarativeAttributeTest.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.v7.tests.server.component.grid.declarative;
  17. import static org.junit.Assert.assertSame;
  18. import org.junit.Test;
  19. import com.vaadin.tests.design.DeclarativeTestBase;
  20. import com.vaadin.v7.shared.ui.grid.HeightMode;
  21. import com.vaadin.v7.ui.Grid;
  22. import com.vaadin.v7.ui.Grid.MultiSelectionModel;
  23. import com.vaadin.v7.ui.Grid.NoSelectionModel;
  24. import com.vaadin.v7.ui.Grid.SingleSelectionModel;
  25. /**
  26. * Tests declarative support for Grid properties.
  27. *
  28. * @since
  29. * @author Vaadin Ltd
  30. */
  31. public class GridDeclarativeAttributeTest extends DeclarativeTestBase<Grid> {
  32. @Test
  33. public void testBasicAttributes() {
  34. String design = "<vaadin7-grid editable rows=20 frozen-columns=-1 "
  35. + "editor-save-caption='Tallenna' editor-cancel-caption='Peruuta' column-reordering-allowed>";
  36. Grid grid = new Grid();
  37. grid.setEditorEnabled(true);
  38. grid.setHeightMode(HeightMode.ROW);
  39. grid.setHeightByRows(20);
  40. grid.setFrozenColumnCount(-1);
  41. grid.setEditorSaveCaption("Tallenna");
  42. grid.setEditorCancelCaption("Peruuta");
  43. grid.setColumnReorderingAllowed(true);
  44. testRead(design, grid);
  45. testWrite(design, grid);
  46. }
  47. @Test
  48. public void testFrozenColumnsAttributes() {
  49. String design = "<vaadin7-grid frozen-columns='2'><table>" //
  50. + "<colgroup><col><col><col></colgroup></table></vaadin7-grid>";
  51. Grid grid = new Grid();
  52. grid.addColumn("property-0", String.class);
  53. grid.addColumn("property-1", String.class);
  54. grid.addColumn("property-2", String.class);
  55. grid.setFrozenColumnCount(2);
  56. testRead(design, grid);
  57. }
  58. @Test
  59. public void testSelectionMode() {
  60. String design = "<vaadin7-grid selection-mode='none'>";
  61. assertSame(NoSelectionModel.class,
  62. read(design).getSelectionModel().getClass());
  63. design = "<vaadin7-grid selection-mode='single'>";
  64. assertSame(SingleSelectionModel.class,
  65. read(design).getSelectionModel().getClass());
  66. design = "<vaadin7-grid selection-mode='multi'>";
  67. assertSame(MultiSelectionModel.class,
  68. read(design).getSelectionModel().getClass());
  69. }
  70. }