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.

GridChildrenTest.java 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.tests.server.component.grid;
  17. import java.util.Iterator;
  18. import org.junit.Assert;
  19. import org.junit.Test;
  20. import com.vaadin.ui.Component;
  21. import com.vaadin.ui.Label;
  22. import com.vaadin.ui.LegacyGrid;
  23. import com.vaadin.ui.LegacyGrid.FooterCell;
  24. import com.vaadin.ui.LegacyGrid.HeaderCell;
  25. public class GridChildrenTest {
  26. @Test
  27. public void componentsInMergedHeader() {
  28. LegacyGrid grid = new LegacyGrid();
  29. grid.addColumn("foo");
  30. grid.addColumn("bar");
  31. grid.addColumn("baz");
  32. HeaderCell merged = grid.getDefaultHeaderRow().join("foo", "bar",
  33. "baz");
  34. Label label = new Label();
  35. merged.setComponent(label);
  36. Iterator<Component> i = grid.iterator();
  37. Assert.assertEquals(label, i.next());
  38. Assert.assertFalse(i.hasNext());
  39. }
  40. @Test
  41. public void componentsInMergedFooter() {
  42. LegacyGrid grid = new LegacyGrid();
  43. grid.addColumn("foo");
  44. grid.addColumn("bar");
  45. grid.addColumn("baz");
  46. FooterCell merged = grid.addFooterRowAt(0).join("foo", "bar", "baz");
  47. Label label = new Label();
  48. merged.setComponent(label);
  49. Iterator<Component> i = grid.iterator();
  50. Assert.assertEquals(label, i.next());
  51. Assert.assertFalse(i.hasNext());
  52. }
  53. }