2 * Copyright 2000-2016 Vaadin Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.vaadin.tests.components.grid.basicfeatures;
18 import java.util.List;
20 import org.openqa.selenium.WebElement;
22 import com.vaadin.testbench.By;
23 import com.vaadin.testbench.TestBenchElement;
24 import com.vaadin.v7.testbench.customelements.GridElement;
27 * GridBasicClientFeatures.
32 public abstract class GridBasicClientFeaturesTest
33 extends GridBasicFeaturesTest {
35 private boolean composite = false;
38 protected Class<?> getUIClass() {
39 return GridBasicClientFeatures.class;
43 protected String getDeploymentPath() {
44 String path = super.getDeploymentPath();
46 path += (path.contains("?") ? "&" : "?") + "composite";
51 protected void setUseComposite(boolean useComposite) {
52 composite = useComposite;
56 protected void selectMenu(String menuCaption) {
57 // GWT menu does not need to be clicked.
58 selectMenu(menuCaption, false);
62 protected WebElement getMenuElement(String menuCaption) {
64 .findElement(By.xpath("//td[text() = '" + menuCaption + "']"));
68 protected GridElement getGridElement() {
70 // Composite requires the basic client features widget for subparts
71 return ((TestBenchElement) findElement(
72 By.vaadin("//TestWidgetComponent")))
73 .wrap(GridElement.class);
75 return super.getGridElement();
80 protected void assertColumnHeaderOrder(int... indices) {
81 List<TestBenchElement> headers = getGridHeaderRowCells();
82 for (int i = 0; i < indices.length; i++) {
83 assertColumnHeader("HEADER (0," + indices[i] + ")", headers.get(i));
87 protected void toggleColumnReorder() {
88 selectMenuPath("Component", "State", "Column Reordering");
91 protected boolean isRowSelected(int index) {
92 boolean selected = getGridElement().getRow(index).isSelected();
96 protected void setSelectionModelMulti() {
97 setSelectionModel("multi");
100 protected void setSelectionModelSingle(boolean deselectAllowed) {
101 String mode = "single";
102 if (!deselectAllowed) {
103 mode += " (no deselect)";
105 setSelectionModel(mode);
108 protected void setSelectionModelNone() {
109 setSelectionModel("none");
112 protected void setSelectionModel(String model) {
113 selectMenuPath("Component", "State", "Selection mode", model);