From cca2172654699f9e2f79e8b36c70700c248da8f2 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 18 Mar 2014 15:19:59 +0000 Subject: Revert "Merge branch 'master' into grid" This reverts commit 4420f52578e245045677f88852f1ba3f405e88a3. Change-Id: I06effe06f245baaeb499071917c359eb34cc55ea --- .../vaadin/client/ui/grid/ListDataSourceTest.java | 178 --------------------- .../vaadin/client/ui/grid/PartitioningTest.java | 104 ------------ 2 files changed, 282 deletions(-) delete mode 100644 client/tests/src/com/vaadin/client/ui/grid/ListDataSourceTest.java delete mode 100644 client/tests/src/com/vaadin/client/ui/grid/PartitioningTest.java (limited to 'client/tests') diff --git a/client/tests/src/com/vaadin/client/ui/grid/ListDataSourceTest.java b/client/tests/src/com/vaadin/client/ui/grid/ListDataSourceTest.java deleted file mode 100644 index 5c5e88bf69..0000000000 --- a/client/tests/src/com/vaadin/client/ui/grid/ListDataSourceTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2000-2013 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.client.ui.grid; - -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; - -import org.easymock.EasyMock; -import org.junit.Test; - -import com.vaadin.client.data.DataChangeHandler; -import com.vaadin.client.ui.grid.datasources.ListDataSource; - -/** - * - * @since 7.2 - * @author Vaadin Ltd - */ -public class ListDataSourceTest { - - @Test - public void testDataSourceConstruction() throws Exception { - - ListDataSource ds = new ListDataSource(0, 1, 2, 3); - - assertEquals(4, ds.getEstimatedSize()); - assertEquals(0, (int) ds.getRow(0)); - assertEquals(1, (int) ds.getRow(1)); - assertEquals(2, (int) ds.getRow(2)); - assertEquals(3, (int) ds.getRow(3)); - - ds = new ListDataSource(Arrays.asList(0, 1, 2, 3)); - - assertEquals(4, ds.getEstimatedSize()); - assertEquals(0, (int) ds.getRow(0)); - assertEquals(1, (int) ds.getRow(1)); - assertEquals(2, (int) ds.getRow(2)); - assertEquals(3, (int) ds.getRow(3)); - } - - @Test - public void testListAddOperation() throws Exception { - - ListDataSource ds = new ListDataSource(0, 1, 2, 3); - - DataChangeHandler handler = EasyMock - .createNiceMock(DataChangeHandler.class); - ds.setDataChangeHandler(handler); - - handler.dataAdded(4, 1); - EasyMock.expectLastCall(); - - EasyMock.replay(handler); - - ds.asList().add(4); - - assertEquals(5, ds.getEstimatedSize()); - assertEquals(0, (int) ds.getRow(0)); - assertEquals(1, (int) ds.getRow(1)); - assertEquals(2, (int) ds.getRow(2)); - assertEquals(3, (int) ds.getRow(3)); - assertEquals(4, (int) ds.getRow(4)); - } - - @Test - public void testListAddAllOperation() throws Exception { - - ListDataSource ds = new ListDataSource(0, 1, 2, 3); - - DataChangeHandler handler = EasyMock - .createNiceMock(DataChangeHandler.class); - ds.setDataChangeHandler(handler); - - handler.dataAdded(4, 3); - EasyMock.expectLastCall(); - - EasyMock.replay(handler); - - ds.asList().addAll(Arrays.asList(4, 5, 6)); - - assertEquals(7, ds.getEstimatedSize()); - assertEquals(0, (int) ds.getRow(0)); - assertEquals(1, (int) ds.getRow(1)); - assertEquals(2, (int) ds.getRow(2)); - assertEquals(3, (int) ds.getRow(3)); - assertEquals(4, (int) ds.getRow(4)); - assertEquals(5, (int) ds.getRow(5)); - assertEquals(6, (int) ds.getRow(6)); - } - - @Test - public void testListRemoveOperation() throws Exception { - - ListDataSource ds = new ListDataSource(0, 1, 2, 3); - - DataChangeHandler handler = EasyMock - .createNiceMock(DataChangeHandler.class); - ds.setDataChangeHandler(handler); - - handler.dataRemoved(3, 1); - EasyMock.expectLastCall(); - - EasyMock.replay(handler); - - ds.asList().remove(2); - - assertEquals(3, ds.getEstimatedSize()); - assertEquals(0, (int) ds.getRow(0)); - assertEquals(1, (int) ds.getRow(1)); - assertEquals(3, (int) ds.getRow(2)); - } - - @Test - public void testListRemoveAllOperation() throws Exception { - - ListDataSource ds = new ListDataSource(0, 1, 2, 3); - - DataChangeHandler handler = EasyMock - .createNiceMock(DataChangeHandler.class); - ds.setDataChangeHandler(handler); - - handler.dataRemoved(0, 3); - EasyMock.expectLastCall(); - - EasyMock.replay(handler); - - ds.asList().removeAll(Arrays.asList(0, 2, 3)); - - assertEquals(1, ds.getEstimatedSize()); - assertEquals(1, (int) ds.getRow(0)); - } - - @Test - public void testListClearOperation() throws Exception { - - ListDataSource ds = new ListDataSource(0, 1, 2, 3); - - DataChangeHandler handler = EasyMock - .createNiceMock(DataChangeHandler.class); - ds.setDataChangeHandler(handler); - - handler.dataRemoved(0, 4); - EasyMock.expectLastCall(); - - EasyMock.replay(handler); - - ds.asList().clear(); - - assertEquals(0, ds.getEstimatedSize()); - } - - @Test(expected = IllegalStateException.class) - public void testFetchingNonExistantItem() { - ListDataSource ds = new ListDataSource(0, 1, 2, 3); - ds.ensureAvailability(5, 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void testUnsupportedIteratorRemove() { - ListDataSource ds = new ListDataSource(0, 1, 2, 3); - ds.asList().iterator().remove(); - } - -} diff --git a/client/tests/src/com/vaadin/client/ui/grid/PartitioningTest.java b/client/tests/src/com/vaadin/client/ui/grid/PartitioningTest.java deleted file mode 100644 index e97bb339e4..0000000000 --- a/client/tests/src/com/vaadin/client/ui/grid/PartitioningTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2000-2013 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.client.ui.grid; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import com.vaadin.shared.ui.grid.Range; - -@SuppressWarnings("static-method") -public class PartitioningTest { - - @Test - public void selfRangeTest() { - final Range range = Range.between(0, 10); - final Range[] partitioning = range.partitionWith(range); - - assertTrue("before is empty", partitioning[0].isEmpty()); - assertTrue("inside is self", partitioning[1].equals(range)); - assertTrue("after is empty", partitioning[2].isEmpty()); - } - - @Test - public void beforeRangeTest() { - final Range beforeRange = Range.between(0, 10); - final Range afterRange = Range.between(10, 20); - final Range[] partitioning = beforeRange.partitionWith(afterRange); - - assertTrue("before is self", partitioning[0].equals(beforeRange)); - assertTrue("inside is empty", partitioning[1].isEmpty()); - assertTrue("after is empty", partitioning[2].isEmpty()); - } - - @Test - public void afterRangeTest() { - final Range beforeRange = Range.between(0, 10); - final Range afterRange = Range.between(10, 20); - final Range[] partitioning = afterRange.partitionWith(beforeRange); - - assertTrue("before is empty", partitioning[0].isEmpty()); - assertTrue("inside is empty", partitioning[1].isEmpty()); - assertTrue("after is self", partitioning[2].equals(afterRange)); - } - - @Test - public void beforeAndInsideRangeTest() { - final Range beforeRange = Range.between(0, 10); - final Range afterRange = Range.between(5, 15); - final Range[] partitioning = beforeRange.partitionWith(afterRange); - - assertEquals("before", Range.between(0, 5), partitioning[0]); - assertEquals("inside", Range.between(5, 10), partitioning[1]); - assertTrue("after is empty", partitioning[2].isEmpty()); - } - - @Test - public void insideRangeTest() { - final Range fullRange = Range.between(0, 20); - final Range insideRange = Range.between(5, 15); - final Range[] partitioning = insideRange.partitionWith(fullRange); - - assertTrue("before is empty", partitioning[0].isEmpty()); - assertEquals("inside", Range.between(5, 15), partitioning[1]); - assertTrue("after is empty", partitioning[2].isEmpty()); - } - - @Test - public void insideAndBelowTest() { - final Range beforeRange = Range.between(0, 10); - final Range afterRange = Range.between(5, 15); - final Range[] partitioning = afterRange.partitionWith(beforeRange); - - assertTrue("before is empty", partitioning[0].isEmpty()); - assertEquals("inside", Range.between(5, 10), partitioning[1]); - assertEquals("after", Range.between(10, 15), partitioning[2]); - } - - @Test - public void aboveAndBelowTest() { - final Range fullRange = Range.between(0, 20); - final Range insideRange = Range.between(5, 15); - final Range[] partitioning = fullRange.partitionWith(insideRange); - - assertEquals("before", Range.between(0, 5), partitioning[0]); - assertEquals("inside", Range.between(5, 15), partitioning[1]); - assertEquals("after", Range.between(15, 20), partitioning[2]); - } -} -- cgit v1.2.3