summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2015-11-19 15:10:56 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-11-25 09:57:05 +0000
commitb4d0865f93c5ba8e08957812bc563f4ad2e9d00f (patch)
tree42ca61d21153e0d8abebc4e32002c4bb56770153 /uitest
parent082851e5479a19df17084598944b45b53b38fd73 (diff)
downloadvaadin-framework-b4d0865f93c5ba8e08957812bc563f4ad2e9d00f.tar.gz
vaadin-framework-b4d0865f93c5ba8e08957812bc563f4ad2e9d00f.zip
Add stylename to sortable Grid header cells (#16991)
Change-Id: I6c151829236928129c258a99177431d0b972f146
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java3
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/SortableHeaderStyles.java67
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/SortableHeaderStylesTest.java51
3 files changed, 120 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java b/uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java
index 708c3a827d..3f17d9a80c 100644
--- a/uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java
@@ -90,6 +90,7 @@ public class GridEditorUITest extends MultiBrowserTest {
saveEditor();
- assertThat(headerCell.getAttribute("class"), not(containsString("sort")));
+ assertThat(headerCell.getAttribute("class"),
+ not(containsString("sort-")));
}
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/SortableHeaderStyles.java b/uitest/src/com/vaadin/tests/components/grid/SortableHeaderStyles.java
new file mode 100644
index 0000000000..56e6c608b3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/SortableHeaderStyles.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2014 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.Collection;
+
+import com.vaadin.annotations.Theme;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.util.PersonContainer;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
+import com.vaadin.ui.OptionGroup;
+
+@Theme("valo")
+public class SortableHeaderStyles extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ getPage()
+ .getStyles()
+ .add(".valo .v-grid-header th.v-grid-cell.sortable { font-weight: bold;}");
+
+ PersonContainer container = PersonContainer.createWithTestData();
+
+ Collection<?> sortableContainerPropertyIds = container
+ .getSortableContainerPropertyIds();
+
+ final OptionGroup sortableSelector = new OptionGroup(
+ "Sortable columns", sortableContainerPropertyIds);
+ sortableSelector.setMultiSelect(true);
+ sortableSelector.setValue(sortableContainerPropertyIds);
+
+ final Grid grid = new Grid(container);
+
+ sortableSelector.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Collection<?> sortableCols = (Collection<?>) sortableSelector
+ .getValue();
+ for (Column column : grid.getColumns()) {
+ column.setSortable(sortableCols.contains(column
+ .getPropertyId()));
+ }
+ }
+ });
+
+ addComponent(sortableSelector);
+ addComponent(grid);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/SortableHeaderStylesTest.java b/uitest/src/com/vaadin/tests/components/grid/SortableHeaderStylesTest.java
new file mode 100644
index 0000000000..32a896603b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/SortableHeaderStylesTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2014 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 $(GridElement.class).first().getHeaderCell(0, column)
+ .getAttribute("class").contains("sortable");
+ }
+}