diff options
author | Artur Signell <artur@vaadin.com> | 2016-08-18 14:52:04 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-08-18 12:32:41 +0000 |
commit | 88a0b0ca9aedc79678bd378e47ebd7e9a190be0e (patch) | |
tree | dac1ce332c90259ddd47b93fc61e953292c05737 | |
parent | 52dc5e4f1c1e11d2181385eb97b78641b8d5b32c (diff) | |
download | vaadin-framework-88a0b0ca9aedc79678bd378e47ebd7e9a190be0e.tar.gz vaadin-framework-88a0b0ca9aedc79678bd378e47ebd7e9a190be0e.zip |
Remove carriage returns
Change-Id: I1be17dcf3245eca3e571886db4fa0cbb9657edbb
60 files changed, 4662 insertions, 4662 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/accordion/AccordionTabIds.java b/uitest/src/main/java/com/vaadin/tests/components/accordion/AccordionTabIds.java index 31bd8d99fb..cceec3a178 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/accordion/AccordionTabIds.java +++ b/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; + } +} diff --git a/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridBasicFeatures.html b/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridBasicFeatures.html index f91829e002..4647468130 100644 --- a/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridBasicFeatures.html +++ b/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridBasicFeatures.html @@ -1,499 +1,499 @@ -<vaadin-legacy-grid
- editor-save-caption='Save'
- editor-cancel-caption='Cancel'
- frozen-columns=1
- style-name='grid-basics'
- width='750px' height='100%'>
-<table>
- <colgroup>
- <col min-width='150'/>
- <col width='115'/>
- <col width='115'/>
- <col width='115'/>
- <col width='115'/>
- <col width='115'/>
- <col width='115'/>
- <col width='115'/>
- <col width='115'/>
- </colgroup>
- <thead>
- <tr>
- <th />
- <th colspan=2><b>2012</b></th>
- <th colspan=2><b>2013</b></th>
- <th colspan=2><b>2014</b></th>
- <th colspan=2><b>2015</b></th>
- </tr>
- <tr default=true>
- <th>Company</th>
- <th>H1</th>
- <th>H2</th>
- <th>H1</th>
- <th>H2</th>
- <th>H1</th>
- <th>H2</th>
- <th>H1</th>
- <th>H2</th>
- </tr>
- <tr>
- <th>
- <vaadin-text-field width='100%' input-prompt='Filter'></vaadin-textfield>
- <!--
- -->
- </th>
- <th />
- <th />
- <th />
- <th />
- <th />
- <th />
- <th />
- <th />
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$6,063.67</td>
- <td>$7,116.66</td>
- <td>$5,879.24</td>
- <td>$5,270.28</td>
- <td>$393.65</td>
- <td>$4,922.45</td>
- <td>$5,443.97</td>
- <td>$203.05</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$6,508.00</td>
- <td>$8,904.53</td>
- <td>$3,938.05</td>
- <td>$2,283.44</td>
- </tr>
- <tr>
- <td>Deomic</td>
- <td>$4,802.82</td>
- <td>$7,083.74</td>
- <td>$6,418.09</td>
- <td>$9,964.82</td>
- <td>$4,543.26</td>
- <td>$2,004.65</td>
- <td>$5,961.86</td>
- <td>$5,753.23</td>
- </tr>
- </tbody>
- <tfoot>
- <tr>
- <td />
- <td>$$$</td>
- <td>$$$</td>
- <td>$$$</td>
- <td>$$$</td>
- <td>$$$</td>
- <td>$$$</td>
- <td>$$$</td>
- <td>$$$</td>
- </tr>
- </tfoot>
-</table>
+<vaadin-legacy-grid + editor-save-caption='Save' + editor-cancel-caption='Cancel' + frozen-columns=1 + style-name='grid-basics' + width='750px' height='100%'> +<table> + <colgroup> + <col min-width='150'/> + <col width='115'/> + <col width='115'/> + <col width='115'/> + <col width='115'/> + <col width='115'/> + <col width='115'/> + <col width='115'/> + <col width='115'/> + </colgroup> + <thead> + <tr> + <th /> + <th colspan=2><b>2012</b></th> + <th colspan=2><b>2013</b></th> + <th colspan=2><b>2014</b></th> + <th colspan=2><b>2015</b></th> + </tr> + <tr default=true> + <th>Company</th> + <th>H1</th> + <th>H2</th> + <th>H1</th> + <th>H2</th> + <th>H1</th> + <th>H2</th> + <th>H1</th> + <th>H2</th> + </tr> + <tr> + <th> + <vaadin-text-field width='100%' input-prompt='Filter'></vaadin-textfield> + <!-- + --> + </th> + <th /> + <th /> + <th /> + <th /> + <th /> + <th /> + <th /> + <th /> + </tr> + </thead> + <tbody> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + <tr> + <td>Deomic</td> + <td>$6,063.67</td> + <td>$7,116.66</td> + <td>$5,879.24</td> + <td>$5,270.28</td> + <td>$393.65</td> + <td>$4,922.45</td> + <td>$5,443.97</td> + <td>$203.05</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$6,508.00</td> + <td>$8,904.53</td> + <td>$3,938.05</td> + <td>$2,283.44</td> + </tr> + <tr> + <td>Deomic</td> + <td>$4,802.82</td> + <td>$7,083.74</td> + <td>$6,418.09</td> + <td>$9,964.82</td> + <td>$4,543.26</td> + <td>$2,004.65</td> + <td>$5,961.86</td> + <td>$5,753.23</td> + </tr> + </tbody> + <tfoot> + <tr> + <td /> + <td>$$$</td> + <td>$$$</td> + <td>$$$</td> + <td>$$$</td> + <td>$$$</td> + <td>$$$</td> + <td>$$$</td> + <td>$$$</td> + </tr> + </tfoot> +</table> </vaadin-legacy-grid>
\ No newline at end of file diff --git a/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridItemEditor.html b/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridItemEditor.html index 7290f92c2c..2860b1bd67 100644 --- a/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridItemEditor.html +++ b/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>
\ No newline at end of file diff --git a/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridMultiSelect.html b/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridMultiSelect.html index 1909cc6d4f..477216d428 100644 --- a/uitest/src/main/resources/com/vaadin/tests/components/grid/declarative/GridMultiSelect.html +++ b/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> diff --git a/uitest/src/main/webapp/statictestfiles/TableInIframeRowClickScrollJumpTest.html b/uitest/src/main/webapp/statictestfiles/TableInIframeRowClickScrollJumpTest.html index dfddbdb7e5..98d31e7dab 100644 --- a/uitest/src/main/webapp/statictestfiles/TableInIframeRowClickScrollJumpTest.html +++ b/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>
\ No newline at end of file diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/CustomRendererTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/CustomRendererTest.java index 81dbb05393..e1b5cacc75 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/CustomRendererTest.java +++ b/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); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddRowTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddRowTest.java index c01eebe79c..3ef26ce934 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddRowTest.java +++ b/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(); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java index ab33f84ce1..ac0e68ce1b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java +++ b/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(); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java index cacf198dc7..ad1fb8c434 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java +++ b/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"))); + + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoExpandTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoExpandTest.java index 27bb664f0e..965d11b2e9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnAutoExpandTest.java +++ b/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); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthRecalculationTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthRecalculationTest.java index 0eb587e6b9..d03d40a60f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthRecalculationTest.java +++ b/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; + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java index 8335e0b032..91f6648f1c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java +++ b/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; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDataSourceResetTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDataSourceResetTest.java index 7b4213feec..896e4da5c3 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDataSourceResetTest.java +++ b/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()); + } + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDefaultSelectionModeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDefaultSelectionModeTest.java index 9f3ef7889d..60395aca87 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDefaultSelectionModeTest.java +++ b/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(); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolledTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolledTest.java index 7460917d00..752622e195 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolledTest.java +++ b/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()); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBarsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBarsTest.java index 21291dc26c..cff81b0d58 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditingWithNoScrollBarsTest.java +++ b/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); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorConverterNotFoundTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorConverterNotFoundTest.java index c39ef2e18f..66ca4616c6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorConverterNotFoundTest.java +++ b/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)); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorCustomFieldTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorCustomFieldTest.java index 2e51de0fe6..b1c7bb884f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorCustomFieldTest.java +++ b/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()); + + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java index 153dad12de..20f00bf1f0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java +++ b/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\")]")); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorUITest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorUITest.java index 3bd92a3626..8f84d38fa9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorUITest.java +++ b/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-"))); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java index 27216543ee..b688970bda 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridExtensionCommunicationTest.java +++ b/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)); + + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java index 3a51fdedb3..762334b26b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java +++ b/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(); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java index 7754b14e04..dfe5a692f6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java +++ b/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(); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java index c5369311df..b2bf6d2293 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java +++ b/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); + } + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInWindowResizeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInWindowResizeTest.java index 33de6d5e7d..8a4e8e79ee 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInWindowResizeTest.java +++ b/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); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java index 746a9f9963..58a4022814 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java +++ b/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); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridItemSetChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridItemSetChangeTest.java index 1d89caa5f4..e1993b1ac7 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridItemSetChangeTest.java +++ b/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()); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridLayoutDetailsRowTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridLayoutDetailsRowTest.java index 5d6c353e4a..5479c84f16 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridLayoutDetailsRowTest.java +++ b/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)); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java index 72d1bd42eb..8c6064ddaa 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java +++ b/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()); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionScrollBarTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionScrollBarTest.java index a1f0f80bc3..acea49bde3 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionScrollBarTest.java +++ b/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(); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridRendererChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridRendererChangeTest.java index 66b8352070..d277effec8 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridRendererChangeTest.java +++ b/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"))); + } + }
\ No newline at end of file diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridReplaceContainerTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridReplaceContainerTest.java index 60c988ee3c..0735264bff 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridReplaceContainerTest.java +++ b/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()); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java index 581b6163b1..af5833824a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java +++ b/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()); + + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java index ce4eab5899..29cec68c6f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java +++ b/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(); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizingTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizingTest.java index 359571120e..41a9ae947d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToLineWhileResizingTest.java +++ b/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); + } }
\ No newline at end of file diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllCellTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllCellTest.java index 92247d7a9b..d9be0cdf64 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectAllCellTest.java +++ b/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)); + } }
\ No newline at end of file diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java index ee9aa15b5c..c16ccbe5fb 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java +++ b/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); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java index 8f407baddf..399bbb5533 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java +++ b/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)); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java index b9dc55318b..8119c547d2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java +++ b/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")); + } }
\ No newline at end of file diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java index f9d88b6d32..66c9422424 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java +++ b/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); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSwitchRenderersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSwitchRenderersTest.java index 8db4b6e50c..2c00295408 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSwitchRenderersTest.java +++ b/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); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeChangeTest.java index 2f2c0258a9..e1b4278499 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeChangeTest.java +++ b/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); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeUITest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeUITest.java index eb2ee1c9db..67615289dc 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridThemeUITest.java +++ b/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(); + + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridWidthIncreaseTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridWidthIncreaseTest.java index c36b8927aa..01b735abd3 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridWidthIncreaseTest.java +++ b/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); + } + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithBrokenRendererTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithBrokenRendererTest.java index 4e298047bf..7556e78b70 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithBrokenRendererTest.java +++ b/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()); + } + + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java index 0202937739..fa6b41e55f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java +++ b/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()); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java index ff44ddf41d..78b9cc499c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java +++ b/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")); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java index f2f5eb4e60..dcf780d589 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java +++ b/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")); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/NullHeadersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/NullHeadersTest.java index 13e726cda5..0293cee531 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/NullHeadersTest.java +++ b/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()); + } + + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/NullRenderersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/NullRenderersTest.java index dcf2a95d36..4fe49af0df 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/NullRenderersTest.java +++ b/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); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/ProgrammaticEditorControlTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/ProgrammaticEditorControlTest.java index 4716f20ce1..f822d7de7f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/ProgrammaticEditorControlTest.java +++ b/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) { + + } + } + }
\ No newline at end of file diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/SelectDuringInitTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/SelectDuringInitTest.java index ce5db1b3d7..968f8ee091 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/SelectDuringInitTest.java +++ b/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()); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/SortableHeaderStylesTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/SortableHeaderStylesTest.java index 0702eff943..8e507339ff 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/SortableHeaderStylesTest.java +++ b/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"); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/WidgetRenderersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/WidgetRenderersTest.java index 79deff513d..32807e8f0c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/WidgetRenderersTest.java +++ b/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()); + } + + }); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridClearContainerTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridClearContainerTest.java index f7c579635e..5996a5dc61 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridClearContainerTest.java +++ b/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()); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridScrollTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridScrollTest.java index 48c94d4b5a..10bb338ad6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridScrollTest.java +++ b/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)); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/LoadingIndicatorTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/LoadingIndicatorTest.java index 83b4b4a70d..70402c3854 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/LoadingIndicatorTest.java +++ b/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) + "')"; + } + }); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/contextclick/GridContextClickTest.java b/uitest/src/test/java/com/vaadin/tests/contextclick/GridContextClickTest.java index 096d79f780..d1139a8a10 100644 --- a/uitest/src/test/java/com/vaadin/tests/contextclick/GridContextClickTest.java +++ b/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); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java index dcefa03966..1c63f2b2ca 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java +++ b/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:")); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridTest.java index 57bc553783..39264d3ea0 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridTest.java +++ b/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()); + } + + } +} |