diff options
author | Artur Signell <artur.signell@itmill.com> | 2010-02-23 10:17:00 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2010-02-23 10:17:00 +0000 |
commit | d3d39ab75f25555ed1c58d6fe727d1d25d489a61 (patch) | |
tree | 166d5d26f182b45aa5f00f674e2466302aa27362 /tests | |
parent | 73ecd7f2a42e09868e4fd9c91073867c809836a2 (diff) | |
download | vaadin-framework-d3d39ab75f25555ed1c58d6fe727d1d25d489a61.tar.gz vaadin-framework-d3d39ab75f25555ed1c58d6fe727d1d25d489a61.zip |
Merged [11391],[11473],[11474],[11475],[11477] from 6.2
Fix and test case for #4222
svn changeset:11485/svn branch:6.3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/vaadin/tests/server/components/TestWindow.java | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/src/com/vaadin/tests/server/components/TestWindow.java b/tests/src/com/vaadin/tests/server/components/TestWindow.java new file mode 100644 index 0000000000..05604aba61 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/components/TestWindow.java @@ -0,0 +1,90 @@ +package com.vaadin.tests.server.components;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+import com.vaadin.ui.Window.ResizeEvent;
+import com.vaadin.ui.Window.ResizeListener;
+
+public class TestWindow extends TestCase {
+
+ private Window window;
+
+ @Override
+ protected void setUp() throws Exception {
+ window = new Window();
+ }
+
+ public void testCloseListener() {
+ CloseListener cl = EasyMock.createMock(Window.CloseListener.class);
+
+ // Expectations
+ cl.windowClose(EasyMock.isA(CloseEvent.class));
+
+ // Start actual test
+ EasyMock.replay(cl);
+
+ // Add listener and send a close event -> should end up in listener once
+ window.addListener(cl);
+ sendClose(window);
+
+ // Ensure listener was called once
+ EasyMock.verify(cl);
+
+ // Remove the listener and send close event -> should not end up in
+ // listener
+ window.removeListener(cl);
+ sendClose(window);
+
+ // Ensure listener still has been called only once
+ EasyMock.verify(cl);
+
+ }
+
+ public void testResizeListener() {
+ ResizeListener rl = EasyMock.createMock(Window.ResizeListener.class);
+
+ // Expectations
+ rl.windowResized(EasyMock.isA(ResizeEvent.class));
+
+ // Start actual test
+ EasyMock.replay(rl);
+
+ // Add listener and send a resize event -> should end up in listener
+ // once
+ window.addListener(rl);
+ sendResize(window);
+
+ // Ensure listener was called once
+ EasyMock.verify(rl);
+
+ // Remove the listener and send close event -> should not end up in
+ // listener
+ window.removeListener(rl);
+ sendResize(window);
+
+ // Ensure listener still has been called only once
+ EasyMock.verify(rl);
+
+ }
+
+ private void sendResize(Window window2) {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("height", 1234);
+ window.changeVariables(window, variables);
+
+ }
+
+ private static void sendClose(Window window) {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("close", true);
+ window.changeVariables(window, variables);
+ }
+}
|