summaryrefslogtreecommitdiffstats
path: root/compatibility-server/src/test
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-10-15 22:44:27 +0300
committerPekka Hyvönen <pekka@vaadin.com>2016-12-09 09:39:00 +0200
commit22c372b7a5cc6540d45b9add88d447ff52eab62d (patch)
tree0bf137e948d906d28167dc87e353ce3d4016c0b9 /compatibility-server/src/test
parenta48e26b9b897a721527d5731a44a587294cdb4ea (diff)
downloadvaadin-framework-22c372b7a5cc6540d45b9add88d447ff52eab62d.tar.gz
vaadin-framework-22c372b7a5cc6540d45b9add88d447ff52eab62d.zip
Send selection change events when changing selection mode (#20391)
Change-Id: Iaeb772981f3ac039bf0fe3cde595cfdb3691cddf
Diffstat (limited to 'compatibility-server/src/test')
-rw-r--r--compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java
index afc38a4201..2421e8d07a 100644
--- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java
+++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Collection;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -374,4 +375,37 @@ public class GridSelectionTest {
assertEquals("selectedRows is correct", itemId2Present,
grid.getSelectedRow());
}
+
+ @Test
+ public void selectionChangeEventWhenChangingSelectionModeSingleToNone() {
+ grid.select(itemId1Present);
+ Assert.assertEquals(itemId1Present, grid.getSelectedRow());
+ mockListener.clearEvent();
+ grid.setSelectionMode(SelectionMode.NONE);
+ assertTrue(mockListener.eventHasHappened());
+ assertTrue(mockListener.getRemoved().contains(itemId1Present));
+ }
+
+ @Test
+ public void selectionChangeEventWhenChangingSelectionModeMultiToNone() {
+ grid.setSelectionMode(SelectionMode.MULTI);
+ grid.select(itemId1Present);
+ grid.select(itemId2Present);
+ mockListener.clearEvent();
+ grid.setSelectionMode(SelectionMode.NONE);
+ assertTrue(mockListener.eventHasHappened());
+ assertTrue(mockListener.getRemoved().contains(itemId1Present));
+ assertTrue(mockListener.getRemoved().contains(itemId2Present));
+ }
+
+ @Test
+ public void noSelectionChangeEventWhenChanginModeWithNoneSelected() {
+ mockListener.clearEvent();
+ grid.setSelectionMode(SelectionMode.SINGLE);
+ assertFalse(mockListener.eventHasHappened());
+ grid.setSelectionMode(SelectionMode.NONE);
+ assertFalse(mockListener.eventHasHappened());
+ grid.setSelectionMode(SelectionMode.MULTI);
+ assertFalse(mockListener.eventHasHappened());
+ }
}