summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2015-11-19 14:31:46 +0200
committerVaadin Code Review <review@vaadin.com>2015-11-27 09:20:27 +0000
commit5f42729e994821bbf84b1160083348c62b5353e9 (patch)
treefd4859cad853464f38d2a6bf6f2719fa533e8d17 /uitest
parent8d1d9618a09b76b79ff4f24a93977f4fea4b2f0e (diff)
downloadvaadin-framework-5f42729e994821bbf84b1160083348c62b5353e9.tar.gz
vaadin-framework-5f42729e994821bbf84b1160083348c62b5353e9.zip
Add stylename to sortable Table header cells (#8219)
Change-Id: I4774b4079f5c564fdc67e8cabf89278ad7cf2f6f
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/table/DisabledSortingTableTest.java2
-rw-r--r--uitest/src/com/vaadin/tests/components/table/SortableHeaderStyles.java64
-rw-r--r--uitest/src/com/vaadin/tests/components/table/SortableHeaderStylesTest.java51
3 files changed, 116 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/DisabledSortingTableTest.java b/uitest/src/com/vaadin/tests/components/table/DisabledSortingTableTest.java
index bb15301eee..73a5e68da9 100644
--- a/uitest/src/com/vaadin/tests/components/table/DisabledSortingTableTest.java
+++ b/uitest/src/com/vaadin/tests/components/table/DisabledSortingTableTest.java
@@ -85,7 +85,7 @@ public class DisabledSortingTableTest extends MultiBrowserTest {
waitUntil(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver input) {
- return className.equals(header.getAttribute("class"));
+ return header.getAttribute("class").contains(className);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/table/SortableHeaderStyles.java b/uitest/src/com/vaadin/tests/components/table/SortableHeaderStyles.java
new file mode 100644
index 0000000000..a41f4248d9
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/SortableHeaderStyles.java
@@ -0,0 +1,64 @@
+/*
+ * 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.table;
+
+import java.util.Collection;
+
+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.OptionGroup;
+import com.vaadin.ui.Table;
+
+public class SortableHeaderStyles extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ getPage().getStyles().add(
+ ".v-table-header-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 Table table = new Table() {
+ @Override
+ public Collection<?> getSortableContainerPropertyIds() {
+ return (Collection<?>) sortableSelector.getValue();
+ }
+ };
+ table.setContainerDataSource(container);
+
+ sortableSelector.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ // Trigger repaint that will read the value again
+ table.markAsDirty();
+ }
+ });
+
+ addComponent(sortableSelector);
+ addComponent(table);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/SortableHeaderStylesTest.java b/uitest/src/com/vaadin/tests/components/table/SortableHeaderStylesTest.java
new file mode 100644
index 0000000000..060b3a661a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/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.table;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.OptionGroupElement;
+import com.vaadin.testbench.elements.TableElement;
+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 $(TableElement.class).first().getHeaderCell(column)
+ .getAttribute("class").contains("sortable");
+ }
+}