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.

CustomRendererTest.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.grid;
  17. import static org.junit.Assert.assertEquals;
  18. import java.util.List;
  19. import org.junit.Test;
  20. import com.vaadin.testbench.elements.GridElement;
  21. import com.vaadin.testbench.elements.LabelElement;
  22. import com.vaadin.testbench.parallel.TestCategory;
  23. import com.vaadin.tests.tb3.MultiBrowserTest;
  24. @TestCategory("grid")
  25. public class CustomRendererTest extends MultiBrowserTest {
  26. @Test
  27. public void testIntArrayIsRendered() throws Exception {
  28. openTestURL();
  29. GridElement grid = findGrid();
  30. assertEquals("1 :: 1 :: 2 :: 3 :: 5 :: 8 :: 13", grid.getCell(0, 0)
  31. .getText());
  32. }
  33. @Test
  34. public void testRowAwareRenderer() throws Exception {
  35. openTestURL();
  36. GridElement grid = findGrid();
  37. assertEquals("Click me!", grid.getCell(0, 1).getText());
  38. assertEquals(CustomRenderer.INIT_DEBUG_LABEL_CAPTION, findDebugLabel()
  39. .getText());
  40. grid.getCell(0, 1).click();
  41. assertEquals("row: 0, key: 0", grid.getCell(0, 1).getText());
  42. assertEquals("key: 0, itemId: " + CustomRenderer.ITEM_ID,
  43. findDebugLabel().getText());
  44. }
  45. private GridElement findGrid() {
  46. List<GridElement> elements = $(GridElement.class).all();
  47. return elements.get(0);
  48. }
  49. private LabelElement findDebugLabel() {
  50. return $(LabelElement.class).id(CustomRenderer.DEBUG_LABEL_ID);
  51. }
  52. }