Переглянути джерело

Remove carriage returns

Change-Id: I1be17dcf3245eca3e571886db4fa0cbb9657edbb
tags/8.0.0.alpha1
Artur Signell 7 роки тому
джерело
коміт
88a0b0ca9a
60 змінених файлів з 4662 додано та 4662 видалено
  1. 57
    57
      uitest/src/main/java/com/vaadin/tests/components/accordion/AccordionTabIds.java
  2. 498
    498
      uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridBasicFeatures.html
  3. 80
    80
      uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridItemEditor.html
  4. 118
    118
      uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridMultiSelect.html
  5. 11
    11
      uitest/src/main/webapp/statictestfiles/TableInIframeRowClickScrollJumpTest.html
  6. 70
    70
      uitest/src/test/java/com/vaadin/tests/components/grid/CustomRendererTest.java
  7. 50
    50
      uitest/src/test/java/com/vaadin/tests/components/grid/GridAddRowTest.java
  8. 73
    73
      uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java
  9. 101
    101
      uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java
  10. 39
    39
      uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoExpandTest.java
  11. 82
    82
      uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthRecalculationTest.java
  12. 139
    139
      uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java
  13. 50
    50
      uitest/src/test/java/com/vaadin/tests/components/grid/GridDataSourceResetTest.java
  14. 84
    84
      uitest/src/test/java/com/vaadin/tests/components/grid/GridDefaultSelectionModeTest.java
  15. 61
    61
      uitest/src/test/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolledTest.java
  16. 38
    38
      uitest/src/test/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBarsTest.java
  17. 42
    42
      uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorConverterNotFoundTest.java
  18. 46
    46
      uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorCustomFieldTest.java
  19. 77
    77
      uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java
  20. 96
    96
      uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorUITest.java
  21. 47
    47
      uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java
  22. 140
    140
      uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java
  23. 151
    151
      uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java
  24. 174
    174
      uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java
  25. 48
    48
      uitest/src/test/java/com/vaadin/tests/components/grid/GridInWindowResizeTest.java
  26. 84
    84
      uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java
  27. 48
    48
      uitest/src/test/java/com/vaadin/tests/components/grid/GridItemSetChangeTest.java
  28. 65
    65
      uitest/src/test/java/com/vaadin/tests/components/grid/GridLayoutDetailsRowTest.java
  29. 49
    49
      uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java
  30. 43
    43
      uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionScrollBarTest.java
  31. 58
    58
      uitest/src/test/java/com/vaadin/tests/components/grid/GridRendererChangeTest.java
  32. 39
    39
      uitest/src/test/java/com/vaadin/tests/components/grid/GridReplaceContainerTest.java
  33. 45
    45
      uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java
  34. 116
    116
      uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java
  35. 48
    48
      uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizingTest.java
  36. 36
    36
      uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllCellTest.java
  37. 87
    87
      uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java
  38. 47
    47
      uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java
  39. 52
    52
      uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java
  40. 57
    57
      uitest/src/test/java/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java
  41. 86
    86
      uitest/src/test/java/com/vaadin/tests/components/grid/GridSwitchRenderersTest.java
  42. 54
    54
      uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeChangeTest.java
  43. 110
    110
      uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeUITest.java
  44. 70
    70
      uitest/src/test/java/com/vaadin/tests/components/grid/GridWidthIncreaseTest.java
  45. 41
    41
      uitest/src/test/java/com/vaadin/tests/components/grid/GridWithBrokenRendererTest.java
  46. 37
    37
      uitest/src/test/java/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java
  47. 42
    42
      uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java
  48. 52
    52
      uitest/src/test/java/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java
  49. 49
    49
      uitest/src/test/java/com/vaadin/tests/components/grid/NullHeadersTest.java
  50. 65
    65
      uitest/src/test/java/com/vaadin/tests/components/grid/NullRenderersTest.java
  51. 63
    63
      uitest/src/test/java/com/vaadin/tests/components/grid/ProgrammaticEditorControlTest.java
  52. 37
    37
      uitest/src/test/java/com/vaadin/tests/components/grid/SelectDuringInitTest.java
  53. 51
    51
      uitest/src/test/java/com/vaadin/tests/components/grid/SortableHeaderStylesTest.java
  54. 167
    167
      uitest/src/test/java/com/vaadin/tests/components/grid/WidgetRenderersTest.java
  55. 52
    52
      uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridClearContainerTest.java
  56. 58
    58
      uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridScrollTest.java
  57. 86
    86
      uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/LoadingIndicatorTest.java
  58. 110
    110
      uitest/src/test/java/com/vaadin/tests/contextclick/GridContextClickTest.java
  59. 116
    116
      uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java
  60. 70
    70
      uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridTest.java

+ 57
- 57
uitest/src/main/java/com/vaadin/tests/components/accordion/AccordionTabIds.java Переглянути файл

@@ -1,57 +1,57 @@
package com.vaadin.tests.components.accordion;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Accordion;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet.Tab;
@SuppressWarnings("serial")
public class AccordionTabIds extends AbstractTestUI {
protected static final String FIRST_TAB_ID = "ID 1";
protected static final String FIRST_TAB_MESSAGE = "First tab";
/*
* (non-Javadoc)
*
* @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
* VaadinRequest)
*/
@Override
protected void setup(VaadinRequest request) {
Accordion accordion = new Accordion();
final Tab firstTab = accordion.addTab(new Label(FIRST_TAB_MESSAGE));
firstTab.setId(FIRST_TAB_ID);
Button setIdButton = new Button("Set id");
setIdButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
firstTab.setId(FIRST_TAB_ID);
}
});
Button clearIdButton = new Button("Clear id");
clearIdButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
firstTab.setId(null);
}
});
addComponents(setIdButton, clearIdButton, accordion);
}
@Override
protected String getTestDescription() {
return "Accordion should set server side defined ids on Tabs.";
}
@Override
protected Integer getTicketNumber() {
return 18456;
}
}
package com.vaadin.tests.components.accordion;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Accordion;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet.Tab;
@SuppressWarnings("serial")
public class AccordionTabIds extends AbstractTestUI {
protected static final String FIRST_TAB_ID = "ID 1";
protected static final String FIRST_TAB_MESSAGE = "First tab";
/*
* (non-Javadoc)
*
* @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
* VaadinRequest)
*/
@Override
protected void setup(VaadinRequest request) {
Accordion accordion = new Accordion();
final Tab firstTab = accordion.addTab(new Label(FIRST_TAB_MESSAGE));
firstTab.setId(FIRST_TAB_ID);
Button setIdButton = new Button("Set id");
setIdButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
firstTab.setId(FIRST_TAB_ID);
}
});
Button clearIdButton = new Button("Clear id");
clearIdButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
firstTab.setId(null);
}
});
addComponents(setIdButton, clearIdButton, accordion);
}
@Override
protected String getTestDescription() {
return "Accordion should set server side defined ids on Tabs.";
}
@Override
protected Integer getTicketNumber() {
return 18456;
}
}

+ 498
- 498
uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridBasicFeatures.html
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 80
- 80
uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridItemEditor.html Переглянути файл

@@ -1,81 +1,81 @@
<vaadin-legacy-grid caption="Double click to edit" width="100%" height="100%"
editable selection-mode="none">
<table>
<colgroup>
<col property-id="index" editable=false width="50" expand=0>
<col property-id="name" expand=2>
<col property-id="progress" expand=2>
<col property-id="weight" editable=false expand=4>
</colgroup>
<thead>
<tr>
<th>##
<th>Name
<th>Progress
<th>Weight
</tr>
</thead>
<tbody>
<tr>
<td>00
<td>Marc Addams
<td>0.42
<td>[SparkLine]
</tr>
<tr>
<td>01
<td>Kenny Black
<td>0.72
<td>[SparkLine]
</tr>
<tr>
<td>02
<td>Sarah McGoff
<td>0.12
<td>[SparkLine]
</tr>
<tr>
<td>03
<td>Jos Jones
<td>0.62
<td>[SparkLine]
</tr>
<tr>
<td>04
<td>Jane Fielding
<td>0.92
<td>[SparkLine]
</tr>
<tr>
<td>05
<td>Marc Einstein
<td>0.05
<td>[SparkLine]
</tr>
<tr>
<td>06
<td>Lenny McGoff
<td>0.40
<td>[SparkLine]
</tr>
<tr>
<td>07
<td>Peter Adams
<td>0.85
<td>[SparkLine]
</tr>
<tr>
<td>08
<td>Tony Stark
<td>0.22
<td>[SparkLine]
</tr>
<tr>
<td>09
<td>Nathan Fillion
<td>0.15
<td>[SparkLine]
</tr>
</tbody>
</table>
<vaadin-legacy-grid caption="Double click to edit" width="100%" height="100%"
editable selection-mode="none">
<table>
<colgroup>
<col property-id="index" editable=false width="50" expand=0>
<col property-id="name" expand=2>
<col property-id="progress" expand=2>
<col property-id="weight" editable=false expand=4>
</colgroup>
<thead>
<tr>
<th>##
<th>Name
<th>Progress
<th>Weight
</tr>
</thead>
<tbody>
<tr>
<td>00
<td>Marc Addams
<td>0.42
<td>[SparkLine]
</tr>
<tr>
<td>01
<td>Kenny Black
<td>0.72
<td>[SparkLine]
</tr>
<tr>
<td>02
<td>Sarah McGoff
<td>0.12
<td>[SparkLine]
</tr>
<tr>
<td>03
<td>Jos Jones
<td>0.62
<td>[SparkLine]
</tr>
<tr>
<td>04
<td>Jane Fielding
<td>0.92
<td>[SparkLine]
</tr>
<tr>
<td>05
<td>Marc Einstein
<td>0.05
<td>[SparkLine]
</tr>
<tr>
<td>06
<td>Lenny McGoff
<td>0.40
<td>[SparkLine]
</tr>
<tr>
<td>07
<td>Peter Adams
<td>0.85
<td>[SparkLine]
</tr>
<tr>
<td>08
<td>Tony Stark
<td>0.22
<td>[SparkLine]
</tr>
<tr>
<td>09
<td>Nathan Fillion
<td>0.15
<td>[SparkLine]
</tr>
</tbody>
</table>
</vaadin-legacy-grid>

+ 118
- 118
uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridMultiSelect.html Переглянути файл

@@ -1,118 +1,118 @@
<vaadin-legacy-grid width='100%' height='100%' selection-mode='multi' editable='false'>
<table>
<colgroup>
<col />
<col />
<col />
</colgroup>
<thead>
<tr>
<th>Description</th>
<th>Milestone</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>Issue #0</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #1</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #2</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #3</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #4</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #5</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #6</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #7</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #8</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #9</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #10</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #11</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #12</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #13</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #14</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #15</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #16</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #17</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #18</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #19</td>
<td>1.0</td>
<td>New</td>
</tr>
</tbody>
</table>
</vaadin-legacy-grid>
<vaadin-legacy-grid width='100%' height='100%' selection-mode='multi' editable='false'>
<table>
<colgroup>
<col />
<col />
<col />
</colgroup>
<thead>
<tr>
<th>Description</th>
<th>Milestone</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>Issue #0</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #1</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #2</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #3</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #4</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #5</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #6</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #7</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #8</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #9</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #10</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #11</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #12</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #13</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #14</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #15</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #16</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #17</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #18</td>
<td>1.0</td>
<td>New</td>
</tr>
<tr>
<td>Issue #19</td>
<td>1.0</td>
<td>New</td>
</tr>
</tbody>
</table>
</vaadin-legacy-grid>

+ 11
- 11
uitest/src/main/webapp/statictestfiles/TableInIframeRowClickScrollJumpTest.html Переглянути файл

@@ -1,12 +1,12 @@
<html>
<head>
<title>IEJumpTest</title>
</head>
<!-- This is for testing Vaadin UI in iFrame (test class TableInIframeRowClickScrollJumpTest, for ticket #15294 -->
<body>
<div style="font-size: 4px">test div</div>
<iframe id="test-iframe-0" src="/run/com.vaadin.tests.components.table.TableBlurFocus" width="100%" height="2000px" style="visibility: visible;">
</iframe>
</body>
<html>
<head>
<title>IEJumpTest</title>
</head>
<!-- This is for testing Vaadin UI in iFrame (test class TableInIframeRowClickScrollJumpTest, for ticket #15294 -->
<body>
<div style="font-size: 4px">test div</div>
<iframe id="test-iframe-0" src="/run/com.vaadin.tests.components.table.TableBlurFocus" width="100%" height="2000px" style="visibility: visible;">
</iframe>
</body>
</html>

+ 70
- 70
uitest/src/test/java/com/vaadin/tests/components/grid/CustomRendererTest.java Переглянути файл

@@ -1,70 +1,70 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class CustomRendererTest extends MultiBrowserTest {
@Test
public void testIntArrayIsRendered() throws Exception {
openTestURL();
GridElement grid = findGrid();
assertEquals("1 :: 1 :: 2 :: 3 :: 5 :: 8 :: 13",
grid.getCell(0, 0).getText());
}
@Test
public void testRowAwareRenderer() throws Exception {
openTestURL();
GridElement grid = findGrid();
assertEquals("Click me!", grid.getCell(0, 1).getText());
assertEquals(CustomRenderer.INIT_DEBUG_LABEL_CAPTION,
findDebugLabel().getText());
grid.getCell(0, 1).click();
assertEquals("row: 0, key: 1", grid.getCell(0, 1).getText());
assertEquals("key: 1, itemId: " + CustomRenderer.ITEM_ID,
findDebugLabel().getText());
}
@Test
public void testBeanRenderer() throws Exception {
openTestURL();
assertEquals("SimpleTestBean(42)", findGrid().getCell(0, 2).getText());
}
private GridElement findGrid() {
List<LegacyGridElement> elements = $(LegacyGridElement.class).all();
return elements.get(0);
}
private LabelElement findDebugLabel() {
return $(LabelElement.class).id(CustomRenderer.DEBUG_LABEL_ID);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class CustomRendererTest extends MultiBrowserTest {
@Test
public void testIntArrayIsRendered() throws Exception {
openTestURL();
GridElement grid = findGrid();
assertEquals("1 :: 1 :: 2 :: 3 :: 5 :: 8 :: 13",
grid.getCell(0, 0).getText());
}
@Test
public void testRowAwareRenderer() throws Exception {
openTestURL();
GridElement grid = findGrid();
assertEquals("Click me!", grid.getCell(0, 1).getText());
assertEquals(CustomRenderer.INIT_DEBUG_LABEL_CAPTION,
findDebugLabel().getText());
grid.getCell(0, 1).click();
assertEquals("row: 0, key: 1", grid.getCell(0, 1).getText());
assertEquals("key: 1, itemId: " + CustomRenderer.ITEM_ID,
findDebugLabel().getText());
}
@Test
public void testBeanRenderer() throws Exception {
openTestURL();
assertEquals("SimpleTestBean(42)", findGrid().getCell(0, 2).getText());
}
private GridElement findGrid() {
List<LegacyGridElement> elements = $(LegacyGridElement.class).all();
return elements.get(0);
}
private LabelElement findDebugLabel() {
return $(LabelElement.class).id(CustomRenderer.DEBUG_LABEL_ID);
}
}

+ 50
- 50
uitest/src/test/java/com/vaadin/tests/components/grid/GridAddRowTest.java Переглянути файл

@@ -1,50 +1,50 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridAddRowTest extends MultiBrowserTest {
@Test
public void testAddRow() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals("Lorem", grid.getCell(0, 1).getText());
Assert.assertEquals("2", grid.getCell(1, 2).getText());
addRow();
Assert.assertEquals("Dolor", grid.getCell(2, 1).getText());
addRow();
Assert.assertEquals("Dolor", grid.getCell(3, 1).getText());
}
private void addRow() {
$(ButtonElement.class).caption("Add new row").first().click();
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridAddRowTest extends MultiBrowserTest {
@Test
public void testAddRow() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals("Lorem", grid.getCell(0, 1).getText());
Assert.assertEquals("2", grid.getCell(1, 2).getText());
addRow();
Assert.assertEquals("Dolor", grid.getCell(2, 1).getText());
addRow();
Assert.assertEquals("Dolor", grid.getCell(3, 1).getText());
}
private void addRow() {
$(ButtonElement.class).caption("Add new row").first().click();
}
}

+ 73
- 73
uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java Переглянути файл

@@ -1,73 +1,73 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.legacyelements.LegacyCheckBoxElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridCheckBoxDisplayTest extends SingleBrowserTest {
@Test
public void testAddRow() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals("First item had wrong value", "true",
grid.getCell(0, 0).getText());
Assert.assertEquals("Second item had wrong value", "false",
grid.getCell(1, 0).getText());
// First edit false item and see that the CheckBox is unchecked
grid.getCell(1, 0).doubleClick();
CheckBoxElement checkbox = $(LegacyCheckBoxElement.class).first();
Assert.assertEquals("CheckBox was checked", "unchecked",
checkbox.getValue());
closeEditor();
// Edit true item and see that the CheckBox is checked
grid.getCell(0, 0).doubleClick();
checkbox = $(LegacyCheckBoxElement.class).first();
Assert.assertEquals("CheckBox was not checked.", "checked",
checkbox.getValue());
closeEditor();
// Edit false item and confirm that the CheckBox is unchecked again
grid.getCell(1, 0).doubleClick();
checkbox = $(LegacyCheckBoxElement.class).first();
Assert.assertEquals("CheckBox was checked", "unchecked",
checkbox.getValue());
}
/**
* Closes the grids editor using the cancel button
*/
private void closeEditor() {
findElement(By.className("v-grid-editor-cancel")).click();
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.legacyelements.LegacyCheckBoxElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridCheckBoxDisplayTest extends SingleBrowserTest {
@Test
public void testAddRow() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals("First item had wrong value", "true",
grid.getCell(0, 0).getText());
Assert.assertEquals("Second item had wrong value", "false",
grid.getCell(1, 0).getText());
// First edit false item and see that the CheckBox is unchecked
grid.getCell(1, 0).doubleClick();
CheckBoxElement checkbox = $(LegacyCheckBoxElement.class).first();
Assert.assertEquals("CheckBox was checked", "unchecked",
checkbox.getValue());
closeEditor();
// Edit true item and see that the CheckBox is checked
grid.getCell(0, 0).doubleClick();
checkbox = $(LegacyCheckBoxElement.class).first();
Assert.assertEquals("CheckBox was not checked.", "checked",
checkbox.getValue());
closeEditor();
// Edit false item and confirm that the CheckBox is unchecked again
grid.getCell(1, 0).doubleClick();
checkbox = $(LegacyCheckBoxElement.class).first();
Assert.assertEquals("CheckBox was checked", "unchecked",
checkbox.getValue());
}
/**
* Closes the grids editor using the cancel button
*/
private void closeEditor() {
findElement(By.className("v-grid-editor-cancel")).click();
}
}

+ 101
- 101
uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java Переглянути файл

@@ -1,101 +1,101 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridColspansTest extends MultiBrowserTest {
@Before
public void setUp() {
setDebug(true);
}
@Test
public void testHeaderColSpans() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertEquals("5", grid.getHeaderCell(0, 1).getAttribute("colspan"));
assertEquals("2", grid.getHeaderCell(1, 1).getAttribute("colspan"));
assertEquals("3", grid.getHeaderCell(1, 3).getAttribute("colspan"));
}
@Test
public void testFooterColSpans() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertEquals("5", grid.getFooterCell(1, 1).getAttribute("colspan"));
assertEquals("2", grid.getFooterCell(0, 1).getAttribute("colspan"));
assertEquals("3", grid.getFooterCell(0, 3).getAttribute("colspan"));
}
@Test
public void testHideFirstColumnOfColspan() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertEquals("Failed initial condition.", "all the stuff",
grid.getHeaderCell(0, 1).getText().toLowerCase());
assertEquals("Failed initial condition.", "first name",
grid.getHeaderCell(2, 1).getText().toLowerCase());
$(ButtonElement.class).caption("Show/Hide firstName").first().click();
assertEquals("Header text changed on column hide.", "all the stuff",
grid.getHeaderCell(0, 1).getText().toLowerCase());
assertEquals("Failed initial condition.", "last name",
grid.getHeaderCell(2, 1).getText().toLowerCase());
}
@Test
public void testSplittingMergedHeaders() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement headerCell = grid.getHeaderCell(1, 1);
assertEquals("Failed initial condition.", "full name",
headerCell.getText().toLowerCase());
assertEquals("Failed initial condition.", "first name",
grid.getHeaderCell(2, 1).getText().toLowerCase());
$(ButtonElement.class).get(1).click();
headerCell = grid.getHeaderCell(1, 1);
assertEquals("Header text not changed on column reorder.", "address",
headerCell.getText().toLowerCase());
assertEquals("Unexpected colspan", "1",
headerCell.getAttribute("colspan"));
headerCell = grid.getHeaderCell(1, 2);
assertEquals("Header text not changed on column reorder", "full name",
headerCell.getText().toLowerCase());
assertEquals("Unexpected colspan", "2",
headerCell.getAttribute("colspan"));
assertTrue("Error indicator not present",
isElementPresent(By.className("v-errorindicator")));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridColspansTest extends MultiBrowserTest {
@Before
public void setUp() {
setDebug(true);
}
@Test
public void testHeaderColSpans() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertEquals("5", grid.getHeaderCell(0, 1).getAttribute("colspan"));
assertEquals("2", grid.getHeaderCell(1, 1).getAttribute("colspan"));
assertEquals("3", grid.getHeaderCell(1, 3).getAttribute("colspan"));
}
@Test
public void testFooterColSpans() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertEquals("5", grid.getFooterCell(1, 1).getAttribute("colspan"));
assertEquals("2", grid.getFooterCell(0, 1).getAttribute("colspan"));
assertEquals("3", grid.getFooterCell(0, 3).getAttribute("colspan"));
}
@Test
public void testHideFirstColumnOfColspan() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertEquals("Failed initial condition.", "all the stuff",
grid.getHeaderCell(0, 1).getText().toLowerCase());
assertEquals("Failed initial condition.", "first name",
grid.getHeaderCell(2, 1).getText().toLowerCase());
$(ButtonElement.class).caption("Show/Hide firstName").first().click();
assertEquals("Header text changed on column hide.", "all the stuff",
grid.getHeaderCell(0, 1).getText().toLowerCase());
assertEquals("Failed initial condition.", "last name",
grid.getHeaderCell(2, 1).getText().toLowerCase());
}
@Test
public void testSplittingMergedHeaders() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement headerCell = grid.getHeaderCell(1, 1);
assertEquals("Failed initial condition.", "full name",
headerCell.getText().toLowerCase());
assertEquals("Failed initial condition.", "first name",
grid.getHeaderCell(2, 1).getText().toLowerCase());
$(ButtonElement.class).get(1).click();
headerCell = grid.getHeaderCell(1, 1);
assertEquals("Header text not changed on column reorder.", "address",
headerCell.getText().toLowerCase());
assertEquals("Unexpected colspan", "1",
headerCell.getAttribute("colspan"));
headerCell = grid.getHeaderCell(1, 2);
assertEquals("Header text not changed on column reorder", "full name",
headerCell.getText().toLowerCase());
assertEquals("Unexpected colspan", "2",
headerCell.getAttribute("colspan"));
assertTrue("Error indicator not present",
isElementPresent(By.className("v-errorindicator")));
}
}

