From 4dcace7123b605115efcbb395a320d460eed9c0e Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Wed, 30 Jul 2014 12:04:47 +0300 Subject: SortLabelsInTable test upgrade (#14292) Change-Id: I07d2b0882ea5520f3d7ec30e29d4c42fb9167c9c --- .../tests/components/table/SortLabelsInTable.java | 13 +-- .../components/table/SortLabelsInTableTest.java | 93 ++++++++++++++++++++++ 2 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/SortLabelsInTableTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/table/SortLabelsInTable.java b/uitest/src/com/vaadin/tests/components/table/SortLabelsInTable.java index 0dc8584169..499cce58c8 100644 --- a/uitest/src/com/vaadin/tests/components/table/SortLabelsInTable.java +++ b/uitest/src/com/vaadin/tests/components/table/SortLabelsInTable.java @@ -16,14 +16,16 @@ package com.vaadin.tests.components.table; import com.vaadin.data.Item; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Label; import com.vaadin.ui.Table; -public class SortLabelsInTable extends TestBase { +public class SortLabelsInTable extends AbstractTestUI { + @SuppressWarnings("unchecked") @Override - protected void setup() { + protected void setup(VaadinRequest request) { Table t = new Table("A table with a text column and a Label column"); t.addContainerProperty("text", String.class, null); t.addContainerProperty("label", Label.class, null); @@ -37,9 +39,8 @@ public class SortLabelsInTable extends TestBase { } @Override - protected String getDescription() { - // TODO Auto-generated method stub - return null; + protected String getTestDescription() { + return "Tests that Labels are sorted in the same way than Strings are."; } @Override diff --git a/uitest/src/com/vaadin/tests/components/table/SortLabelsInTableTest.java b/uitest/src/com/vaadin/tests/components/table/SortLabelsInTableTest.java new file mode 100644 index 0000000000..54b5cad9b2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/SortLabelsInTableTest.java @@ -0,0 +1,93 @@ +/* + * 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 static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests sorting labels in table. + * + * @author Vaadin Ltd + */ +public class SortLabelsInTableTest extends MultiBrowserTest { + + @Test + public void testSorting() { + openTestURL(); + + TableElement table = $(TableElement.class).first(); + + // check unsorted + assertEquals("Text 0", table.getCell(0, 0).getText()); + assertEquals("Label 0", table.getCell(0, 1).getText()); + assertEquals("Text 14", table.getCell(14, 0).getText()); + assertEquals("Label 14", table.getCell(14, 1).getText()); + + // sort by first column (ascending order) + table.getHeaderCell(0).click(); + + // check sorted + assertEquals("Text 0", table.getCell(0, 0).getText()); + assertEquals("Label 0", table.getCell(0, 1).getText()); + assertEquals("Text 10", table.getCell(2, 0).getText()); + assertEquals("Label 10", table.getCell(2, 1).getText()); + assertEquals("Text 19", table.getCell(11, 0).getText()); + assertEquals("Label 19", table.getCell(11, 1).getText()); + assertEquals("Text 4", table.getCell(14, 0).getText()); + assertEquals("Label 4", table.getCell(14, 1).getText()); + + // sort by first column (descending order) + table.getHeaderCell(0).click(); + + // check sorted + assertEquals("Text 9", table.getCell(0, 0).getText()); + assertEquals("Label 9", table.getCell(0, 1).getText()); + assertEquals("Text 19", table.getCell(8, 0).getText()); + assertEquals("Label 19", table.getCell(8, 1).getText()); + assertEquals("Text 13", table.getCell(14, 0).getText()); + assertEquals("Label 13", table.getCell(14, 1).getText()); + + // sort by second column (descending order) + table.getHeaderCell(1).click(); + + // check no change + assertEquals("Text 9", table.getCell(0, 0).getText()); + assertEquals("Label 9", table.getCell(0, 1).getText()); + assertEquals("Text 19", table.getCell(8, 0).getText()); + assertEquals("Label 19", table.getCell(8, 1).getText()); + assertEquals("Text 13", table.getCell(14, 0).getText()); + assertEquals("Label 13", table.getCell(14, 1).getText()); + + // sort by second column (ascending order) + table.getHeaderCell(1).click(); + + // check back to first sorting results + assertEquals("Text 0", table.getCell(0, 0).getText()); + assertEquals("Label 0", table.getCell(0, 1).getText()); + assertEquals("Text 10", table.getCell(2, 0).getText()); + assertEquals("Label 10", table.getCell(2, 1).getText()); + assertEquals("Text 19", table.getCell(11, 0).getText()); + assertEquals("Label 19", table.getCell(11, 1).getText()); + assertEquals("Text 4", table.getCell(14, 0).getText()); + assertEquals("Label 4", table.getCell(14, 1).getText()); + } + +} -- cgit v1.2.3