diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2015-10-05 17:46:28 +0300 |
---|---|---|
committer | Markus Koivisto <markus@vaadin.com> | 2015-10-09 12:33:21 +0000 |
commit | 2732b77278001c11fd5059fb89f19587302cb033 (patch) | |
tree | 2ecb166c2b0cbd1391f0f1bcd31cc58cdbec0a46 /server/tests | |
parent | 9ee97bbf72551ba650e7ea910dddaae64f6c7ef0 (diff) | |
download | vaadin-framework-2732b77278001c11fd5059fb89f19587302cb033.tar.gz vaadin-framework-2732b77278001c11fd5059fb89f19587302cb033.zip |
Add Grid column resize event API (#16838)
Change-Id: I1cdecb54b3df45b16ddf2c7b06261198be086274
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java index 2b960d26a0..da230e86c7 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java @@ -15,6 +15,9 @@ */ package com.vaadin.tests.server.component.grid; +import static org.easymock.EasyMock.and; +import static org.easymock.EasyMock.capture; +import static org.easymock.EasyMock.isA; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -29,6 +32,8 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; +import org.easymock.Capture; +import org.easymock.EasyMock; import org.junit.Before; import org.junit.Test; @@ -39,6 +44,8 @@ import com.vaadin.shared.ui.grid.GridState; import com.vaadin.shared.util.SharedUtil; import com.vaadin.ui.Grid; import com.vaadin.ui.Grid.Column; +import com.vaadin.ui.Grid.ColumnResizeEvent; +import com.vaadin.ui.Grid.ColumnResizeListener; import com.vaadin.ui.TextField; public class GridColumns { @@ -354,4 +361,34 @@ public class GridColumns { assertEquals("hidingToggleCaption", firstColumn.getHidingToggleCaption()); } + + @Test + public void testColumnSetWidthFiresResizeEvent() { + final Column firstColumn = grid.getColumns().get(0); + + // prepare a listener mock that captures the argument + ColumnResizeListener mock = EasyMock + .createMock(ColumnResizeListener.class); + Capture<ColumnResizeEvent> capturedEvent = new Capture<ColumnResizeEvent>(); + mock.columnResize(and(capture(capturedEvent), + isA(ColumnResizeEvent.class))); + EasyMock.expectLastCall().once(); + + // Tell it to wait for the call + EasyMock.replay(mock); + + // Cause a resize event + grid.addColumnResizeListener(mock); + firstColumn.setWidth(firstColumn.getWidth() + 10); + + // Verify the method was called + EasyMock.verify(mock); + + // Asserts on the captured event + ColumnResizeEvent event = capturedEvent.getValue(); + assertEquals("Event column was not first column.", firstColumn, + event.getColumn()); + assertFalse("Event should not be userOriginated", + event.isUserOriginated()); + } } |