+ 39
- 39
uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoExpandTest.java Переглянути файл

@@ -1,39 +1,39 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridColumnAutoExpandTest extends MultiBrowserTest {
@Test
public void testSecondColumnHasExpanded() {
openTestURL();
GridCellElement headerCell = $(LegacyGridElement.class).first()
.getHeaderCell(0, 1);
assertTrue("Column did not expand as expected",
headerCell.getSize().getWidth() > 400);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridColumnAutoExpandTest extends MultiBrowserTest {
@Test
public void testSecondColumnHasExpanded() {
openTestURL();
GridCellElement headerCell = $(LegacyGridElement.class).first()
.getHeaderCell(0, 1);
assertTrue("Column did not expand as expected",
headerCell.getSize().getWidth() > 400);
}
}

+ 82
- 82
uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthRecalculationTest.java Переглянути файл

@@ -1,82 +1,82 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Dimension;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridColumnWidthRecalculationTest extends SingleBrowserTest {
private GridElement grid;
@Before
public void open() {
openTestURL();
grid = $(LegacyGridElement.class).first();
}
@Test
public void columnWidthAfterSwap() {
int column0Width = getColumnWidth(0);
int column1Width = getColumnWidth(1);
Assert.assertTrue("Column 0 should be narrower than column 1 initially",
column0Width < column1Width);
$(ButtonElement.class).caption("Swap content").first().click();
Assert.assertEquals(
"Column 0 width should not change when swapping contents only",
column0Width, getColumnWidth(0));
Assert.assertEquals(
"Column 1 width should not change when swapping contents only",
column1Width, getColumnWidth(1));
}
@Test
public void columnWidthAfterSwapAndRecalculate() {
int column0Width = getColumnWidth(0);
int column1Width = getColumnWidth(1);
Assert.assertTrue("Column 0 should be narrower than column 1 initially",
column0Width < column1Width);
$(ButtonElement.class).caption("Swap content and recalculate columns")
.first().click();
column0Width = getColumnWidth(0);
column1Width = getColumnWidth(1);
Assert.assertTrue(
"Column 1 should be narrower than column 0 after resize",
column1Width < column0Width);
}
private int getColumnWidth(int columnIndex) {
GridCellElement headerColumn = grid.getHeaderCells(0).get(columnIndex);
Dimension column1Size = headerColumn.getSize();
int columnWidth = column1Size.getWidth();
return columnWidth;
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Dimension;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridColumnWidthRecalculationTest extends SingleBrowserTest {
private GridElement grid;
@Before
public void open() {
openTestURL();
grid = $(LegacyGridElement.class).first();
}
@Test
public void columnWidthAfterSwap() {
int column0Width = getColumnWidth(0);
int column1Width = getColumnWidth(1);
Assert.assertTrue("Column 0 should be narrower than column 1 initially",
column0Width < column1Width);
$(ButtonElement.class).caption("Swap content").first().click();
Assert.assertEquals(
"Column 0 width should not change when swapping contents only",
column0Width, getColumnWidth(0));
Assert.assertEquals(
"Column 1 width should not change when swapping contents only",
column1Width, getColumnWidth(1));
}
@Test
public void columnWidthAfterSwapAndRecalculate() {
int column0Width = getColumnWidth(0);
int column1Width = getColumnWidth(1);
Assert.assertTrue("Column 0 should be narrower than column 1 initially",
column0Width < column1Width);
$(ButtonElement.class).caption("Swap content and recalculate columns")
.first().click();
column0Width = getColumnWidth(0);
column1Width = getColumnWidth(1);
Assert.assertTrue(
"Column 1 should be narrower than column 0 after resize",
column1Width < column0Width);
}
private int getColumnWidth(int columnIndex) {
GridCellElement headerColumn = grid.getHeaderCells(0).get(columnIndex);
Dimension column1Size = headerColumn.getSize();
int columnWidth = column1Size.getWidth();
return columnWidth;
}
}

+ 139
- 139
uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java Переглянути файл

@@ -1,139 +1,139 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.NativeSelectElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridColumnWidthsWithoutDataTest extends SingleBrowserTest {
@Test
public void testWidthsWhenAddingDataBack() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
int[] baseWidths = getColWidths(grid);
Assert.assertEquals("Sanity check", 2, baseWidths.length);
Assert.assertTrue("Columns should not have equal width",
Math.abs(baseWidths[0] - baseWidths[1]) > 2);
removeData();
assertSameWidths(baseWidths, getColWidths(grid));
addData();
assertSameWidths(baseWidths, getColWidths(grid));
}
@Test
public void testWidthsWhenInitiallyEmpty() {
setDebug(true);
openTestURL();
$(ButtonElement.class).caption("Recreate without data").first().click();
GridElement grid = $(LegacyGridElement.class).first();
int[] baseWidths = getColWidths(grid);
Assert.assertEquals("Sanity check", 2, baseWidths.length);
Assert.assertTrue("Columns should have roughly equal width",
Math.abs(baseWidths[0] - baseWidths[1]) < 10);
Assert.assertTrue("Columns should not have default widths",
baseWidths[0] > 140);
Assert.assertTrue("Columns should not have default widths",
baseWidths[1] > 140);
addData();
assertSameWidths(baseWidths, getColWidths(grid));
Assert.assertFalse("Notification was present",
isElementPresent(NotificationElement.class));
}
@Test
public void testMultiSelectWidths() {
setDebug(true);
openTestURL();
$(NativeSelectElement.class).caption("Selection mode").first()
.selectByText("Multi");
GridElement grid = $(LegacyGridElement.class).first();
int sum = sumUsedWidths(grid);
// 295 instead of 300 to avoid rounding issues
Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295);
$(ButtonElement.class).caption("Recreate without data").first().click();
grid = $(LegacyGridElement.class).first();
sum = sumUsedWidths(grid);
// 295 instead of 300 to avoid rounding issues
Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295);
}
private int sumUsedWidths(GridElement grid) {
int sum = 0;
for (int i : getColWidths(grid)) {
sum += i;
}
return sum;
}
private static void assertSameWidths(int[] expected, int[] actual) {
Assert.assertEquals("Arrays have differing lengths", expected.length,
actual.length);
for (int i = 0; i < expected.length; i++) {
if (Math.abs(expected[i] - actual[i]) > 1) {
Assert.fail("Differing sizes at index " + i + ". Expected "
+ expected[i] + " but got " + actual[i]);
}
}
}
private void removeData() {
$(ButtonElement.class).caption("Remove data").first().click();
}
private void addData() {
$(ButtonElement.class).caption("Add data").first().click();
}
private int[] getColWidths(GridElement grid) {
List<GridCellElement> headerCells = grid.getHeaderCells(0);
int[] widths = new int[headerCells.size()];
for (int i = 0; i < widths.length; i++) {
widths[i] = headerCells.get(i).getSize().getWidth();
}
return widths;
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.NativeSelectElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridColumnWidthsWithoutDataTest extends SingleBrowserTest {
@Test
public void testWidthsWhenAddingDataBack() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
int[] baseWidths = getColWidths(grid);
Assert.assertEquals("Sanity check", 2, baseWidths.length);
Assert.assertTrue("Columns should not have equal width",
Math.abs(baseWidths[0] - baseWidths[1]) > 2);
removeData();
assertSameWidths(baseWidths, getColWidths(grid));
addData();
assertSameWidths(baseWidths, getColWidths(grid));
}
@Test
public void testWidthsWhenInitiallyEmpty() {
setDebug(true);
openTestURL();
$(ButtonElement.class).caption("Recreate without data").first().click();
GridElement grid = $(LegacyGridElement.class).first();
int[] baseWidths = getColWidths(grid);
Assert.assertEquals("Sanity check", 2, baseWidths.length);
Assert.assertTrue("Columns should have roughly equal width",
Math.abs(baseWidths[0] - baseWidths[1]) < 10);
Assert.assertTrue("Columns should not have default widths",
baseWidths[0] > 140);
Assert.assertTrue("Columns should not have default widths",
baseWidths[1] > 140);
addData();
assertSameWidths(baseWidths, getColWidths(grid));
Assert.assertFalse("Notification was present",
isElementPresent(NotificationElement.class));
}
@Test
public void testMultiSelectWidths() {
setDebug(true);
openTestURL();
$(NativeSelectElement.class).caption("Selection mode").first()
.selectByText("Multi");
GridElement grid = $(LegacyGridElement.class).first();
int sum = sumUsedWidths(grid);
// 295 instead of 300 to avoid rounding issues
Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295);
$(ButtonElement.class).caption("Recreate without data").first().click();
grid = $(LegacyGridElement.class).first();
sum = sumUsedWidths(grid);
// 295 instead of 300 to avoid rounding issues
Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295);
}
private int sumUsedWidths(GridElement grid) {
int sum = 0;
for (int i : getColWidths(grid)) {
sum += i;
}
return sum;
}
private static void assertSameWidths(int[] expected, int[] actual) {
Assert.assertEquals("Arrays have differing lengths", expected.length,
actual.length);
for (int i = 0; i < expected.length; i++) {
if (Math.abs(expected[i] - actual[i]) > 1) {
Assert.fail("Differing sizes at index " + i + ". Expected "
+ expected[i] + " but got " + actual[i]);
}
}
}
private void removeData() {
$(ButtonElement.class).caption("Remove data").first().click();
}
private void addData() {
$(ButtonElement.class).caption("Add data").first().click();
}
private int[] getColWidths(GridElement grid) {
List<GridCellElement> headerCells = grid.getHeaderCells(0);
int[] widths = new int[headerCells.size()];
for (int i = 0; i < widths.length; i++) {
widths[i] = headerCells.get(i).getSize().getWidth();
}
return widths;
}
}

+ 50
- 50
uitest/src/test/java/com/vaadin/tests/components/grid/GridDataSourceResetTest.java Переглянути файл

@@ -1,50 +1,50 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridDataSourceResetTest extends SingleBrowserTest {
@Test
public void testRemoveWithSelectUpdatesRowsCorrectly() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertTrue("First row was not selected", grid.getRow(0).isSelected());
for (int i = 1; i < 10; ++i) {
assertFalse("Only first row should be selected",
grid.getRow(i).isSelected());
}
$(ButtonElement.class).first().click();
assertTrue("First row was not selected after remove",
grid.getRow(0).isSelected());
for (int i = 1; i < 9; ++i) {
assertFalse("Only first row should be selected after remove",
grid.getRow(i).isSelected());
}
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridDataSourceResetTest extends SingleBrowserTest {
@Test
public void testRemoveWithSelectUpdatesRowsCorrectly() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertTrue("First row was not selected", grid.getRow(0).isSelected());
for (int i = 1; i < 10; ++i) {
assertFalse("Only first row should be selected",
grid.getRow(i).isSelected());
}
$(ButtonElement.class).first().click();
assertTrue("First row was not selected after remove",
grid.getRow(0).isSelected());
for (int i = 1; i < 9; ++i) {
assertFalse("Only first row should be selected after remove",
grid.getRow(i).isSelected());
}
}
}

+ 84
- 84
uitest/src/test/java/com/vaadin/tests/components/grid/GridDefaultSelectionModeTest.java Переглянути файл

