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.v7.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;
25 import com.vaadin.v7.tests.components.grid.basicfeatures.GridBasicClientFeatures;
28 * GridBasicClientFeatures.
33 public abstract class GridBasicClientFeaturesTest
34 extends GridBasicFeaturesTest {
36 private boolean composite = false;
39 protected Class<?> getUIClass() {
40 return GridBasicClientFeatures.class;
44 protected String getDeploymentPath() {
45 String path = super.getDeploymentPath();
47 path += (path.contains("?") ? "&" : "?") + "composite";
52 protected void setUseComposite(boolean useComposite) {
53 composite = useComposite;
57 protected void selectMenu(String menuCaption) {
58 // GWT menu does not need to be clicked.
59 selectMenu(menuCaption, false);
63 protected WebElement getMenuElement(String menuCaption) {
65 .findElement(By.xpath("//td[text() = '" + menuCaption + "']"));
69 protected GridElement getGridElement() {
71 // Composite requires the basic client features widget for subparts
72 return ((TestBenchElement) findElement(
73 By.vaadin("//TestWidgetComponent")))
74 .wrap(GridElement.class);
76 return super.getGridElement();
81 protected void assertColumnHeaderOrder(int... indices) {
82 List<TestBenchElement> headers = getGridHeaderRowCells();
83 for (int i = 0; i < indices.length; i++) {
84 assertColumnHeader("HEADER (0," + indices[i] + ")", headers.get(i));
88 protected void toggleColumnReorder() {
89 selectMenuPath("Component", "State", "Column Reordering");
92 protected boolean isRowSelected(int index) {
93 boolean selected = getGridElement().getRow(index).isSelected();
97 protected void setSelectionModelMulti() {
98 setSelectionModel("multi");
101 protected void setSelectionModelSingle(boolean deselectAllowed) {
102 String mode = "single";
103 if (!deselectAllowed) {
104 mode += " (no deselect)";
106 setSelectionModel(mode);
109 protected void setSelectionModelNone() {
110 setSelectionModel("none");
113 protected void setSelectionModel(String model) {
114 selectMenuPath("Component", "State", "Selection mode", model);