@@ -1,84 +1,84 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridDefaultSelectionModeTest extends MultiBrowserTest {
@Test
public void testSelectionFromServer() {
setDebug(true);
openTestURL();
$(ButtonElement.class).caption("Select on server").first().click();
assertTrue("Row should be selected.",
$(LegacyGridElement.class).first().getRow(0).isSelected());
$(ButtonElement.class).caption("Deselect on server").first().click();
assertFalse("Row should not be selected.",
$(LegacyGridElement.class).first().getRow(0).isSelected());
assertNoErrorNotifications();
}
@Test
public void testSelectionWithSort() {
setDebug(true);
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
grid.getCell(0, 0).click();
GridCellElement header = grid.getHeaderCell(0, 1);
header.click();
header.click();
assertTrue("Row should be selected.", grid.getRow(1).isSelected());
assertNoErrorNotifications();
}
@Test
public void testReselectDeselectedRow() {
setDebug(true);
openTestURL();
$(ButtonElement.class).caption("Select on server").first().click();
GridElement grid = $(LegacyGridElement.class).first();
assertTrue("Row should be selected.", grid.getRow(0).isSelected());
$(ButtonElement.class).caption("Deselect on server").first().click();
assertFalse("Row should not be selected.", grid.getRow(0).isSelected());
grid.getCell(0, 0).click();
assertTrue("Row should be selected.", grid.getRow(0).isSelected());
assertNoErrorNotifications();
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridDefaultSelectionModeTest extends MultiBrowserTest {
@Test
public void testSelectionFromServer() {
setDebug(true);
openTestURL();
$(ButtonElement.class).caption("Select on server").first().click();
assertTrue("Row should be selected.",
$(LegacyGridElement.class).first().getRow(0).isSelected());
$(ButtonElement.class).caption("Deselect on server").first().click();
assertFalse("Row should not be selected.",
$(LegacyGridElement.class).first().getRow(0).isSelected());
assertNoErrorNotifications();
}
@Test
public void testSelectionWithSort() {
setDebug(true);
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
grid.getCell(0, 0).click();
GridCellElement header = grid.getHeaderCell(0, 1);
header.click();
header.click();
assertTrue("Row should be selected.", grid.getRow(1).isSelected());
assertNoErrorNotifications();
}
@Test
public void testReselectDeselectedRow() {
setDebug(true);
openTestURL();
$(ButtonElement.class).caption("Select on server").first().click();
GridElement grid = $(LegacyGridElement.class).first();
assertTrue("Row should be selected.", grid.getRow(0).isSelected());
$(ButtonElement.class).caption("Deselect on server").first().click();
assertFalse("Row should not be selected.", grid.getRow(0).isSelected());
grid.getCell(0, 0).click();
assertTrue("Row should be selected.", grid.getRow(0).isSelected());
assertNoErrorNotifications();
}
}

+ 61
- 61
uitest/src/test/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolledTest.java Переглянути файл

@@ -1,61 +1,61 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridDragSelectionWhileScrolledTest extends MultiBrowserTest {
@Override
protected boolean requireWindowFocusForIE() {
return true;
}
@Test
public void testDragSelect() throws IOException {
openTestURL();
// Scroll grid to view
GridElement grid = $(LegacyGridElement.class).first();
((JavascriptExecutor) getDriver())
.executeScript("arguments[0].scrollIntoView(true);", grid);
// Drag select 2 rows
new Actions(getDriver()).moveToElement(grid.getCell(3, 0), 5, 5)
.clickAndHold().moveToElement(grid.getCell(2, 0), 5, 5)
.release().perform();
// Assert only those are selected.
assertTrue("Row 3 should be selected", grid.getRow(3).isSelected());
assertTrue("Row 2 should be selected", grid.getRow(2).isSelected());
assertFalse("Row 4 should not be selected",
grid.getRow(4).isSelected());
assertFalse("Row 1 should not be selected",
grid.getRow(1).isSelected());
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridDragSelectionWhileScrolledTest extends MultiBrowserTest {
@Override
protected boolean requireWindowFocusForIE() {
return true;
}
@Test
public void testDragSelect() throws IOException {
openTestURL();
// Scroll grid to view
GridElement grid = $(LegacyGridElement.class).first();
((JavascriptExecutor) getDriver())
.executeScript("arguments[0].scrollIntoView(true);", grid);
// Drag select 2 rows
new Actions(getDriver()).moveToElement(grid.getCell(3, 0), 5, 5)
.clickAndHold().moveToElement(grid.getCell(2, 0), 5, 5)
.release().perform();
// Assert only those are selected.
assertTrue("Row 3 should be selected", grid.getRow(3).isSelected());
assertTrue("Row 2 should be selected", grid.getRow(2).isSelected());
assertFalse("Row 4 should not be selected",
grid.getRow(4).isSelected());
assertFalse("Row 1 should not be selected",
grid.getRow(1).isSelected());
}
}

+ 38
- 38
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBarsTest.java Переглянути файл

@@ -1,38 +1,38 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridEditingWithNoScrollBarsTest extends MultiBrowserTest {
@Test
public void testEditorWideEnough() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
grid.getCell(1, 1).doubleClick();
assertEquals(grid.getEditor().getSize().width,
grid.getTableWrapper().getSize().width);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridEditingWithNoScrollBarsTest extends MultiBrowserTest {
@Test
public void testEditorWideEnough() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
grid.getCell(1, 1).doubleClick();
assertEquals(grid.getEditor().getSize().width,
grid.getTableWrapper().getSize().width);
}
}

+ 42
- 42
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorConverterNotFoundTest.java Переглянути файл

@@ -1,42 +1,42 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
public class GridEditorConverterNotFoundTest extends GridBasicFeaturesTest {
@Override
protected Class<?> getUIClass() {
// Use the correct UI with helpers from GridBasicFeatures
return GridEditorConverterNotFound.class;
}
@Test
public void testConverterNotFound() {
openTestURL();
$(LegacyGridElement.class).first().getCell(0, 0).doubleClick();
assertEquals("1. com.vaadin.data.Buffered$SourceException",
getLogRow(0));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
public class GridEditorConverterNotFoundTest extends GridBasicFeaturesTest {
@Override
protected Class<?> getUIClass() {
// Use the correct UI with helpers from GridBasicFeatures
return GridEditorConverterNotFound.class;
}
@Test
public void testConverterNotFound() {
openTestURL();
$(LegacyGridElement.class).first().getCell(0, 0).doubleClick();
assertEquals("1. com.vaadin.data.Buffered$SourceException",
getLogRow(0));
}
}

+ 46
- 46
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorCustomFieldTest.java Переглянути файл

@@ -1,46 +1,46 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridEditorElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridEditorCustomFieldTest extends MultiBrowserTest {
@Test
public void testCustomFieldWorksInEditorRow() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals("Stockholm", grid.getCell(0, 2).getText());
grid.getCell(0, 1).doubleClick();
GridEditorElement editor = grid.getEditor();
TestBenchElement customField = editor.getField(2);
ComboBoxElement comboBox = customField.$(ComboBoxElement.class).first();
comboBox.selectByText("Oslo");
editor.save();
Assert.assertEquals("Oslo", grid.getCell(0, 2).getText());
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridEditorElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridEditorCustomFieldTest extends MultiBrowserTest {
@Test
public void testCustomFieldWorksInEditorRow() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals("Stockholm", grid.getCell(0, 2).getText());
grid.getCell(0, 1).doubleClick();
GridEditorElement editor = grid.getEditor();
TestBenchElement customField = editor.getField(2);
ComboBoxElement comboBox = customField.$(ComboBoxElement.class).first();
comboBox.selectByText("Oslo");
editor.save();
Assert.assertEquals("Oslo", grid.getCell(0, 2).getText());
}
}

+ 77
- 77
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java Переглянути файл

@@ -1,77 +1,77 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridEditorFrozenColumnsUITest extends MultiBrowserTest {
@Test
public void testEditorWithFrozenColumns() throws IOException {
openTestURL();
openEditor(10);
compareScreen("noscroll");
scrollGridHorizontallyTo(100);
compareScreen("scrolled");
}
private void openEditor(int rowIndex) {
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement cell = grid.getCell(rowIndex, 1);
new Actions(driver).moveToElement(cell).doubleClick().build().perform();
}
private void scrollGridHorizontallyTo(double px) {
executeScript("arguments[0].scrollLeft = " + px,
getGridHorizontalScrollbar());
}
private Object executeScript(String script, WebElement element) {
final WebDriver driver = getDriver();
if (driver instanceof JavascriptExecutor) {
final JavascriptExecutor je = (JavascriptExecutor) driver;
return je.executeScript(script, element);
} else {
throw new IllegalStateException("current driver "
+ getDriver().getClass().getName() + " is not a "
+ JavascriptExecutor.class.getSimpleName());
}
}
private WebElement getGridHorizontalScrollbar() {
return getDriver().findElement(By.xpath(
"//div[contains(@class, \"v-grid-scroller-horizontal\")]"));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridEditorFrozenColumnsUITest extends MultiBrowserTest {
@Test
public void testEditorWithFrozenColumns() throws IOException {
openTestURL();
openEditor(10);
compareScreen("noscroll");
scrollGridHorizontallyTo(100);
compareScreen("scrolled");
}
private void openEditor(int rowIndex) {
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement cell = grid.getCell(rowIndex, 1);
new Actions(driver).moveToElement(cell).doubleClick().build().perform();
}
private void scrollGridHorizontallyTo(double px) {
executeScript("arguments[0].scrollLeft = " + px,
getGridHorizontalScrollbar());
}
private Object executeScript(String script, WebElement element) {
final WebDriver driver = getDriver();
if (driver instanceof JavascriptExecutor) {
final JavascriptExecutor je = (JavascriptExecutor) driver;
return je.executeScript(script, element);
} else {
throw new IllegalStateException("current driver "
+ getDriver().getClass().getName() + " is not a "
+ JavascriptExecutor.class.getSimpleName());
}
}
private WebElement getGridHorizontalScrollbar() {
return getDriver().findElement(By.xpath(
"//div[contains(@class, \"v-grid-scroller-horizontal\")]"));
}
}

+ 96
- 96
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorUITest.java Переглянути файл

@@ -1,96 +1,96 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.elements.PasswordFieldElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridEditorUITest extends MultiBrowserTest {
@Override
public void setup() throws Exception {
super.setup();
setDebug(true);
openTestURL();
}
private void openEditor(int rowIndex) {
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement cell = grid.getCell(rowIndex, 1);
new Actions(driver).moveToElement(cell).doubleClick().build().perform();
}
private void saveEditor() {
findElement(By.cssSelector(".v-grid-editor-save")).click();
}
private GridCellElement getHeaderCell(int rowIndex, int colIndex) {
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement headerCell = grid.getHeaderCell(rowIndex, colIndex);
return headerCell;
}
@Test
public void testEditor() {
assertFalse("Sanity check",
isElementPresent(PasswordFieldElement.class));
openEditor(5);
new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform();
openEditor(10);
assertTrue("Editor should be opened with a password field",
isElementPresent(PasswordFieldElement.class));
assertFalse("Notification was present",
isElementPresent(NotificationElement.class));
}
@Test
public void savingResetsSortingIndicator() {
GridCellElement headerCell = getHeaderCell(0, 0);
headerCell.click();
openEditor(1);
saveEditor();
assertThat(headerCell.getAttribute("class"),
not(containsString("sort-")));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.elements.PasswordFieldElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridEditorUITest extends MultiBrowserTest {
@Override
public void setup() throws Exception {
super.setup();
setDebug(true);
openTestURL();
}
private void openEditor(int rowIndex) {
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement cell = grid.getCell(rowIndex, 1);
new Actions(driver).moveToElement(cell).doubleClick().build().perform();
}
private void saveEditor() {
findElement(By.cssSelector(".v-grid-editor-save")).click();
}
private GridCellElement getHeaderCell(int rowIndex, int colIndex) {
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement headerCell = grid.getHeaderCell(rowIndex, colIndex);
return headerCell;
}
@Test
public void testEditor() {
assertFalse("Sanity check",
isElementPresent(PasswordFieldElement.class));
openEditor(5);
new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform();
openEditor(10);
assertTrue("Editor should be opened with a password field",
isElementPresent(PasswordFieldElement.class));
assertFalse("Notification was present",
isElementPresent(NotificationElement.class));
}
@Test
public void savingResetsSortingIndicator() {
GridCellElement headerCell = getHeaderCell(0, 0);
headerCell.click();
openEditor(1);
saveEditor();
assertThat(headerCell.getAttribute("class"),
not(containsString("sort-")));
}
}

+ 47
- 47
uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java Переглянути файл

@@ -1,47 +1,47 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridExtensionCommunicationTest extends SingleBrowserTest {
@Test
public void testMouseClickIsSentToExtension() {
openTestURL();
GridCellElement cell = $(LegacyGridElement.class).first().getCell(0, 4);
cell.click(5, 5);
int expectedX = cell.getLocation().getX() + 5;
int expectedY = cell.getLocation().getY() + 5;
assertEquals(
"1. Click on Person Nina Brown on column Column[propertyId:gender]",
getLogRow(1));
assertEquals("2. MouseEventDetails: left (" + expectedX + ", "
+ expectedY + ")", getLogRow(0));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridExtensionCommunicationTest extends SingleBrowserTest {
@Test
public void testMouseClickIsSentToExtension() {
openTestURL();
GridCellElement cell = $(LegacyGridElement.class).first().getCell(0, 4);
cell.click(5, 5);
int expectedX = cell.getLocation().getX() + 5;
int expectedY = cell.getLocation().getY() + 5;
assertEquals(
"1. Click on Person Nina Brown on column Column[propertyId:gender]",
getLogRow(1));
assertEquals("2. MouseEventDetails: left (" + expectedX + ", "
+ expectedY + ")", getLogRow(0));
}
}

+ 140
- 140
uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java Переглянути файл

@@ -1,140 +1,140 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridHeaderFooterComponentsTest extends SingleBrowserTest {
@Before
public void setUp() {
setDebug(true);
openTestURL();
}
@Test
public void hideAndShowComponentsInHeader() {
GridElement grid = $(LegacyGridElement.class).first();
int filterRow = 2;
Assert.assertNull(getHeaderElement(grid, filterRow, 1));
Assert.assertNotNull(getHeaderElement(grid, filterRow, 2));
Assert.assertNotNull(getHeaderElement(grid, filterRow, 3));
// Show (1,2)
grid.getHeaderCell(1, 1).$(ButtonElement.class).first().click();
TextFieldElement textfield = getHeaderElement(grid, filterRow, 1);
Assert.assertNotNull(textfield);
Assert.assertEquals("Filter: string", textfield.getValue());
textfield.setValue("foo");
Assert.assertEquals("1. value change for field in string to foo",
getLogRow(0));
assertNoErrorNotifications();
}
private TextFieldElement getHeaderElement(GridElement grid, int row,
int col) {
GridCellElement cell = grid.getHeaderCell(row, col);
List<TextFieldElement> all = cell.$(TextFieldElement.class).all();
if (all.size() == 0) {
return null;
} else if (all.size() == 1) {
return all.get(0);
} else {
throw new RuntimeException(
"Multiple elements found in the header cell at " + row + ","
+ col);
}
}
@Test
public void hideAndShowComponentsInFooter() {
GridElement grid = $(LegacyGridElement.class).first();
int filterRow = 0;
Assert.assertNull(getFooterElement(grid, filterRow, 1));
Assert.assertNotNull(getFooterElement(grid, filterRow, 2));
Assert.assertNotNull(getFooterElement(grid, filterRow, 3));
// Show (1,2)
grid.getFooterCell(1, 1).$(ButtonElement.class).first().click();
TextFieldElement textfield = getFooterElement(grid, filterRow, 1);
Assert.assertNotNull(textfield);
Assert.assertEquals("Filter: string", textfield.getValue());
textfield.setValue("foo");
Assert.assertEquals("1. value change for field in string to foo",
getLogRow(0));
assertNoErrorNotifications();
}
private TextFieldElement getFooterElement(GridElement grid, int row,
int col) {
GridCellElement cell = grid.getFooterCell(row, col);
List<TextFieldElement> all = cell.$(TextFieldElement.class).all();
if (all.size() == 0) {
return null;
} else if (all.size() == 1) {
return all.get(0);
} else {
throw new RuntimeException(
"Multiple elements found in the footer cell at " + row + ","
+ col);
}
}
@Test
public void testRemoveAllHeadersAndFooters() {
openTestURL();
for (int i = 2; i >= 0; --i) {
// Remove Header
$(LegacyGridElement.class).first().getHeaderCell(i, 0)
.$(ButtonElement.class).first().click();
assertFalse("Header " + i + " should not be present.",
$(LegacyGridElement.class).first()
.isElementPresent(By.vaadin("#header[" + i + "]")));
// Remove Footer
$(LegacyGridElement.class).first().getFooterCell(i, 0)
.$(ButtonElement.class).first().click();
assertFalse("Footer " + i + " should not be present.",
$(LegacyGridElement.class).first()
.isElementPresent(By.vaadin("#footer[" + i + "]")));
}
assertNoErrorNotifications();
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridHeaderFooterComponentsTest extends SingleBrowserTest {
@Before
public void setUp() {
setDebug(true);
openTestURL();
}
@Test
public void hideAndShowComponentsInHeader() {
GridElement grid = $(LegacyGridElement.class).first();
int filterRow = 2;
Assert.assertNull(getHeaderElement(grid, filterRow, 1));
Assert.assertNotNull(getHeaderElement(grid, filterRow, 2));
Assert.assertNotNull(getHeaderElement(grid, filterRow, 3));
// Show (1,2)
grid.getHeaderCell(1, 1).$(ButtonElement.class).first().click();
TextFieldElement textfield = getHeaderElement(grid, filterRow, 1);
Assert.assertNotNull(textfield);
Assert.assertEquals("Filter: string", textfield.getValue());
textfield.setValue("foo");
Assert.assertEquals("1. value change for field in string to foo",
getLogRow(0));
assertNoErrorNotifications();
}
private TextFieldElement getHeaderElement(GridElement grid, int row,
int col) {
GridCellElement cell = grid.getHeaderCell(row, col);
List<TextFieldElement> all = cell.$(TextFieldElement.class).all();
if (all.size() == 0) {
return null;
} else if (all.size() == 1) {
return all.get(0);
} else {
throw new RuntimeException(
"Multiple elements found in the header cell at " + row + ","
+ col);
}
}
@Test
public void hideAndShowComponentsInFooter() {
GridElement grid = $(LegacyGridElement.class).first();
int filterRow = 0;
Assert.assertNull(getFooterElement(grid, filterRow, 1));
Assert.assertNotNull(getFooterElement(grid, filterRow, 2));
Assert.assertNotNull(getFooterElement(grid, filterRow, 3));
// Show (1,2)
grid.getFooterCell(1, 1).$(ButtonElement.class).first().click();
TextFieldElement textfield = getFooterElement(grid, filterRow, 1);
Assert.assertNotNull(textfield);
Assert.assertEquals("Filter: string", textfield.getValue());
textfield.setValue("foo");
Assert.assertEquals("1. value change for field in string to foo",
getLogRow(0));
assertNoErrorNotifications();
}
private TextFieldElement getFooterElement(GridElement grid, int row,
int col) {
GridCellElement cell = grid.getFooterCell(row, col);
List<TextFieldElement> all = cell.$(TextFieldElement.class).all();
if (all.size() == 0) {
return null;
} else if (all.size() == 1) {
return all.get(0);
} else {
throw new RuntimeException(
"Multiple elements found in the footer cell at " + row + ","
+ col);
}
}
@Test
public void testRemoveAllHeadersAndFooters() {
openTestURL();
for (int i = 2; i >= 0; --i) {
// Remove Header
$(LegacyGridElement.class).first().getHeaderCell(i, 0)
.$(ButtonElement.class).first().click();
assertFalse("Header " + i + " should not be present.",
$(LegacyGridElement.class).first()
.isElementPresent(By.vaadin("#header[" + i + "]")));
// Remove Footer
$(LegacyGridElement.class).first().getFooterCell(i, 0)
.$(ButtonElement.class).first().click();
assertFalse("Footer " + i + " should not be present.",
$(LegacyGridElement.class).first()
.isElementPresent(By.vaadin("#footer[" + i + "]")));
}
assertNoErrorNotifications();
}
}

+ 151
- 151
uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java Переглянути файл

@@ -1,151 +1,151 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridHeaderFormatChangeTest extends MultiBrowserTest {
@Test
public void testHeaderRetainsSelectAllForColumnRemoval() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Assert that we do not have the select all checkbox
Assert.assertTrue(
"Found input in header even though none should exist.",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Set grid into multiselection mode
toggleSelectionMode();
// Assert that we now have a select all checkbox in the header
Assert.assertFalse("Expected one input field in header",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Hide the firstName column from the grid.
toggleFirstName();
// Assert that we still have the select all checkbox in the header.
Assert.assertFalse("Header was missing checkbox after hiding column",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Show the firstName column.
toggleFirstName();
// Assert that we still have the select all checkbox in the header.
Assert.assertFalse(
"Header was missing checkbox after bringing back column",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
}
@Test
public void testHeaderRetainsSelectAllForJoinColumnAdd() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Assert that we do not have the select all checkbox
Assert.assertTrue(
"Found input in header even though none should exist.",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Set grid into multiselection mode
toggleSelectionMode();
// Assert that we now have a select all checkbox in the header
Assert.assertFalse("Expected one input field in header",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Add Join columns header
toggleJoin();
// Assert that we still have the select all checkbox in the header.
Assert.assertFalse("Header was missing checkbox after hiding column",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// remove Join Columns header
toggleJoin();
// Assert that we still have the select all checkbox in the header.
Assert.assertFalse(
"Header was missing checkbox after bringing back column",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
}
@Test
public void selectAllShouldKeepState() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Assert that we do not have the select all checkbox
Assert.assertTrue(
"Found input in header even though none should exist.",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Set grid into multiselection mode
toggleSelectionMode();
// Assert that we now have a select all checkbox in the header
Assert.assertFalse("Should not be selected after adding",
grid.getHeader().findElement(By.tagName("input")).isSelected());
grid.getHeader().findElement(By.tagName("input")).click();
// Assert that checkbox is checked
assertSelectAllChecked(
"Not selected even though we just clicked selection", grid);
// Hide the firstName column from the grid.
toggleFirstName();
// Assert that checkbox is still checked
assertSelectAllChecked("Selection disappeared after removing column",
grid);
// Show the firstName column.
toggleFirstName();
// Assert that checkbox is still checked
assertSelectAllChecked("Selection disappeared after adding column",
grid);
}
private void assertSelectAllChecked(String message, GridElement grid) {
Assert.assertTrue(message,
grid.getHeader().findElement(By.tagName("input")).isSelected());
}
private void toggleSelectionMode() {
$(ButtonElement.class).id("selection_mode").click();
}
private void toggleFirstName() {
$(ButtonElement.class).id("show_hide").click();
}
private void toggleJoin() {
$(ButtonElement.class).id("join").click();
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridHeaderFormatChangeTest extends MultiBrowserTest {
@Test
public void testHeaderRetainsSelectAllForColumnRemoval() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Assert that we do not have the select all checkbox
Assert.assertTrue(
"Found input in header even though none should exist.",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Set grid into multiselection mode
toggleSelectionMode();
// Assert that we now have a select all checkbox in the header
Assert.assertFalse("Expected one input field in header",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Hide the firstName column from the grid.
toggleFirstName();
// Assert that we still have the select all checkbox in the header.
Assert.assertFalse("Header was missing checkbox after hiding column",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Show the firstName column.
toggleFirstName();
// Assert that we still have the select all checkbox in the header.
Assert.assertFalse(
"Header was missing checkbox after bringing back column",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
}
@Test
public void testHeaderRetainsSelectAllForJoinColumnAdd() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Assert that we do not have the select all checkbox
Assert.assertTrue(
"Found input in header even though none should exist.",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Set grid into multiselection mode
toggleSelectionMode();
// Assert that we now have a select all checkbox in the header
Assert.assertFalse("Expected one input field in header",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Add Join columns header
toggleJoin();
// Assert that we still have the select all checkbox in the header.
Assert.assertFalse("Header was missing checkbox after hiding column",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// remove Join Columns header
toggleJoin();
// Assert that we still have the select all checkbox in the header.
Assert.assertFalse(
"Header was missing checkbox after bringing back column",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
}
@Test
public void selectAllShouldKeepState() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Assert that we do not have the select all checkbox
Assert.assertTrue(
"Found input in header even though none should exist.",
grid.getHeader().findElements(By.tagName("input")).isEmpty());
// Set grid into multiselection mode
toggleSelectionMode();
// Assert that we now have a select all checkbox in the header
Assert.assertFalse("Should not be selected after adding",
grid.getHeader().findElement(By.tagName("input")).isSelected());
grid.getHeader().findElement(By.tagName("input")).click();
// Assert that checkbox is checked
assertSelectAllChecked(
"Not selected even though we just clicked selection", grid);
// Hide the firstName column from the grid.
toggleFirstName();
// Assert that checkbox is still checked
assertSelectAllChecked("Selection disappeared after removing column",
grid);
// Show the firstName column.
toggleFirstName();
// Assert that checkbox is still checked
assertSelectAllChecked("Selection disappeared after adding column",
grid);
}
private void assertSelectAllChecked(String message, GridElement grid) {
Assert.assertTrue(message,
grid.getHeader().findElement(By.tagName("input")).isSelected());
}
private void toggleSelectionMode() {
$(ButtonElement.class).id("selection_mode").click();
}
private void toggleFirstName() {
$(ButtonElement.class).id("show_hide").click();
}
private void toggleJoin() {
$(ButtonElement.class).id("join").click();
}
}

+ 174
- 174
uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java Переглянути файл

@@ -1,174 +1,174 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridHeaderStyleNamesTest extends SingleBrowserTest {
private GridElement grid;
@Before
public void findGridCells() {
openTestURL();
grid = $(LegacyGridElement.class).first();
}
private GridCellElement getMergedHeaderCell() {
return grid.getHeaderCell(0, 3);
}
private WebElement getMergedHeaderCellContent() {
return getMergedHeaderCell().findElement(
By.cssSelector("div.v-grid-column-header-content"));
}
private GridCellElement getAgeFooterCell() {
return grid.getFooterCell(0, 2);
}
private WebElement getAgeFooterCellContent() {
return getAgeFooterCell().findElement(
By.cssSelector("div.v-grid-column-footer-content"));
}
@Test
public void cellStyleNamesCanBeAddedAndRemoved() {
ButtonElement toggleStyles = $(ButtonElement.class)
.caption("Toggle styles").first();
assertStylesSet(true);
toggleStyles.click();
assertStylesSet(false);
toggleStyles.click();
assertStylesSet(true);
}
@Test
public void rowStyleNamesCanBeAddedAndRemoved() {
ButtonElement toggleStyles = $(ButtonElement.class)
.caption("Toggle styles").first();
assertRowStylesSet(true);
toggleStyles.click();
assertRowStylesSet(false);
toggleStyles.click();
assertRowStylesSet(true);
}
private void assertStylesSet(boolean set) {
if (set) {
assertHasStyleName(
"Footer cell should have the assigned 'age-footer' class name",
getAgeFooterCell(), "age-footer");
assertHasStyleName(
"Header cell should have the assigned 'age' class name",
getAgeHeaderCell(), "age");
assertHasStyleName(
"The merged header cell should have the assigned 'city-country' class name",
getMergedHeaderCell(), "city-country");
} else {
assertHasNotStyleName(
"Footer cell should not have the removed 'age-footer' class name",
getAgeFooterCell(), "age-footer");
assertHasNotStyleName(
"Header cell should not have the removed 'age' class name",
getAgeHeaderCell(), "age");
assertHasNotStyleName(
"Ther merged header cell should not have the removed 'city-country' class name",
getMergedHeaderCell(), "city-country");
}
assertHasStyleName(
"The default v-grid-cell style name should not be removed from the header cell",
getAgeHeaderCell(), "v-grid-cell");
assertHasStyleName(
"The default v-grid-cell style name should not be removed from the footer cell",
getAgeFooterCell(), "v-grid-cell");
assertHasStyleName(
"The default v-grid-cell style name should not be removed from the merged header cell",
getMergedHeaderCell(), "v-grid-cell");
}
private void assertRowStylesSet(boolean set) {
if (set) {
assertHasStyleName(
"Footer row should have the assigned 'custom-row' class name",
getFooterRow(), "custom-row");
assertHasStyleName(
"Header row should have the assigned 'custom-row' class name",
getHeaderRow(), "custom-row");
} else {
assertHasNotStyleName(
"Footer row should not have the removed 'custom-row' class name",
getFooterRow(), "custom-row");
assertHasNotStyleName(
"Header row should not have the removed 'custom-row' class name",
getHeaderRow(), "custom-row");
}
assertHasStyleName(
"The default v-grid-row style name should not be removed from the header row",
getHeaderRow(), "v-grid-row");
assertHasStyleName(
"The default v-grid-row style name should not be removed from the footer row",
getFooterRow(), "v-grid-row");
}
private WebElement getAgeHeaderCell() {
return grid.getHeaderCell(1, 2);
}
private WebElement getAgeHeaderCellContent() {
return getAgeHeaderCell().findElement(
By.cssSelector("div.v-grid-column-header-content"));
}
private WebElement getFooterRow() {
return grid.getFooterRow(0);
}
private WebElement getHeaderRow() {
return grid.getHeaderRow(0);
}
private void assertHasStyleName(String message, WebElement element,
String stylename) {
if (!hasCssClass(element, stylename)) {
Assert.fail(message);
}
}
private void assertHasNotStyleName(String message, WebElement element,
String stylename) {
if (hasCssClass(element, stylename)) {
Assert.fail(message);
}
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridHeaderStyleNamesTest extends SingleBrowserTest {
private GridElement grid;
@Before
public void findGridCells() {
openTestURL();
grid = $(LegacyGridElement.class).first();
}
private GridCellElement getMergedHeaderCell() {
return grid.getHeaderCell(0, 3);
}
private WebElement getMergedHeaderCellContent() {
return getMergedHeaderCell().findElement(
By.cssSelector("div.v-grid-column-header-content"));
}
private GridCellElement getAgeFooterCell() {
return grid.getFooterCell(0, 2);
}
private WebElement getAgeFooterCellContent() {
return getAgeFooterCell().findElement(
By.cssSelector("div.v-grid-column-footer-content"));
}
@Test
public void cellStyleNamesCanBeAddedAndRemoved() {
ButtonElement toggleStyles = $(ButtonElement.class)
.caption("Toggle styles").first();
assertStylesSet(true);
toggleStyles.click();
assertStylesSet(false);
toggleStyles.click();
assertStylesSet(true);
}
@Test
public void rowStyleNamesCanBeAddedAndRemoved() {
ButtonElement toggleStyles = $(ButtonElement.class)
.caption("Toggle styles").first();
assertRowStylesSet(true);
toggleStyles.click();
assertRowStylesSet(false);
toggleStyles.click();
assertRowStylesSet(true);
}
private void assertStylesSet(boolean set) {
if (set) {
assertHasStyleName(
"Footer cell should have the assigned 'age-footer' class name",
getAgeFooterCell(), "age-footer");
assertHasStyleName(
"Header cell should have the assigned 'age' class name",
getAgeHeaderCell(), "age");
assertHasStyleName(
"The merged header cell should have the assigned 'city-country' class name",
getMergedHeaderCell(), "city-country");
} else {
assertHasNotStyleName(
"Footer cell should not have the removed 'age-footer' class name",
getAgeFooterCell(), "age-footer");
assertHasNotStyleName(
"Header cell should not have the removed 'age' class name",
getAgeHeaderCell(), "age");
assertHasNotStyleName(
"Ther merged header cell should not have the removed 'city-country' class name",
getMergedHeaderCell(), "city-country");
}
assertHasStyleName(
"The default v-grid-cell style name should not be removed from the header cell",
getAgeHeaderCell(), "v-grid-cell");
assertHasStyleName(
"The default v-grid-cell style name should not be removed from the footer cell",
getAgeFooterCell(), "v-grid-cell");
assertHasStyleName(
"The default v-grid-cell style name should not be removed from the merged header cell",
getMergedHeaderCell(), "v-grid-cell");
}
private void assertRowStylesSet(boolean set) {
if (set) {
assertHasStyleName(
"Footer row should have the assigned 'custom-row' class name",
getFooterRow(), "custom-row");
assertHasStyleName(
"Header row should have the assigned 'custom-row' class name",
getHeaderRow(), "custom-row");
} else {
assertHasNotStyleName(
"Footer row should not have the removed 'custom-row' class name",
getFooterRow(), "custom-row");
assertHasNotStyleName(
"Header row should not have the removed 'custom-row' class name",
getHeaderRow(), "custom-row");
}
assertHasStyleName(
"The default v-grid-row style name should not be removed from the header row",
getHeaderRow(), "v-grid-row");
assertHasStyleName(
"The default v-grid-row style name should not be removed from the footer row",
getFooterRow(), "v-grid-row");
}
private WebElement getAgeHeaderCell() {
return grid.getHeaderCell(1, 2);
}
private WebElement getAgeHeaderCellContent() {
return getAgeHeaderCell().findElement(
By.cssSelector("div.v-grid-column-header-content"));
}
private WebElement getFooterRow() {
return grid.getFooterRow(0);
}
private WebElement getHeaderRow() {
return grid.getHeaderRow(0);
}
private void assertHasStyleName(String message, WebElement element,
String stylename) {
if (!hasCssClass(element, stylename)) {
Assert.fail(message);
}
}
private void assertHasNotStyleName(String message, WebElement element,
String stylename) {
if (hasCssClass(element, stylename)) {
Assert.fail(message);
}
}
}

+ 48
- 48
uitest/src/test/java/com/vaadin/tests/components/grid/GridInWindowResizeTest.java Переглянути файл

@@ -1,48 +1,48 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.Collections;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.Browser;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridInWindowResizeTest extends MultiBrowserTest {
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
// Must test on a browser with animations
return Collections
.singletonList(Browser.CHROME.getDesiredCapabilities());
}
@Test
public void resizeWindow() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
int col1WidthBefore = grid.getCell(0, 0).getSize().getWidth();
$(ButtonElement.class).caption("resize").first().click();
int col1WidthAfter = grid.getCell(0, 0).getSize().getWidth();
Assert.assertTrue(col1WidthAfter < col1WidthBefore);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.Collections;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.Browser;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridInWindowResizeTest extends MultiBrowserTest {
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
// Must test on a browser with animations
return Collections
.singletonList(Browser.CHROME.getDesiredCapabilities());
}
@Test
public void resizeWindow() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
int col1WidthBefore = grid.getCell(0, 0).getSize().getWidth();
$(ButtonElement.class).caption("resize").first().click();
int col1WidthAfter = grid.getCell(0, 0).getSize().getWidth();
Assert.assertTrue(col1WidthAfter < col1WidthBefore);
}
}

+ 84
- 84
uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java Переглянути файл

@@ -1,84 +1,84 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridInitiallyHiddenColumnsTest extends SingleBrowserTest {
@Test
public void ensureCorrectlyRendered() {
openTestURL("debug");
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals("Rowling", grid.getCell(0, 0).getText());
Assert.assertEquals("Scott", grid.getCell(1, 0).getText());
getSidebarOpenButton(grid).click();
getColumnHidingToggle(grid, "First Name").click();
getColumnHidingToggle(grid, "Age").click();
getSidebarOpenButton(grid).click();
Assert.assertEquals("Umberto", grid.getCell(0, 0).getText());
Assert.assertEquals("Rowling", grid.getCell(0, 1).getText());
Assert.assertEquals("25", grid.getCell(0, 2).getText());
Assert.assertEquals("Dan", grid.getCell(1, 0).getText());
Assert.assertEquals("Scott", grid.getCell(1, 1).getText());
Assert.assertEquals("54", grid.getCell(1, 2).getText());
}
// TODO: as to the getX methods reuse ones from GridBasicFeaturesTest?
protected WebElement getSidebarOpenButton(GridElement grid) {
List<WebElement> elements = grid
.findElements(By.className("v-grid-sidebar-button"));
return elements.isEmpty() ? null : elements.get(0);
}
/**
* Returns the toggle inside the sidebar for hiding the column at the given
* index, or null if not found.
*/
protected WebElement getColumnHidingToggle(GridElement grid,
String caption) {
WebElement sidebar = getSidebar(grid);
List<WebElement> elements = sidebar
.findElements(By.className("column-hiding-toggle"));
for (WebElement e : elements) {
if (caption.equalsIgnoreCase(e.getText())) {
return e;
}
}
return null;
}
protected WebElement getSidebar(GridElement grid) {
List<WebElement> elements = findElements(
By.className("v-grid-sidebar-popup"));
return elements.isEmpty() ? null : elements.get(0);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class GridInitiallyHiddenColumnsTest extends SingleBrowserTest {
@Test
public void ensureCorrectlyRendered() {
openTestURL("debug");
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals("Rowling", grid.getCell(0, 0).getText());
Assert.assertEquals("Scott", grid.getCell(1, 0).getText());
getSidebarOpenButton(grid).click();
getColumnHidingToggle(grid, "First Name").click();
getColumnHidingToggle(grid, "Age").click();
getSidebarOpenButton(grid).click();
Assert.assertEquals("Umberto", grid.getCell(0, 0).getText());
Assert.assertEquals("Rowling", grid.getCell(0, 1).getText());
Assert.assertEquals("25", grid.getCell(0, 2).getText());
Assert.assertEquals("Dan", grid.getCell(1, 0).getText());
Assert.assertEquals("Scott", grid.getCell(1, 1).getText());
Assert.assertEquals("54", grid.getCell(1, 2).getText());
}
// TODO: as to the getX methods reuse ones from GridBasicFeaturesTest?
protected WebElement getSidebarOpenButton(GridElement grid) {
List<WebElement> elements = grid
.findElements(By.className("v-grid-sidebar-button"));
return elements.isEmpty() ? null : elements.get(0);
}
/**
* Returns the toggle inside the sidebar for hiding the column at the given
* index, or null if not found.
*/
protected WebElement getColumnHidingToggle(GridElement grid,
String caption) {
WebElement sidebar = getSidebar(grid);
List<WebElement> elements = sidebar
.findElements(By.className("column-hiding-toggle"));
for (WebElement e : elements) {
if (caption.equalsIgnoreCase(e.getText())) {
return e;
}
}
return null;
}
protected WebElement getSidebar(GridElement grid) {
List<WebElement> elements = findElements(
By.className("v-grid-sidebar-popup"));
return elements.isEmpty() ? null : elements.get(0);
}
}

+ 48
- 48
uitest/src/test/java/com/vaadin/tests/components/grid/GridItemSetChangeTest.java Переглянути файл

@@ -1,48 +1,48 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridItemSetChangeTest extends SingleBrowserTest {
@Test
public void testValueChangeListenersWorkAfterItemSetChange() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertEquals("Last name initially wrong", "Bar",
grid.getCell(0, 1).getText());
$(ButtonElement.class).caption("Modify").first().click();
assertEquals("Last name was not updated", "Spam",
grid.getCell(0, 1).getText());
$(ButtonElement.class).caption("Reset").first().click();
assertEquals("Last name was not updated on reset", "Baz",
grid.getCell(0, 1).getText());
$(ButtonElement.class).caption("Modify").first().click();
assertEquals("Last name was not updated after reset modification",
"Spam", grid.getCell(0, 1).getText());
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridItemSetChangeTest extends SingleBrowserTest {
@Test
public void testValueChangeListenersWorkAfterItemSetChange() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertEquals("Last name initially wrong", "Bar",
grid.getCell(0, 1).getText());
$(ButtonElement.class).caption("Modify").first().click();
assertEquals("Last name was not updated", "Spam",
grid.getCell(0, 1).getText());
$(ButtonElement.class).caption("Reset").first().click();
assertEquals("Last name was not updated on reset", "Baz",
grid.getCell(0, 1).getText());
$(ButtonElement.class).caption("Modify").first().click();
assertEquals("Last name was not updated after reset modification",
"Spam", grid.getCell(0, 1).getText());
}
}

+ 65
- 65
uitest/src/test/java/com/vaadin/tests/components/grid/GridLayoutDetailsRowTest.java Переглянути файл

@@ -1,65 +1,65 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.number.IsCloseTo.closeTo;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridLayoutElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* Tests that details row displays GridLayout contents properly.
*
* @author Vaadin Ltd
*/
@TestCategory("grid")
public class GridLayoutDetailsRowTest extends MultiBrowserTest {
@Test
public void testLabelHeights() {
openTestURL();
waitForElementPresent(By.className("v-grid"));
GridElement grid = $(LegacyGridElement.class).first();
grid.getRow(2).click(5, 5);
waitForElementPresent(By.id("lbl2"));
GridLayoutElement gridLayout = $(GridLayoutElement.class).first();
int gridLayoutHeight = gridLayout.getSize().height;
// height should be divided equally
double expectedHeight = gridLayoutHeight / 4;
assertLabelHeight("lbl1", expectedHeight);
assertLabelHeight("lbl2", expectedHeight);
assertLabelHeight("lbl3", expectedHeight);
assertLabelHeight("lbl4", expectedHeight);
}
private void assertLabelHeight(String id, double expectedHeight) {
// 1px leeway for calculations
assertThat("Unexpected label height.",
(double) $(LabelElement.class).id(id).getSize().height,
closeTo(expectedHeight, 1d));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.number.IsCloseTo.closeTo;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridLayoutElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* Tests that details row displays GridLayout contents properly.
*
* @author Vaadin Ltd
*/
@TestCategory("grid")
public class GridLayoutDetailsRowTest extends MultiBrowserTest {
@Test
public void testLabelHeights() {
openTestURL();
waitForElementPresent(By.className("v-grid"));
GridElement grid = $(LegacyGridElement.class).first();
grid.getRow(2).click(5, 5);
waitForElementPresent(By.id("lbl2"));
GridLayoutElement gridLayout = $(GridLayoutElement.class).first();
int gridLayoutHeight = gridLayout.getSize().height;
// height should be divided equally
double expectedHeight = gridLayoutHeight / 4;
assertLabelHeight("lbl1", expectedHeight);
assertLabelHeight("lbl2", expectedHeight);
assertLabelHeight("lbl3", expectedHeight);
assertLabelHeight("lbl4", expectedHeight);
}
private void assertLabelHeight(String id, double expectedHeight) {
// 1px leeway for calculations
assertThat("Unexpected label height.",
(double) $(LabelElement.class).id(id).getSize().height,
closeTo(expectedHeight, 1d));
}
}

+ 49
- 49
uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java Переглянути файл

@@ -1,49 +1,49 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridMultiSelectionOnInitTest extends MultiBrowserTest {
@Test
public void testSelectAllCheckBoxExists() {
openTestURL();
assertTrue("The select all checkbox was missing.",
$(LegacyGridElement.class).first().getHeaderCell(0, 0)
.isElementPresent(By.tagName("input")));
}
@Test
public void testSetSelectedUpdatesClient() {
openTestURL();
assertFalse("Rows should not be selected initially.",
$(LegacyGridElement.class).first().getRow(0).isSelected());
$(ButtonElement.class).first().click();
assertTrue("Rows should be selected after button click.",
$(LegacyGridElement.class).first().getRow(0).isSelected());
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridMultiSelectionOnInitTest extends MultiBrowserTest {
@Test
public void testSelectAllCheckBoxExists() {
openTestURL();
assertTrue("The select all checkbox was missing.",
$(LegacyGridElement.class).first().getHeaderCell(0, 0)
.isElementPresent(By.tagName("input")));
}
@Test
public void testSetSelectedUpdatesClient() {
openTestURL();
assertFalse("Rows should not be selected initially.",
$(LegacyGridElement.class).first().getRow(0).isSelected());
$(ButtonElement.class).first().click();
assertTrue("Rows should be selected after button click.",
$(LegacyGridElement.class).first().getRow(0).isSelected());
}
}

+ 43
- 43
uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionScrollBarTest.java Переглянути файл

@@ -1,43 +1,43 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridMultiSelectionScrollBarTest extends MultiBrowserTest {
@Test
public void testNoVisibleScrollBar() throws IOException {
setDebug(true);
openTestURL();
assertTrue("Horizontal scrollbar should not be visible.",
$(LegacyGridElement.class).first().getHorizontalScroller()
.getAttribute("style").toLowerCase()
.contains("display: none;"));
// Just to make sure nothing odd happened.
assertNoErrorNotifications();
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridMultiSelectionScrollBarTest extends MultiBrowserTest {
@Test
public void testNoVisibleScrollBar() throws IOException {
setDebug(true);
openTestURL();
assertTrue("Horizontal scrollbar should not be visible.",
$(LegacyGridElement.class).first().getHorizontalScroller()
.getAttribute("style").toLowerCase()
.contains("display: none;"));
// Just to make sure nothing odd happened.
assertNoErrorNotifications();
}
}

+ 58
- 58
uitest/src/test/java/com/vaadin/tests/components/grid/GridRendererChangeTest.java Переглянути файл

@@ -1,59 +1,59 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridRendererChangeTest extends MultiBrowserTest {
@Test
public void testChangeRenderer() {
setDebug(true);
openTestURL();
GridCellElement cell = $(LegacyGridElement.class).first().getCell(0, 0);
assertTrue("No button in the first cell.",
cell.isElementPresent(By.tagName("button")));
int width = cell.getSize().getWidth();
List<ButtonElement> buttons = $(ButtonElement.class).all();
Collections.reverse(buttons);
// Order: TextRenderer, HTMLRenderer, ButtonRenderer
for (ButtonElement button : buttons) {
button.click();
assertNoErrorNotifications();
cell = $(LegacyGridElement.class).first().getCell(0, 0);
assertEquals("Cell size changed", width, cell.getSize().getWidth());
}
assertTrue("No button in the first cell.",
cell.isElementPresent(By.tagName("button")));
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridRendererChangeTest extends MultiBrowserTest {
@Test
public void testChangeRenderer() {
setDebug(true);
openTestURL();
GridCellElement cell = $(LegacyGridElement.class).first().getCell(0, 0);
assertTrue("No button in the first cell.",
cell.isElementPresent(By.tagName("button")));
int width = cell.getSize().getWidth();
List<ButtonElement> buttons = $(ButtonElement.class).all();
Collections.reverse(buttons);
// Order: TextRenderer, HTMLRenderer, ButtonRenderer
for (ButtonElement button : buttons) {
button.click();
assertNoErrorNotifications();
cell = $(LegacyGridElement.class).first().getCell(0, 0);
assertEquals("Cell size changed", width, cell.getSize().getWidth());
}
assertTrue("No button in the first cell.",
cell.isElementPresent(By.tagName("button")));
}
}

+ 39
- 39
uitest/src/test/java/com/vaadin/tests/components/grid/GridReplaceContainerTest.java Переглянути файл

@@ -1,39 +1,39 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridReplaceContainerTest extends SingleBrowserTest {
@Test
public void selectAfterContainerChange() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
grid.getCell(0, 0).click();
Assert.assertTrue(grid.getRow(0).isSelected());
$(ButtonElement.class).first().click();
Assert.assertFalse(grid.getRow(0).isSelected());
grid.getCell(0, 0).click();
Assert.assertTrue(grid.getRow(0).isSelected());
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridReplaceContainerTest extends SingleBrowserTest {
@Test
public void selectAfterContainerChange() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
grid.getCell(0, 0).click();
Assert.assertTrue(grid.getRow(0).isSelected());
$(ButtonElement.class).first().click();
Assert.assertFalse(grid.getRow(0).isSelected());
grid.getCell(0, 0).click();
Assert.assertTrue(grid.getRow(0).isSelected());
}
}

+ 45
- 45
uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java Переглянути файл

@@ -1,45 +1,45 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridResizeAndScrollTest extends MultiBrowserTest {
@Test
public void scrollAndClick() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
grid.scrollToRow(49);
// select a row (click on checkbox)
grid.getCell(49, 0).click();
// verify rows are what they should be
GridCellElement cell = grid.getCell(33, 1);
String textBefore = cell.getText();
cell.click();
Assert.assertEquals("String contents changed on click", textBefore,
cell.getText());
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridResizeAndScrollTest extends MultiBrowserTest {
@Test
public void scrollAndClick() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
grid.scrollToRow(49);
// select a row (click on checkbox)
grid.getCell(49, 0).click();
// verify rows are what they should be
GridCellElement cell = grid.getCell(33, 1);
String textBefore = cell.getText();
cell.click();
Assert.assertEquals("String contents changed on click", textBefore,
cell.getText());
}
}

+ 116
- 116
uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java Переглянути файл

@@ -1,116 +1,116 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridResizeHiddenColumnTest extends MultiBrowserTest {
@Before
public void before() {
openTestURL();
}
@Test
public void testDragResizeHiddenColumnSize() {
GridElement grid = $(LegacyGridElement.class).first();
Actions action = new Actions(getDriver());
// Check if column 'Gender' hidden
List<GridCellElement> headerCells = grid.getHeaderCells(0);
Assert.assertEquals("There should be two visible columns", 2,
headerCells.size());
Assert.assertFalse("Gender column should be hidden",
containsText("Gender", headerCells));
// Resize first column
int dragOffset = -100;
int headerCellWidth = headerCells.get(0).getSize().getWidth();
dragResizeColumn(headerCells.get(0), 1, dragOffset);
// When dragging the resizer on IE8, the final offset will be smaller
// (might be an issue with the feature that doesn't start resizing until
// the cursor moved a few pixels)
double delta = BrowserUtil.isIE8(getDesiredCapabilities()) ? 5d : 0;
Assert.assertEquals(
"Column width should've changed by " + dragOffset + "px",
headerCellWidth + dragOffset,
headerCells.get(0).getSize().getWidth(), delta);
// Make column 'Gender' visible
WebElement menuButton = grid.findElement(By.className("v-contextmenu"))
.findElement(By.tagName("button"));
action.click(menuButton).perform(); // Click on menu button
WebElement sidebarPopup = findElement(
By.className("v-grid-sidebar-popup"));
WebElement visibilityToggle = findElementByText("Gender",
sidebarPopup.findElements(By.className("gwt-MenuItem")));
action.click(visibilityToggle).perform(); // Click on 'Gender' menu item
// Check if column 'Gender' is visible
headerCells = grid.getHeaderCells(0);
Assert.assertEquals("There should be three visible columns", 3,
headerCells.size());
Assert.assertTrue("Gender column should be visible",
containsText("Gender", headerCells));
// Check if column 'Gender' has expanded width
int widthSum = 0;
for (GridCellElement e : headerCells) {
widthSum += e.getSize().getWidth();
}
Assert.assertEquals("Gender column should take up the remaining space",
grid.getHeader().getSize().getWidth(), widthSum, 1d);
}
private WebElement findElementByText(String text,
List<? extends WebElement> elements) {
for (WebElement e : elements) {
if (text.equalsIgnoreCase(e.getText())) {
return e;
}
}
return null;
}
private boolean containsText(String text,
List<? extends WebElement> elements) {
return !(findElementByText(text, elements) == null);
}
private void dragResizeColumn(GridCellElement headerCell, int posX,
int offset) {
Dimension size = headerCell.getSize();
new Actions(getDriver())
.moveToElement(headerCell, size.getWidth() + posX,
size.getHeight() / 2)
.clickAndHold().moveByOffset(offset, 0).release().perform();
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridResizeHiddenColumnTest extends MultiBrowserTest {
@Before
public void before() {
openTestURL();
}
@Test
public void testDragResizeHiddenColumnSize() {
GridElement grid = $(LegacyGridElement.class).first();
Actions action = new Actions(getDriver());
// Check if column 'Gender' hidden
List<GridCellElement> headerCells = grid.getHeaderCells(0);
Assert.assertEquals("There should be two visible columns", 2,
headerCells.size());
Assert.assertFalse("Gender column should be hidden",
containsText("Gender", headerCells));
// Resize first column
int dragOffset = -100;
int headerCellWidth = headerCells.get(0).getSize().getWidth();
dragResizeColumn(headerCells.get(0), 1, dragOffset);
// When dragging the resizer on IE8, the final offset will be smaller
// (might be an issue with the feature that doesn't start resizing until
// the cursor moved a few pixels)
double delta = BrowserUtil.isIE8(getDesiredCapabilities()) ? 5d : 0;
Assert.assertEquals(
"Column width should've changed by " + dragOffset + "px",
headerCellWidth + dragOffset,
headerCells.get(0).getSize().getWidth(), delta);
// Make column 'Gender' visible
WebElement menuButton = grid.findElement(By.className("v-contextmenu"))
.findElement(By.tagName("button"));
action.click(menuButton).perform(); // Click on menu button
WebElement sidebarPopup = findElement(
By.className("v-grid-sidebar-popup"));
WebElement visibilityToggle = findElementByText("Gender",
sidebarPopup.findElements(By.className("gwt-MenuItem")));
action.click(visibilityToggle).perform(); // Click on 'Gender' menu item
// Check if column 'Gender' is visible
headerCells = grid.getHeaderCells(0);
Assert.assertEquals("There should be three visible columns", 3,
headerCells.size());
Assert.assertTrue("Gender column should be visible",
containsText("Gender", headerCells));
// Check if column 'Gender' has expanded width
int widthSum = 0;
for (GridCellElement e : headerCells) {
widthSum += e.getSize().getWidth();
}
Assert.assertEquals("Gender column should take up the remaining space",
grid.getHeader().getSize().getWidth(), widthSum, 1d);
}
private WebElement findElementByText(String text,
List<? extends WebElement> elements) {
for (WebElement e : elements) {
if (text.equalsIgnoreCase(e.getText())) {
return e;
}
}
return null;
}
private boolean containsText(String text,
List<? extends WebElement> elements) {
return !(findElementByText(text, elements) == null);
}
private void dragResizeColumn(GridCellElement headerCell, int posX,
int offset) {
Dimension size = headerCell.getSize();
new Actions(getDriver())
.moveToElement(headerCell, size.getWidth() + posX,
size.getHeight() / 2)
.clickAndHold().moveByOffset(offset, 0).release().perform();
}
}

+ 48
- 48
uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizingTest.java Переглянути файл

@@ -1,49 +1,49 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridScrollToLineWhileResizingTest extends MultiBrowserTest {
@Test
public void testScrollToLineWorksWhileMovingSplitProgrammatically() {
openTestURL();
$(LegacyGridElement.class).first().getCell(21, 0).click();
List<WebElement> cells = findElements(By.className("v-grid-cell"));
boolean foundCell21 = false;
for (WebElement cell : cells) {
if ("cell21".equals(cell.getText())) {
foundCell21 = true;
}
}
assertTrue(foundCell21);
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridScrollToLineWhileResizingTest extends MultiBrowserTest {
@Test
public void testScrollToLineWorksWhileMovingSplitProgrammatically() {
openTestURL();
$(LegacyGridElement.class).first().getCell(21, 0).click();
List<WebElement> cells = findElements(By.className("v-grid-cell"));
boolean foundCell21 = false;
for (WebElement cell : cells) {
if ("cell21".equals(cell.getText())) {
foundCell21 = true;
}
}
assertTrue(foundCell21);
}
}

+ 36
- 36
uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllCellTest.java Переглянути файл

@@ -1,37 +1,37 @@
package com.vaadin.tests.components.grid;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridSelectAllCellTest extends MultiBrowserTest {
@Override
public void setup() throws Exception {
super.setup();
openTestURL();
}
@Test
public void selectAllCellCanBeClicked() throws IOException {
GridElement.GridCellElement selectAllCell = $(LegacyGridElement.class).first()
.getHeaderCell(0, 0);
new Actions(getDriver()).moveToElement(selectAllCell, 2, 2).click()
.perform();
WebElement selectAllCheckbox = selectAllCell
.findElement(By.cssSelector("input"));
assertThat(selectAllCheckbox.isSelected(), is(true));
}
package com.vaadin.tests.components.grid;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridSelectAllCellTest extends MultiBrowserTest {
@Override
public void setup() throws Exception {
super.setup();
openTestURL();
}
@Test
public void selectAllCellCanBeClicked() throws IOException {
GridElement.GridCellElement selectAllCell = $(LegacyGridElement.class).first()
.getHeaderCell(0, 0);
new Actions(getDriver()).moveToElement(selectAllCell, 2, 2).click()
.perform();
WebElement selectAllCheckbox = selectAllCell
.findElement(By.cssSelector("input"));
assertThat(selectAllCheckbox.isSelected(), is(true));
}
}

+ 87
- 87
uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java Переглянути файл

@@ -1,87 +1,87 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridSidebarPositionTest extends MultiBrowserTest {
@Test
public void heightRestrictedToBrowserWindow() {
openTestURL();
GridElement gridWithVeryManyColumns = $(LegacyGridElement.class)
.id(GridSidebarPosition.POPUP_WINDOW_HEIGHT);
getSidebarOpenButton(gridWithVeryManyColumns).click();
Dimension popupSize = getSidebarPopup().getSize();
Dimension browserWindowSize = getDriver().manage().window().getSize();
Assert.assertTrue(
popupSize.getHeight() <= browserWindowSize.getHeight());
}
@Test
public void popupNotBelowBrowserWindow() {
openTestURL();
GridElement gridAtBottom = $(LegacyGridElement.class)
.id(GridSidebarPosition.POPUP_WINDOW_MOVED_UP);
getSidebarOpenButton(gridAtBottom).click();
WebElement sidebarPopup = getSidebarPopup();
Dimension popupSize = sidebarPopup.getSize();
Point popupLocation = sidebarPopup.getLocation();
int popupBottom = popupLocation.getY() + popupSize.getHeight();
Dimension browserWindowSize = getDriver().manage().window().getSize();
Assert.assertTrue(popupBottom <= browserWindowSize.getHeight());
}
@Test
public void popupAbove() {
openTestURL();
GridElement gridPopupAbove = $(LegacyGridElement.class)
.id(GridSidebarPosition.POPUP_ABOVE);
WebElement sidebarOpenButton = getSidebarOpenButton(gridPopupAbove);
sidebarOpenButton.click();
WebElement sidebarPopup = getSidebarPopup();
Dimension popupSize = sidebarPopup.getSize();
Point popupLocation = sidebarPopup.getLocation();
int popupBottom = popupLocation.getY() + popupSize.getHeight();
int sideBarButtonTop = sidebarOpenButton.getLocation().getY();
Assert.assertTrue(popupBottom <= sideBarButtonTop);
}
protected WebElement getSidebarOpenButton(GridElement grid) {
List<WebElement> elements = grid
.findElements(By.className("v-grid-sidebar-button"));
return elements.isEmpty() ? null : elements.get(0);
}
protected WebElement getSidebarPopup() {
List<WebElement> elements = findElements(
By.className("v-grid-sidebar-popup"));
return elements.isEmpty() ? null : elements.get(0);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridSidebarPositionTest extends MultiBrowserTest {
@Test
public void heightRestrictedToBrowserWindow() {
openTestURL();
GridElement gridWithVeryManyColumns = $(LegacyGridElement.class)
.id(GridSidebarPosition.POPUP_WINDOW_HEIGHT);
getSidebarOpenButton(gridWithVeryManyColumns).click();
Dimension popupSize = getSidebarPopup().getSize();
Dimension browserWindowSize = getDriver().manage().window().getSize();
Assert.assertTrue(
popupSize.getHeight() <= browserWindowSize.getHeight());
}
@Test
public void popupNotBelowBrowserWindow() {
openTestURL();
GridElement gridAtBottom = $(LegacyGridElement.class)
.id(GridSidebarPosition.POPUP_WINDOW_MOVED_UP);
getSidebarOpenButton(gridAtBottom).click();
WebElement sidebarPopup = getSidebarPopup();
Dimension popupSize = sidebarPopup.getSize();
Point popupLocation = sidebarPopup.getLocation();
int popupBottom = popupLocation.getY() + popupSize.getHeight();
Dimension browserWindowSize = getDriver().manage().window().getSize();
Assert.assertTrue(popupBottom <= browserWindowSize.getHeight());
}
@Test
public void popupAbove() {
openTestURL();
GridElement gridPopupAbove = $(LegacyGridElement.class)
.id(GridSidebarPosition.POPUP_ABOVE);
WebElement sidebarOpenButton = getSidebarOpenButton(gridPopupAbove);
sidebarOpenButton.click();
WebElement sidebarPopup = getSidebarPopup();
Dimension popupSize = sidebarPopup.getSize();
Point popupLocation = sidebarPopup.getLocation();
int popupBottom = popupLocation.getY() + popupSize.getHeight();
int sideBarButtonTop = sidebarOpenButton.getLocation().getY();
Assert.assertTrue(popupBottom <= sideBarButtonTop);
}
protected WebElement getSidebarOpenButton(GridElement grid) {
List<WebElement> elements = grid
.findElements(By.className("v-grid-sidebar-button"));
return elements.isEmpty() ? null : elements.get(0);
}
protected WebElement getSidebarPopup() {
List<WebElement> elements = findElements(
By.className("v-grid-sidebar-popup"));
return elements.isEmpty() ? null : elements.get(0);
}
}

+ 47
- 47
uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java Переглянути файл

@@ -1,47 +1,47 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridSingleColumnTest extends MultiBrowserTest {
@Test
public void testHeaderIsVisible() {
openTestURL();
GridCellElement cell = $(LegacyGridElement.class).first().getHeaderCell(0, 0);
Assert.assertTrue("No header available",
cell.getText().equalsIgnoreCase("header"));
}
@Test
public void testScrollDidNotThrow() {
setDebug(true);
openTestURL();
Assert.assertFalse("Exception when scrolling on init",
isElementPresent(NotificationElement.class));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridSingleColumnTest extends MultiBrowserTest {
@Test
public void testHeaderIsVisible() {
openTestURL();
GridCellElement cell = $(LegacyGridElement.class).first().getHeaderCell(0, 0);
Assert.assertTrue("No header available",
cell.getText().equalsIgnoreCase("header"));
}
@Test
public void testScrollDidNotThrow() {
setDebug(true);
openTestURL();
Assert.assertFalse("Exception when scrolling on init",
isElementPresent(NotificationElement.class));
}
}

+ 52
- 52
uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java Переглянути файл

@@ -1,53 +1,53 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridSortIndicatorTest extends MultiBrowserTest {
@Test
public void testIndicators() throws InterruptedException {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Clicking the left header cell should set ascending sort order for
// both columns.
grid.getHeaderCell(0, 0).click();
assertTrue(grid.getHeaderCell(0, 0).getAttribute("class")
.contains("sort-asc"));
assertTrue(grid.getHeaderCell(0, 1).getAttribute("class")
.contains("sort-asc"));
// Click the left column to change the sort direction.
grid.getHeaderCell(0, 0).click();
assertTrue(grid.getHeaderCell(0, 0).getAttribute("class")
.contains("sort-desc"));
assertTrue(grid.getHeaderCell(0, 1).getAttribute("class")
.contains("sort-desc"));
// Clicking on the right column should have no effect.
grid.getHeaderCell(0, 1).click();
assertTrue(grid.getHeaderCell(0, 0).getAttribute("class")
.contains("sort-desc"));
assertTrue(grid.getHeaderCell(0, 1).getAttribute("class")
.contains("sort-desc"));
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridSortIndicatorTest extends MultiBrowserTest {
@Test
public void testIndicators() throws InterruptedException {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Clicking the left header cell should set ascending sort order for
// both columns.
grid.getHeaderCell(0, 0).click();
assertTrue(grid.getHeaderCell(0, 0).getAttribute("class")
.contains("sort-asc"));
assertTrue(grid.getHeaderCell(0, 1).getAttribute("class")
.contains("sort-asc"));
// Click the left column to change the sort direction.
grid.getHeaderCell(0, 0).click();
assertTrue(grid.getHeaderCell(0, 0).getAttribute("class")
.contains("sort-desc"));
assertTrue(grid.getHeaderCell(0, 1).getAttribute("class")
.contains("sort-desc"));
// Clicking on the right column should have no effect.
grid.getHeaderCell(0, 1).click();
assertTrue(grid.getHeaderCell(0, 0).getAttribute("class")
.contains("sort-desc"));
assertTrue(grid.getHeaderCell(0, 1).getAttribute("class")
.contains("sort-desc"));
}
}

+ 57
- 57
uitest/src/test/java/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java Переглянути файл

@@ -1,57 +1,57 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridRowElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridSubPixelProblemWrappingTest extends MultiBrowserTest {
@Test
public void addedRowShouldNotWrap() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Cells in first row should be at the same y coordinate as the row
assertRowAndCellTops(grid, 0);
// Add a row
$(ButtonElement.class).first().click();
// Cells in the first row should be at the same y coordinate as the row
assertRowAndCellTops(grid, 0);
// Cells in the second row should be at the same y coordinate as the row
assertRowAndCellTops(grid, 1);
}
private void assertRowAndCellTops(GridElement grid, int rowIndex) {
GridRowElement row = grid.getRow(rowIndex);
int rowTop = row.getLocation().y;
int cell0Top = grid.getCell(rowIndex, 0).getLocation().y;
int cell1Top = grid.getCell(rowIndex, 1).getLocation().y;
Assert.assertEquals(rowTop, cell0Top);
Assert.assertEquals(rowTop, cell1Top);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridRowElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridSubPixelProblemWrappingTest extends MultiBrowserTest {
@Test
public void addedRowShouldNotWrap() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
// Cells in first row should be at the same y coordinate as the row
assertRowAndCellTops(grid, 0);
// Add a row
$(ButtonElement.class).first().click();
// Cells in the first row should be at the same y coordinate as the row
assertRowAndCellTops(grid, 0);
// Cells in the second row should be at the same y coordinate as the row
assertRowAndCellTops(grid, 1);
}
private void assertRowAndCellTops(GridElement grid, int rowIndex) {
GridRowElement row = grid.getRow(rowIndex);
int rowTop = row.getLocation().y;
int cell0Top = grid.getCell(rowIndex, 0).getLocation().y;
int cell1Top = grid.getCell(rowIndex, 1).getLocation().y;
Assert.assertEquals(rowTop, cell0Top);
Assert.assertEquals(rowTop, cell1Top);
}
}

+ 86
- 86
uitest/src/test/java/com/vaadin/tests/components/grid/GridSwitchRenderersTest.java Переглянути файл

@@ -1,86 +1,86 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridSwitchRenderersTest extends MultiBrowserTest {
@Test
public void testRendererSwitch() {
// The UI should start with TEXT rendering in the second column
// Clicking the checkbox will toggle rendering to HTML mode
// Clicking it again should return TEXT rendering mode.
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertTrue(
"Initial rendering of column 1 is not unformatted text",
cellTextIsUnformatted(grid.getCell(0, 1).getText()));
// NOTE: must click at 5,5 because of Valo and rendering in Chrome
// This is a TestBench bug that may be fixed sometime in the future
CheckBoxElement cb = $(CheckBoxElement.class).first();
cb.click(5, 5);
Assert.assertTrue(
"Column 1 data has not been rendered with HTMLRenderer after renderer swap",
cellTextIsHTMLFormatted(grid.getCell(0, 1).getText()));
cb.click(5, 5);
Assert.assertTrue(
"Column 1 data has not been re-rendered as text after renderer swap",
cellTextIsUnformatted(grid.getCell(0, 1).getText()));
}
/**
* Attempts to match a string to a string like {@code <b>(4, 1)</b>}.
*
* @param cellText
* input string
* @return true if input string is formatted like a raw HTML string
*/
private boolean cellTextIsUnformatted(String cellText) {
String regex = "<b>\\(\\d+, \\d+\\)</b>";
return cellText.matches(regex);
}
/**
* Attempts to match a string to a string like {@code (4, 1)}, i.e. the HTML
* formatted version of the above (the bold tags should be consumed by the
* renderer).
*
* @param cellText
* input string
* @return true if input string is formatted like plain text (i.e. HTML bits
* have been consumed by renderer)
*/
private boolean cellTextIsHTMLFormatted(String cellText) {
String regex = "\\(\\d+, \\d+\\)";
return cellText.matches(regex);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridSwitchRenderersTest extends MultiBrowserTest {
@Test
public void testRendererSwitch() {
// The UI should start with TEXT rendering in the second column
// Clicking the checkbox will toggle rendering to HTML mode
// Clicking it again should return TEXT rendering mode.
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertTrue(
"Initial rendering of column 1 is not unformatted text",
cellTextIsUnformatted(grid.getCell(0, 1).getText()));
// NOTE: must click at 5,5 because of Valo and rendering in Chrome
// This is a TestBench bug that may be fixed sometime in the future
CheckBoxElement cb = $(CheckBoxElement.class).first();
cb.click(5, 5);
Assert.assertTrue(
"Column 1 data has not been rendered with HTMLRenderer after renderer swap",
cellTextIsHTMLFormatted(grid.getCell(0, 1).getText()));
cb.click(5, 5);
Assert.assertTrue(
"Column 1 data has not been re-rendered as text after renderer swap",
cellTextIsUnformatted(grid.getCell(0, 1).getText()));
}
/**
* Attempts to match a string to a string like {@code <b>(4, 1)</b>}.
*
* @param cellText
* input string
* @return true if input string is formatted like a raw HTML string
*/
private boolean cellTextIsUnformatted(String cellText) {
String regex = "<b>\\(\\d+, \\d+\\)</b>";
return cellText.matches(regex);
}
/**
* Attempts to match a string to a string like {@code (4, 1)}, i.e. the HTML
* formatted version of the above (the bold tags should be consumed by the
* renderer).
*
* @param cellText
* input string
* @return true if input string is formatted like plain text (i.e. HTML bits
* have been consumed by renderer)
*/
private boolean cellTextIsHTMLFormatted(String cellText) {
String regex = "\\(\\d+, \\d+\\)";
return cellText.matches(regex);
}
}

+ 54
- 54
uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeChangeTest.java Переглянути файл

@@ -1,54 +1,54 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridThemeChangeTest extends MultiBrowserTest {
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
// Seems like stylesheet onload is not fired on PhantomJS
// https://github.com/ariya/phantomjs/issues/12332
return super.getBrowsersExcludingPhantomJS();
}
@Test
public void testThemeChange() {
openTestURL("debug");
GridElement grid = $(LegacyGridElement.class).first();
int reindeerHeight = grid.getRow(0).getSize().getHeight();
grid.getCell(0, 0).click();
grid = $(LegacyGridElement.class).first();
int valoHeight = grid.getRow(0).getSize().getHeight();
Assert.assertTrue(
"Row height should increase when changing from Reindeer to Valo",
valoHeight > reindeerHeight);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridThemeChangeTest extends MultiBrowserTest {
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
// Seems like stylesheet onload is not fired on PhantomJS
// https://github.com/ariya/phantomjs/issues/12332
return super.getBrowsersExcludingPhantomJS();
}
@Test
public void testThemeChange() {
openTestURL("debug");
GridElement grid = $(LegacyGridElement.class).first();
int reindeerHeight = grid.getRow(0).getSize().getHeight();
grid.getCell(0, 0).click();
grid = $(LegacyGridElement.class).first();
int valoHeight = grid.getRow(0).getSize().getHeight();
Assert.assertTrue(
"Row height should increase when changing from Reindeer to Valo",
valoHeight > reindeerHeight);
}
}

+ 110
- 110
uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeUITest.java Переглянути файл

@@ -1,110 +1,110 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.GridElement.GridEditorElement;
import com.vaadin.testbench.elements.NativeSelectElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.legacyelements.LegacyDateFieldElement;
import com.vaadin.tests.tb3.MultiBrowserThemeTest;
@TestCategory("grid")
public class GridThemeUITest extends MultiBrowserThemeTest {
private GridElement grid;
@Test
public void grid() throws Exception {
openTestURL();
selectPage("Editor");
compareScreen("basic");
}
@Test
public void headerAndFooter() throws Exception {
openTestURL();
selectPage("HeaderFooter");
compareScreen("basic");
grid.getHeaderCell(0, 6).$(ButtonElement.class).first().click();
compareScreen("additional-header");
grid.getHeaderCell(2, 1).click();
compareScreen("sorted-last-name");
grid.getHeaderCell(2, 4).click();
compareScreen("sorted-age");
}
@Test
public void editor() throws Exception {
openTestURL();
selectPage("Editor");
GridCellElement ritaBirthdate = grid.getCell(2, 3);
// Open editor row
openEditor(ritaBirthdate);
compareScreen("initial");
GridEditorElement editor = grid.getEditor();
LegacyDateFieldElement dateField = editor
.$(LegacyDateFieldElement.class).first();
WebElement input = dateField.findElement(By.xpath("input"));
input.sendKeys("Invalid", Keys.TAB);
editor.save();
compareScreen("one-invalid");
TextFieldElement age = editor.$(TextFieldElement.class).caption("Age")
.first();
age.sendKeys("abc", Keys.TAB);
editor.save();
compareScreen("two-invalid");
}
private void openEditor(GridCellElement targetCell) {
new Actions(getDriver()).doubleClick(targetCell).perform();
try {
if (grid.getEditor().isDisplayed()) {
return;
}
} catch (Exception e) {
}
// Try again if IE happen to fail..
new Actions(getDriver()).doubleClick(targetCell).perform();
}
/**
* @since
* @param string
*/
private void selectPage(String string) {
$(NativeSelectElement.class).id("page").selectByText(string);
grid = $(LegacyGridElement.class).first();
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.GridElement.GridEditorElement;
import com.vaadin.testbench.elements.NativeSelectElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.legacyelements.LegacyDateFieldElement;
import com.vaadin.tests.tb3.MultiBrowserThemeTest;
@TestCategory("grid")
public class GridThemeUITest extends MultiBrowserThemeTest {
private GridElement grid;
@Test
public void grid() throws Exception {
openTestURL();
selectPage("Editor");
compareScreen("basic");
}
@Test
public void headerAndFooter() throws Exception {
openTestURL();
selectPage("HeaderFooter");
compareScreen("basic");
grid.getHeaderCell(0, 6).$(ButtonElement.class).first().click();
compareScreen("additional-header");
grid.getHeaderCell(2, 1).click();
compareScreen("sorted-last-name");
grid.getHeaderCell(2, 4).click();
compareScreen("sorted-age");
}
@Test
public void editor() throws Exception {
openTestURL();
selectPage("Editor");
GridCellElement ritaBirthdate = grid.getCell(2, 3);
// Open editor row
openEditor(ritaBirthdate);
compareScreen("initial");
GridEditorElement editor = grid.getEditor();
LegacyDateFieldElement dateField = editor
.$(LegacyDateFieldElement.class).first();
WebElement input = dateField.findElement(By.xpath("input"));
input.sendKeys("Invalid", Keys.TAB);
editor.save();
compareScreen("one-invalid");
TextFieldElement age = editor.$(TextFieldElement.class).caption("Age")
.first();
age.sendKeys("abc", Keys.TAB);
editor.save();
compareScreen("two-invalid");
}
private void openEditor(GridCellElement targetCell) {
new Actions(getDriver()).doubleClick(targetCell).perform();
try {
if (grid.getEditor().isDisplayed()) {
return;
}
} catch (Exception e) {
}
// Try again if IE happen to fail..
new Actions(getDriver()).doubleClick(targetCell).perform();
}
/**
* @since
* @param string
*/
private void selectPage(String string) {
$(NativeSelectElement.class).id("page").selectByText(string);
grid = $(LegacyGridElement.class).first();
}
}

+ 70
- 70
uitest/src/test/java/com/vaadin/tests/components/grid/GridWidthIncreaseTest.java Переглянути файл

@@ -1,70 +1,70 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridWidthIncreaseTest extends MultiBrowserTest {
private static int INCREASE_COUNT = 3;
@Test
public void testColumnsExpandWithGrid() throws IOException {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
double accuracy = 1.0d;
DesiredCapabilities cap = getDesiredCapabilities();
if (BrowserUtil.isIE(cap, 8) || BrowserUtil.isIE(cap, 9)
|| BrowserUtil.isPhantomJS(cap)) {
accuracy = 2.0d;
}
for (int i = 0; i < INCREASE_COUNT; ++i) {
$(ButtonElement.class).first().click();
int prevWidth = 0;
for (int c = 0; c < GridWidthIncrease.COLUMN_COUNT; ++c) {
int width = grid.getCell(0, c).getSize().getWidth();
if (c > 0) {
// check that columns are roughly the same width.
assertEquals("Difference in column widths", prevWidth,
width, accuracy);
}
prevWidth = width;
}
/*
* Column widths should be the same as table wrapper size. Since
* Selenium doesn't support subpixels correctly, we use a rough
* estimation.
*/
assertEquals(grid.getRow(0).getSize().getWidth(),
grid.getTableWrapper().getSize().getWidth(), accuracy);
}
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class GridWidthIncreaseTest extends MultiBrowserTest {
private static int INCREASE_COUNT = 3;
@Test
public void testColumnsExpandWithGrid() throws IOException {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
double accuracy = 1.0d;
DesiredCapabilities cap = getDesiredCapabilities();
if (BrowserUtil.isIE(cap, 8) || BrowserUtil.isIE(cap, 9)
|| BrowserUtil.isPhantomJS(cap)) {
accuracy = 2.0d;
}
for (int i = 0; i < INCREASE_COUNT; ++i) {
$(ButtonElement.class).first().click();
int prevWidth = 0;
for (int c = 0; c < GridWidthIncrease.COLUMN_COUNT; ++c) {
int width = grid.getCell(0, c).getSize().getWidth();
if (c > 0) {
// check that columns are roughly the same width.
assertEquals("Difference in column widths", prevWidth,
width, accuracy);
}
prevWidth = width;
}
/*
* Column widths should be the same as table wrapper size. Since
* Selenium doesn't support subpixels correctly, we use a rough
* estimation.
*/
assertEquals(grid.getRow(0).getSize().getWidth(),
grid.getTableWrapper().getSize().getWidth(), accuracy);
}
}
}

+ 41
- 41
uitest/src/test/java/com/vaadin/tests/components/grid/GridWithBrokenRendererTest.java Переглянути файл

@@ -1,41 +1,41 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridWithBrokenRendererTest extends SingleBrowserTest {
@Test
public void ensureRendered() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertRow(grid, 0, "FI", "", "Finland");
assertRow(grid, 1, "SE", "", "Sweden");
}
private void assertRow(GridElement grid, int row, String... texts) {
for (int column = 0; column < texts.length; column++) {
Assert.assertEquals("Cell " + row + "," + column, texts[column],
grid.getCell(row, column).getText());
}
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridWithBrokenRendererTest extends SingleBrowserTest {
@Test
public void ensureRendered() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
assertRow(grid, 0, "FI", "", "Finland");
assertRow(grid, 1, "SE", "", "Sweden");
}
private void assertRow(GridElement grid, int row, String... texts) {
for (int column = 0; column < texts.length; column++) {
Assert.assertEquals("Cell " + row + "," + column, texts[column],
grid.getCell(row, column).getText());
}
}
}

+ 37
- 37
uitest/src/test/java/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java Переглянути файл

@@ -1,37 +1,37 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridWithLabelEditorTest extends SingleBrowserTest {
@Test
public void testNoExceptionOnEdit() {
setDebug(true);
openTestURL();
assertNoErrorNotifications();
assertEquals("LabelEditor content not correct.", "FooFoo",
$(LegacyGridElement.class).first().getEditor().getField(0).getText());
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class GridWithLabelEditorTest extends SingleBrowserTest {
@Test
public void testNoExceptionOnEdit() {
setDebug(true);
openTestURL();
assertNoErrorNotifications();
assertEquals("LabelEditor content not correct.", "FooFoo",
$(LegacyGridElement.class).first().getEditor().getField(0).getText());
}
}

+ 42
- 42
uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java Переглянути файл

@@ -1,42 +1,42 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class InitialFrozenColumnsTest extends MultiBrowserTest {
@Test
public void testInitialFrozenColumns() {
setDebug(true);
openTestURL();
Assert.assertFalse("Notification was present",
isElementPresent(NotificationElement.class));
WebElement cell = $(LegacyGridElement.class).first().getCell(0, 0);
assertTrue(cell.getAttribute("class").contains("frozen"));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class InitialFrozenColumnsTest extends MultiBrowserTest {
@Test
public void testInitialFrozenColumns() {
setDebug(true);
openTestURL();
Assert.assertFalse("Notification was present",
isElementPresent(NotificationElement.class));
WebElement cell = $(LegacyGridElement.class).first().getCell(0, 0);
assertTrue(cell.getAttribute("class").contains("frozen"));
}
}

+ 52
- 52
uitest/src/test/java/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java Переглянути файл

@@ -1,52 +1,52 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class JavaScriptRenderersTest extends MultiBrowserTest {
@Test
public void testJavaScriptRenderer() {
setDebug(true);
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement cell_1_1 = grid.getCell(1, 1);
GridCellElement cell_2_2 = grid.getCell(2, 2);
// Verify render functionality
Assert.assertEquals("Bean(2, 0)", cell_1_1.getText());
Assert.assertEquals("string2", cell_2_2.getText());
// Verify init functionality
Assert.assertEquals("1", cell_1_1.getAttribute("column"));
// Verify onbrowserevent
cell_1_1.click();
Assert.assertTrue(
cell_1_1.getText().startsWith("Clicked 1 with key 2 at"));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class JavaScriptRenderersTest extends MultiBrowserTest {
@Test
public void testJavaScriptRenderer() {
setDebug(true);
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
GridCellElement cell_1_1 = grid.getCell(1, 1);
GridCellElement cell_2_2 = grid.getCell(2, 2);
// Verify render functionality
Assert.assertEquals("Bean(2, 0)", cell_1_1.getText());
Assert.assertEquals("string2", cell_2_2.getText());
// Verify init functionality
Assert.assertEquals("1", cell_1_1.getAttribute("column"));
// Verify onbrowserevent
cell_1_1.click();
Assert.assertTrue(
cell_1_1.getText().startsWith("Clicked 1 with key 2 at"));
}
}

+ 49
- 49
uitest/src/test/java/com/vaadin/tests/components/grid/NullHeadersTest.java Переглянути файл

@@ -1,49 +1,49 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class NullHeadersTest extends SingleBrowserTest {
@Test
public void gridWithNullHeadersShouldBeRendered() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals(1, grid.getHeaderCount());
Assert.assertEquals(3, grid.getHeaderCells(0).size());
for (int i = 0; i < 3; i++) {
Assert.assertEquals("", grid.getHeaderCell(0, 0).getText());
}
assertRow(grid, 0, "Finland", "foo", "1");
assertRow(grid, 1, "Swaziland", "bar", "2");
assertRow(grid, 2, "Japan", "baz", "3");
}
private void assertRow(GridElement grid, int row, String... contents) {
for (int col = 0; col < contents.length; col++) {
Assert.assertEquals(contents[col],
grid.getCell(row, col).getText());
}
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class NullHeadersTest extends SingleBrowserTest {
@Test
public void gridWithNullHeadersShouldBeRendered() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals(1, grid.getHeaderCount());
Assert.assertEquals(3, grid.getHeaderCells(0).size());
for (int i = 0; i < 3; i++) {
Assert.assertEquals("", grid.getHeaderCell(0, 0).getText());
}
assertRow(grid, 0, "Finland", "foo", "1");
assertRow(grid, 1, "Swaziland", "bar", "2");
assertRow(grid, 2, "Japan", "baz", "3");
}
private void assertRow(GridElement grid, int row, String... contents) {
for (int col = 0; col < contents.length; col++) {
Assert.assertEquals(contents[col],
grid.getCell(row, col).getText());
}
}
}

+ 65
- 65
uitest/src/test/java/com/vaadin/tests/components/grid/NullRenderersTest.java Переглянути файл

@@ -1,65 +1,65 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.assertEquals;
@TestCategory("grid")
public class NullRenderersTest extends MultiBrowserTest {
@Test
public void testDefaults() throws Exception {
openTestURL();
GridElement grid = findGridWithDefaults();
assertEquals("-- No Text --", grid.getCell(0, 0).getText());
assertEquals("-- No Jokes --", grid.getCell(0, 1).getText());
assertEquals("-- Never --", grid.getCell(0, 2).getText());
assertEquals("-- Nothing --", grid.getCell(0, 3).getText());
assertEquals("-- No Control --", grid.getCell(0, 5).getText());
}
@Test
public void testNoDefaults() throws Exception {
openTestURL();
GridElement grid = findGridNoDefaults();
assertEquals("", grid.getCell(0, 0).getText());
assertEquals("", grid.getCell(0, 1).getText());
assertEquals("", grid.getCell(0, 2).getText());
assertEquals("", grid.getCell(0, 3).getText());
assertEquals("", grid.getCell(0, 5).getText());
}
private GridElement findGridWithDefaults() {
return $(LegacyGridElement.class).id("test-grid-defaults");
}
private GridElement findGridNoDefaults() {
return $(LegacyGridElement.class).id("test-grid");
}
private LabelElement findDebugLabel() {
return $(LabelElement.class).id(CustomRenderer.DEBUG_LABEL_ID);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.assertEquals;
@TestCategory("grid")
public class NullRenderersTest extends MultiBrowserTest {
@Test
public void testDefaults() throws Exception {
openTestURL();
GridElement grid = findGridWithDefaults();
assertEquals("-- No Text --", grid.getCell(0, 0).getText());
assertEquals("-- No Jokes --", grid.getCell(0, 1).getText());
assertEquals("-- Never --", grid.getCell(0, 2).getText());
assertEquals("-- Nothing --", grid.getCell(0, 3).getText());
assertEquals("-- No Control --", grid.getCell(0, 5).getText());
}
@Test
public void testNoDefaults() throws Exception {
openTestURL();
GridElement grid = findGridNoDefaults();
assertEquals("", grid.getCell(0, 0).getText());
assertEquals("", grid.getCell(0, 1).getText());
assertEquals("", grid.getCell(0, 2).getText());
assertEquals("", grid.getCell(0, 3).getText());
assertEquals("", grid.getCell(0, 5).getText());
}
private GridElement findGridWithDefaults() {
return $(LegacyGridElement.class).id("test-grid-defaults");
}
private GridElement findGridNoDefaults() {
return $(LegacyGridElement.class).id("test-grid");
}
private LabelElement findDebugLabel() {
return $(LabelElement.class).id(CustomRenderer.DEBUG_LABEL_ID);
}
}

+ 63
- 63
uitest/src/test/java/com/vaadin/tests/components/grid/ProgrammaticEditorControlTest.java Переглянути файл

@@ -1,64 +1,64 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class ProgrammaticEditorControlTest extends SingleBrowserTest {
@Test
public void multipleOpenFromServerSide() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
ButtonElement editButton = $(ButtonElement.class).caption("Edit")
.first();
ButtonElement cancelButton = $(ButtonElement.class).caption("Cancel")
.first();
editButton.click();
assertEditorFieldContents(grid, "test");
cancelButton.click();
assertEditorNotPresent(grid);
editButton.click();
assertEditorFieldContents(grid, "test");
}
private void assertEditorFieldContents(GridElement grid, String text) {
TextFieldElement editorField = wrap(TextFieldElement.class,
grid.getEditor().getField(0));
Assert.assertEquals(text, editorField.getValue());
}
private void assertEditorNotPresent(GridElement grid) {
try {
grid.getEditor();
Assert.fail("Editor should not be present");
} catch (Exception e) {
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class ProgrammaticEditorControlTest extends SingleBrowserTest {
@Test
public void multipleOpenFromServerSide() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
ButtonElement editButton = $(ButtonElement.class).caption("Edit")
.first();
ButtonElement cancelButton = $(ButtonElement.class).caption("Cancel")
.first();
editButton.click();
assertEditorFieldContents(grid, "test");
cancelButton.click();
assertEditorNotPresent(grid);
editButton.click();
assertEditorFieldContents(grid, "test");
}
private void assertEditorFieldContents(GridElement grid, String text) {
TextFieldElement editorField = wrap(TextFieldElement.class,
grid.getEditor().getField(0));
Assert.assertEquals(text, editorField.getValue());
}
private void assertEditorNotPresent(GridElement grid) {
try {
grid.getEditor();
Assert.fail("Editor should not be present");
} catch (Exception e) {
}
}
}

+ 37
- 37
uitest/src/test/java/com/vaadin/tests/components/grid/SelectDuringInitTest.java Переглянути файл

@@ -1,37 +1,37 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class SelectDuringInitTest extends SingleBrowserTest {
@Test
public void testSelectDuringInit() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertTrue(grid.getRow(1).isSelected());
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.SingleBrowserTest;
@TestCategory("grid")
public class SelectDuringInitTest extends SingleBrowserTest {
@Test
public void testSelectDuringInit() {
openTestURL();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertTrue(grid.getRow(1).isSelected());
}
}

+ 51
- 51
uitest/src/test/java/com/vaadin/tests/components/grid/SortableHeaderStylesTest.java Переглянути файл

@@ -1,51 +1,51 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.OptionGroupElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class SortableHeaderStylesTest extends SingleBrowserTest {
@Test
public void testSortableHeaderStyles() {
openTestURL();
Assert.assertFalse(hasSortableStyle(0));
for (int i = 1; i < 8; i++) {
Assert.assertTrue(hasSortableStyle(i));
}
OptionGroupElement sortableSelector = $(OptionGroupElement.class)
.first();
// Toggle sortability
sortableSelector.selectByText("lastName");
Assert.assertFalse(hasSortableStyle(3));
// Toggle back
sortableSelector.selectByText("lastName");
Assert.assertTrue(hasSortableStyle(3));
}
private boolean hasSortableStyle(int column) {
return $(LegacyGridElement.class).first().getHeaderCell(0, column)
.getAttribute("class").contains("sortable");
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.OptionGroupElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class SortableHeaderStylesTest extends SingleBrowserTest {
@Test
public void testSortableHeaderStyles() {
openTestURL();
Assert.assertFalse(hasSortableStyle(0));
for (int i = 1; i < 8; i++) {
Assert.assertTrue(hasSortableStyle(i));
}
OptionGroupElement sortableSelector = $(OptionGroupElement.class)
.first();
// Toggle sortability
sortableSelector.selectByText("lastName");
Assert.assertFalse(hasSortableStyle(3));
// Toggle back
sortableSelector.selectByText("lastName");
Assert.assertTrue(hasSortableStyle(3));
}
private boolean hasSortableStyle(int column) {
return $(LegacyGridElement.class).first().getHeaderCell(0, column)
.getAttribute("class").contains("sortable");
}
}

+ 167
- 167
uitest/src/test/java/com/vaadin/tests/components/grid/WidgetRenderersTest.java Переглянути файл

@@ -1,167 +1,167 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* TB tests for the various builtin widget-based renderers.
*
* @since
* @author Vaadin Ltd
*/
@TestCategory("grid")
public class WidgetRenderersTest extends MultiBrowserTest {
@Override
public void setup() throws Exception {
super.setup();
openTestURL();
}
@Test
public void testProgressBarRenderer() {
assertTrue(getGridCell(0, 0)
.isElementPresent(By.className("v-progressbar")));
}
@Test
public void testButtonRenderer() {
WebElement button = getGridCell(0, 1)
.findElement(By.className("v-nativebutton"));
button.click();
waitUntilTextUpdated(button, "Clicked!");
}
@Test
public void testButtonRendererAfterCellBeingFocused() {
GridCellElement buttonCell = getGridCell(0, 1);
assertFalse("cell should not be focused before focusing",
buttonCell.isFocused());
// avoid clicking on the button
buttonCell.click(buttonCell.getSize().getWidth() - 10, 5);
assertTrue("cell should be focused after focusing",
buttonCell.isFocused());
WebElement button = buttonCell
.findElement(By.className("v-nativebutton"));
assertNotEquals("Button should not be clicked before click", "Clicked!",
button.getText());
new Actions(getDriver()).moveToElement(button).click().perform();
waitUntilTextUpdated(button, "Clicked!");
}
@Test
public void testImageRenderer() {
final WebElement image = getGridCell(0, 2)
.findElement(By.className("gwt-Image"));
waitUntilmageSrcEndsWith(image, "window/img/close.png");
image.click();
waitUntilmageSrcEndsWith(image, "window/img/maximize.png");
}
private void waitUntilmageSrcEndsWith(final WebElement image,
final String expectedText) {
waitUntil(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver input) {
return image.getAttribute("src").endsWith(expectedText);
}
@Override
public String toString() {
// Timed out after 10 seconds waiting for ...
return String.format(
"image source to update. Supposed to end with '%s' (was: '%s').",
expectedText, image.getAttribute("src"));
}
});
}
@Test
public void testColumnReorder() {
$(ButtonElement.class).caption("Change column order").first().click();
assertFalse("Notification was present",
isElementPresent(NotificationElement.class));
assertTrue(
getGridCell(0, 0).isElementPresent(By.className("gwt-Image")));
assertTrue(getGridCell(0, 1)
.isElementPresent(By.className("v-progressbar")));
assertTrue(getGridCell(0, 2)
.isElementPresent(By.className("v-nativebutton")));
}
@Test
public void testPropertyIdInEvent() {
WebElement button = getGridCell(0, 3)
.findElement(By.className("v-nativebutton"));
button.click();
waitUntilTextUpdated(button, WidgetRenderers.PROPERTY_ID);
}
GridCellElement getGridCell(int row, int col) {
return $(LegacyGridElement.class).first().getCell(row, col);
}
private void waitUntilTextUpdated(final WebElement button,
final String expectedText) {
waitUntil(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver input) {
return button.getText().equals(expectedText);
}
@Override
public String toString() {
// Timed out after 10 seconds waiting for ...
return String.format("button's text to become '%s' (was: '').",
expectedText, button.getText());
}
});
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* TB tests for the various builtin widget-based renderers.
*
* @since
* @author Vaadin Ltd
*/
@TestCategory("grid")
public class WidgetRenderersTest extends MultiBrowserTest {
@Override
public void setup() throws Exception {
super.setup();
openTestURL();
}
@Test
public void testProgressBarRenderer() {
assertTrue(getGridCell(0, 0)
.isElementPresent(By.className("v-progressbar")));
}
@Test
public void testButtonRenderer() {
WebElement button = getGridCell(0, 1)
.findElement(By.className("v-nativebutton"));
button.click();
waitUntilTextUpdated(button, "Clicked!");
}
@Test
public void testButtonRendererAfterCellBeingFocused() {
GridCellElement buttonCell = getGridCell(0, 1);
assertFalse("cell should not be focused before focusing",
buttonCell.isFocused());
// avoid clicking on the button
buttonCell.click(buttonCell.getSize().getWidth() - 10, 5);
assertTrue("cell should be focused after focusing",
buttonCell.isFocused());
WebElement button = buttonCell
.findElement(By.className("v-nativebutton"));
assertNotEquals("Button should not be clicked before click", "Clicked!",
button.getText());
new Actions(getDriver()).moveToElement(button).click().perform();
waitUntilTextUpdated(button, "Clicked!");
}
@Test
public void testImageRenderer() {
final WebElement image = getGridCell(0, 2)
.findElement(By.className("gwt-Image"));
waitUntilmageSrcEndsWith(image, "window/img/close.png");
image.click();
waitUntilmageSrcEndsWith(image, "window/img/maximize.png");
}
private void waitUntilmageSrcEndsWith(final WebElement image,
final String expectedText) {
waitUntil(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver input) {
return image.getAttribute("src").endsWith(expectedText);
}
@Override
public String toString() {
// Timed out after 10 seconds waiting for ...
return String.format(
"image source to update. Supposed to end with '%s' (was: '%s').",
expectedText, image.getAttribute("src"));
}
});
}
@Test
public void testColumnReorder() {
$(ButtonElement.class).caption("Change column order").first().click();
assertFalse("Notification was present",
isElementPresent(NotificationElement.class));
assertTrue(
getGridCell(0, 0).isElementPresent(By.className("gwt-Image")));
assertTrue(getGridCell(0, 1)
.isElementPresent(By.className("v-progressbar")));
assertTrue(getGridCell(0, 2)
.isElementPresent(By.className("v-nativebutton")));
}
@Test
public void testPropertyIdInEvent() {
WebElement button = getGridCell(0, 3)
.findElement(By.className("v-nativebutton"));
button.click();
waitUntilTextUpdated(button, WidgetRenderers.PROPERTY_ID);
}
GridCellElement getGridCell(int row, int col) {
return $(LegacyGridElement.class).first().getCell(row, col);
}
private void waitUntilTextUpdated(final WebElement button,
final String expectedText) {
waitUntil(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver input) {
return button.getText().equals(expectedText);
}
@Override
public String toString() {
// Timed out after 10 seconds waiting for ...
return String.format("button's text to become '%s' (was: '').",
expectedText, button.getText());
}
});
}
}

+ 52
- 52
uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridClearContainerTest.java Переглянути файл

@@ -1,52 +1,52 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid.basicfeatures.server;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* Tests that removing and adding rows doesn't cause an infinite loop in the
* browser.
*
* @author Vaadin Ltd
*/
@TestCategory("grid")
public class GridClearContainerTest extends MultiBrowserTest {
private final String ERRORNOTE = "Unexpected cell contents.";
@Test
public void clearAndReadd() {
openTestURL();
ButtonElement button = $(ButtonElement.class)
.caption("Clear and re-add").first();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals(ERRORNOTE, "default", grid.getCell(0, 0).getText());
Assert.assertEquals(ERRORNOTE, "default", grid.getCell(1, 0).getText());
button.click();
Assert.assertEquals(ERRORNOTE, "Updated value 1",
grid.getCell(0, 0).getText());
Assert.assertEquals(ERRORNOTE, "Updated value 2",
grid.getCell(1, 0).getText());
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid.basicfeatures.server;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* Tests that removing and adding rows doesn't cause an infinite loop in the
* browser.
*
* @author Vaadin Ltd
*/
@TestCategory("grid")
public class GridClearContainerTest extends MultiBrowserTest {
private final String ERRORNOTE = "Unexpected cell contents.";
@Test
public void clearAndReadd() {
openTestURL();
ButtonElement button = $(ButtonElement.class)
.caption("Clear and re-add").first();
GridElement grid = $(LegacyGridElement.class).first();
Assert.assertEquals(ERRORNOTE, "default", grid.getCell(0, 0).getText());
Assert.assertEquals(ERRORNOTE, "default", grid.getCell(1, 0).getText());
button.click();
Assert.assertEquals(ERRORNOTE, "Updated value 1",
grid.getCell(0, 0).getText());
Assert.assertEquals(ERRORNOTE, "Updated value 2",
grid.getCell(1, 0).getText());
}
}

+ 58
- 58
uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridScrollTest.java Переглянути файл

@@ -1,58 +1,58 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid.basicfeatures.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
public class GridScrollTest extends GridBasicFeaturesTest {
@Test
public void testCorrectItemRequestsOnScroll() {
openTestURL();
assertTrue("Initial push from server not found",
getLogRow(1).equals("0. Requested items 0 - 40"));
// Client response varies a bit between browsers as different amount of
// rows is cached.
assertTrue("First row request from client not found",
getLogRow(0).startsWith("1. Requested items 0 - "));
selectMenuPath("Component", "Size", "HeightMode Row");
selectMenuPath("Settings", "Clear log");
$(LegacyGridElement.class).first().scrollToRow(40);
assertEquals("Log row did not contain expected item request",
"0. Requested items 0 - 86", getLogRow(0));
assertEquals("There should be only one log row", " ", getLogRow(1));
selectMenuPath("Settings", "Clear log");
$(LegacyGridElement.class).first().scrollToRow(100);
assertEquals("Log row did not contain expected item request",
"0. Requested items 47 - 146", getLogRow(0));
assertEquals("There should be only one log row", " ", getLogRow(1));
selectMenuPath("Settings", "Clear log");
$(LegacyGridElement.class).first().scrollToRow(300);
assertEquals("Log row did not contain expected item request",
"0. Requested items 247 - 346", getLogRow(0));
assertEquals("There should be only one log row", " ", getLogRow(1));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid.basicfeatures.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Test;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
public class GridScrollTest extends GridBasicFeaturesTest {
@Test
public void testCorrectItemRequestsOnScroll() {
openTestURL();
assertTrue("Initial push from server not found",
getLogRow(1).equals("0. Requested items 0 - 40"));
// Client response varies a bit between browsers as different amount of
// rows is cached.
assertTrue("First row request from client not found",
getLogRow(0).startsWith("1. Requested items 0 - "));
selectMenuPath("Component", "Size", "HeightMode Row");
selectMenuPath("Settings", "Clear log");
$(LegacyGridElement.class).first().scrollToRow(40);
assertEquals("Log row did not contain expected item request",
"0. Requested items 0 - 86", getLogRow(0));
assertEquals("There should be only one log row", " ", getLogRow(1));
selectMenuPath("Settings", "Clear log");
$(LegacyGridElement.class).first().scrollToRow(100);
assertEquals("Log row did not contain expected item request",
"0. Requested items 47 - 146", getLogRow(0));
assertEquals("There should be only one log row", " ", getLogRow(1));
selectMenuPath("Settings", "Clear log");
$(LegacyGridElement.class).first().scrollToRow(300);
assertEquals("Log row did not contain expected item request",
"0. Requested items 247 - 346", getLogRow(0));
assertEquals("There should be only one log row", " ", getLogRow(1));
}
}

+ 86
- 86
uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/LoadingIndicatorTest.java Переглянути файл

@@ -1,86 +1,86 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid.basicfeatures.server;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
public class LoadingIndicatorTest extends GridBasicFeaturesTest {
@Test
public void testLoadingIndicator() throws InterruptedException {
setDebug(true);
openTestURL();
selectMenuPath("Component", "State", "Container delay", "2000");
GridElement gridElement = $(LegacyGridElement.class).first();
Assert.assertFalse(
"Loading indicator should not be visible before disabling waitForVaadin",
isLoadingIndicatorVisible());
testBench().disableWaitForVaadin();
// Scroll to a completely new location
gridElement.getCell(200, 1);
// Wait for loading indicator delay
waitUntil(ExpectedConditions.visibilityOfElementLocated(
By.className("v-loading-indicator")));
waitUntilNot(ExpectedConditions.visibilityOfElementLocated(
By.className("v-loading-indicator")));
// Scroll so much that more data gets fetched, but not so much that
// missing rows are shown
gridElement.getCell(230, 1);
// Wait for potentially triggered loading indicator to become visible
Thread.sleep(500);
Assert.assertFalse(
"Loading indicator should not be visible when fetching rows that are not visible",
isLoadingIndicatorVisible());
// Finally verify that there was actually a request going on
waitUntilLogContains("Requested items");
}
private void waitUntilLogContains(final String value) {
waitUntil(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver input) {
return getLogRow(0).contains(value);
}
@Override
public String toString() {
// Timed out after 10 seconds waiting for ...
return "first log row to contain '" + value + "' (was: '"
+ getLogRow(0) + "')";
}
});
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.grid.basicfeatures.server;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
public class LoadingIndicatorTest extends GridBasicFeaturesTest {
@Test
public void testLoadingIndicator() throws InterruptedException {
setDebug(true);
openTestURL();
selectMenuPath("Component", "State", "Container delay", "2000");
GridElement gridElement = $(LegacyGridElement.class).first();
Assert.assertFalse(
"Loading indicator should not be visible before disabling waitForVaadin",
isLoadingIndicatorVisible());
testBench().disableWaitForVaadin();
// Scroll to a completely new location
gridElement.getCell(200, 1);
// Wait for loading indicator delay
waitUntil(ExpectedConditions.visibilityOfElementLocated(
By.className("v-loading-indicator")));
waitUntilNot(ExpectedConditions.visibilityOfElementLocated(
By.className("v-loading-indicator")));
// Scroll so much that more data gets fetched, but not so much that
// missing rows are shown
gridElement.getCell(230, 1);
// Wait for potentially triggered loading indicator to become visible
Thread.sleep(500);
Assert.assertFalse(
"Loading indicator should not be visible when fetching rows that are not visible",
isLoadingIndicatorVisible());
// Finally verify that there was actually a request going on
waitUntilLogContains("Requested items");
}
private void waitUntilLogContains(final String value) {
waitUntil(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver input) {
return getLogRow(0).contains(value);
}
@Override
public String toString() {
// Timed out after 10 seconds waiting for ...
return "first log row to contain '" + value + "' (was: '"
+ getLogRow(0) + "')";
}
});
}
}

+ 110
- 110
uitest/src/test/java/com/vaadin/tests/contextclick/GridContextClickTest.java Переглянути файл

@@ -1,110 +1,110 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.contextclick;
import static org.junit.Assert.assertEquals;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
public class GridContextClickTest extends AbstractContextClickTest {
@Test
public void testBodyContextClickWithTypedListener() {
addOrRemoveTypedListener();
contextClick($(LegacyGridElement.class).first().getCell(0, 0));
assertEquals(
"1. ContextClickEvent value: Lisa Schneider, propertyId: address, section: BODY",
getLogRow(0));
contextClick($(LegacyGridElement.class).first().getCell(0, 3));
assertEquals(
"2. ContextClickEvent value: Lisa Schneider, propertyId: lastName, section: BODY",
getLogRow(0));
}
@Test
public void testHeaderContextClickWithTypedListener() {
addOrRemoveTypedListener();
contextClick($(LegacyGridElement.class).first().getHeaderCell(0, 0));
assertEquals(
"1. ContextClickEvent value: Address, propertyId: address, section: HEADER",
getLogRow(0));
contextClick($(LegacyGridElement.class).first().getHeaderCell(0, 3));
assertEquals(
"2. ContextClickEvent value: Last Name, propertyId: lastName, section: HEADER",
getLogRow(0));
}
@Test
public void testFooterContextClickWithTypedListener() {
addOrRemoveTypedListener();
contextClick($(LegacyGridElement.class).first().getFooterCell(0, 0));
assertEquals(
"1. ContextClickEvent value: , propertyId: address, section: FOOTER",
getLogRow(0));
contextClick($(LegacyGridElement.class).first().getFooterCell(0, 3));
assertEquals(
"2. ContextClickEvent value: , propertyId: lastName, section: FOOTER",
getLogRow(0));
}
@Test
public void testContextClickInEmptyGrid() {
addOrRemoveTypedListener();
$(ButtonElement.class).caption("Remove all content").first().click();
contextClick($(LegacyGridElement.class).first(), 100, 100);
assertEquals(
"1. ContextClickEvent value: , propertyId: null, section: BODY",
getLogRow(0));
}
/**
* Performs a context click on given element at coordinates 20, 10 followed
* by a regular click. This prevents browser context menu from blocking
* future operations.
*
* A smaller X offset might hit the resize handle of the previous cell that
* overlaps with the next header cell.
*
* @param e
* web element
*/
@Override
protected void contextClick(WebElement e) {
contextClick(e, 20, 10);
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.contextclick;
import static org.junit.Assert.assertEquals;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
public class GridContextClickTest extends AbstractContextClickTest {
@Test
public void testBodyContextClickWithTypedListener() {
addOrRemoveTypedListener();
contextClick($(LegacyGridElement.class).first().getCell(0, 0));
assertEquals(
"1. ContextClickEvent value: Lisa Schneider, propertyId: address, section: BODY",
getLogRow(0));
contextClick($(LegacyGridElement.class).first().getCell(0, 3));
assertEquals(
"2. ContextClickEvent value: Lisa Schneider, propertyId: lastName, section: BODY",
getLogRow(0));
}
@Test
public void testHeaderContextClickWithTypedListener() {
addOrRemoveTypedListener();
contextClick($(LegacyGridElement.class).first().getHeaderCell(0, 0));
assertEquals(
"1. ContextClickEvent value: Address, propertyId: address, section: HEADER",
getLogRow(0));
contextClick($(LegacyGridElement.class).first().getHeaderCell(0, 3));
assertEquals(
"2. ContextClickEvent value: Last Name, propertyId: lastName, section: HEADER",
getLogRow(0));
}
@Test
public void testFooterContextClickWithTypedListener() {
addOrRemoveTypedListener();
contextClick($(LegacyGridElement.class).first().getFooterCell(0, 0));
assertEquals(
"1. ContextClickEvent value: , propertyId: address, section: FOOTER",
getLogRow(0));
contextClick($(LegacyGridElement.class).first().getFooterCell(0, 3));
assertEquals(
"2. ContextClickEvent value: , propertyId: lastName, section: FOOTER",
getLogRow(0));
}
@Test
public void testContextClickInEmptyGrid() {
addOrRemoveTypedListener();
$(ButtonElement.class).caption("Remove all content").first().click();
contextClick($(LegacyGridElement.class).first(), 100, 100);
assertEquals(
"1. ContextClickEvent value: , propertyId: null, section: BODY",
getLogRow(0));
}
/**
* Performs a context click on given element at coordinates 20, 10 followed
* by a regular click. This prevents browser context menu from blocking
* future operations.
*
* A smaller X offset might hit the resize handle of the previous cell that
* overlaps with the next header cell.
*
* @param e
* web element
*/
@Override
protected void contextClick(WebElement e) {
contextClick(e, 20, 10);
}
}

+ 116
- 116
uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java Переглянути файл

@@ -1,116 +1,116 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.fieldgroup;
import static org.junit.Assert.assertFalse;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.GridElement.GridEditorElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.legacyelements.LegacyDateFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class BasicCrudGridEditorRowTest extends MultiBrowserTest {
private GridElement grid;
@Before
public void openTest() {
openTestURL();
grid = $(LegacyGridElement.class).first();
}
@Test
public void lookAndFeel() throws Exception {
GridCellElement ritaBirthdate = grid.getCell(2, 3);
compareScreen("grid");
// Open editor row
new Actions(getDriver()).doubleClick(ritaBirthdate).perform();
compareScreen("editorrow");
}
@Test
public void editorRowOneInvalidValue() throws Exception {
GridCellElement ritaBirthdate = grid.getCell(2, 3);
// Open editor row
new Actions(getDriver()).doubleClick(ritaBirthdate).perform();
GridEditorElement editor = grid.getEditor();
LegacyDateFieldElement dateField = editor
.$(LegacyDateFieldElement.class).first();
WebElement input = dateField.findElement(By.xpath("input"));
// input.click();
input.sendKeys("Invalid", Keys.TAB);
editor.save();
Assert.assertTrue("Editor wasn't displayed.", editor.isDisplayed());
Assert.assertTrue("DateField wasn't displayed.",
dateField.isDisplayed());
Assert.assertTrue("DateField didn't have 'v-invalid' css class.",
hasCssClass(dateField, "v-datefield-error"));
}
@Test
public void testCheckboxInEditorWorks() {
GridCellElement ritaBirthdate = grid.getCell(2, 3);
// Open editor row
new Actions(getDriver()).doubleClick(ritaBirthdate).perform();
// Get CheckBox
GridEditorElement editor = grid.getEditor();
CheckBoxElement cb = editor.getField(5).wrap(CheckBoxElement.class);
// Check values
String value = cb.getValue();
cb.click(5, 5);
Assert.assertNotEquals("Checkbox value did not change", value,
cb.getValue());
}
@Test
public void testNoTopStyleSetOnEditorOpenWithFooterOnTop() {
GridCellElement cell = grid.getCell(2, 3);
// Open editor row
new Actions(getDriver()).doubleClick(cell).perform();
// Close editor
new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform();
cell = grid.getCell(14, 3);
// Open editor row
new Actions(getDriver()).doubleClick(cell).perform();
String attribute = grid.getEditor().getAttribute("style").toLowerCase();
assertFalse("Style should not contain top.",
attribute.contains("top:"));
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.fieldgroup;
import static org.junit.Assert.assertFalse;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.GridElement.GridEditorElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.legacyelements.LegacyDateFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
@TestCategory("grid")
public class BasicCrudGridEditorRowTest extends MultiBrowserTest {
private GridElement grid;
@Before
public void openTest() {
openTestURL();
grid = $(LegacyGridElement.class).first();
}
@Test
public void lookAndFeel() throws Exception {
GridCellElement ritaBirthdate = grid.getCell(2, 3);
compareScreen("grid");
// Open editor row
new Actions(getDriver()).doubleClick(ritaBirthdate).perform();
compareScreen("editorrow");
}
@Test
public void editorRowOneInvalidValue() throws Exception {
GridCellElement ritaBirthdate = grid.getCell(2, 3);
// Open editor row
new Actions(getDriver()).doubleClick(ritaBirthdate).perform();
GridEditorElement editor = grid.getEditor();
LegacyDateFieldElement dateField = editor
.$(LegacyDateFieldElement.class).first();
WebElement input = dateField.findElement(By.xpath("input"));
// input.click();
input.sendKeys("Invalid", Keys.TAB);
editor.save();
Assert.assertTrue("Editor wasn't displayed.", editor.isDisplayed());
Assert.assertTrue("DateField wasn't displayed.",
dateField.isDisplayed());
Assert.assertTrue("DateField didn't have 'v-invalid' css class.",
hasCssClass(dateField, "v-datefield-error"));
}
@Test
public void testCheckboxInEditorWorks() {
GridCellElement ritaBirthdate = grid.getCell(2, 3);
// Open editor row
new Actions(getDriver()).doubleClick(ritaBirthdate).perform();
// Get CheckBox
GridEditorElement editor = grid.getEditor();
CheckBoxElement cb = editor.getField(5).wrap(CheckBoxElement.class);
// Check values
String value = cb.getValue();
cb.click(5, 5);
Assert.assertNotEquals("Checkbox value did not change", value,
cb.getValue());
}
@Test
public void testNoTopStyleSetOnEditorOpenWithFooterOnTop() {
GridCellElement cell = grid.getCell(2, 3);
// Open editor row
new Actions(getDriver()).doubleClick(cell).perform();
// Close editor
new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform();
cell = grid.getCell(14, 3);
// Open editor row
new Actions(getDriver()).doubleClick(cell).perform();
String attribute = grid.getEditor().getAttribute("style").toLowerCase();
assertFalse("Style should not contain top.",
attribute.contains("top:"));
}
}

+ 70
- 70
uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridTest.java Переглянути файл

@@ -1,70 +1,70 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.fieldgroup;
import java.util.List;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.AbstractHasTestBenchCommandExecutor;
import com.vaadin.testbench.elements.AbstractComponentElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
public class BasicCrudGridTest extends SingleBrowserTestPhantomJS2 {
@Test
public void fieldsInitiallyEmpty() {
openTestURL();
List<TextFieldElement> textFields = getFieldsLayout()
.$(TextFieldElement.class).all();
for (TextFieldElement e : textFields) {
Assert.assertEquals("TextField should be empty", "", e.getValue());
}
}
private AbstractHasTestBenchCommandExecutor getFieldsLayout() {
return $(AbstractComponentElement.class).id("form");
}
@Test
public void fieldsClearedOnDeselect() {
openTestURL();
// Select row
$(LegacyGridElement.class).first().getCell(2, 2).click();
List<TextFieldElement> textFields = getFieldsLayout()
.$(TextFieldElement.class).all();
for (TextFieldElement e : textFields) {
Assert.assertNotEquals("TextField should not be empty", "",
e.getValue());
}
// Deselect row
$(LegacyGridElement.class).first().getCell(2, 2).click();
for (TextFieldElement e : textFields) {
Assert.assertEquals("TextField should be empty", "", e.getValue());
}
}
}
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.fieldgroup;
import java.util.List;
import com.vaadin.tests.components.grid.LegacyGridElement;
import org.junit.Assert;
import org.junit.Test;
import com.vaadin.testbench.AbstractHasTestBenchCommandExecutor;
import com.vaadin.testbench.elements.AbstractComponentElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2;
public class BasicCrudGridTest extends SingleBrowserTestPhantomJS2 {
@Test
public void fieldsInitiallyEmpty() {
openTestURL();
List<TextFieldElement> textFields = getFieldsLayout()
.$(TextFieldElement.class).all();
for (TextFieldElement e : textFields) {
Assert.assertEquals("TextField should be empty", "", e.getValue());
}
}
private AbstractHasTestBenchCommandExecutor getFieldsLayout() {
return $(AbstractComponentElement.class).id("form");
}
@Test
public void fieldsClearedOnDeselect() {
openTestURL();
// Select row
$(LegacyGridElement.class).first().getCell(2, 2).click();
List<TextFieldElement> textFields = getFieldsLayout()
.$(TextFieldElement.class).all();
for (TextFieldElement e : textFields) {
Assert.assertNotEquals("TextField should not be empty", "",
e.getValue());
}
// Deselect row
$(LegacyGridElement.class).first().getCell(2, 2).click();
for (TextFieldElement e : textFields) {
Assert.assertEquals("TextField should be empty", "", e.getValue());
}
}
}

Завантаження…
Відмінити
Зберегти