@@ -0,0 +1,2519 @@
+package com.vaadin.tests.server.components;%0D%0A%0D%0Aimport java.util.HashMap;%0D%0Aimport java.util.Map;%0D%0A%0D%0Aimport junit.framework.TestCase;%0D%0A%0D%0Aimport org.easymock.EasyMock;%0D%0A%0D%0Aimport com.vaadin.ui.Window;%0D%0Aimport com.vaadin.ui.Window.CloseEvent;%0D%0Aimport com.vaadin.ui.Window.CloseListener;%0D%0Aimport com.vaadin.ui.Window.ResizeEvent;%0D%0Aimport com.vaadin.ui.Window.ResizeListener;%0D%0A%0D%0Apublic class TestWindow extends TestCase %7B%0D%0A%0D%0A    private Window window;%0D%0A%0D%0A    @Override%0D%0A    protected void setUp() throws Exception %7B%0D%0A        window = new Window();%0D%0A    %7D%0D%0A%0D%0A    public void testCloseListener() %7B%0D%0A        CloseListener cl = EasyMock.createMock(Window.CloseListener.class);%0D%0A%0D%0A        // Expectations%0D%0A        cl.windowClose(EasyMock.isA(CloseEvent.class));%0D%0A%0D%0A        // Start actual test%0D%0A        EasyMock.replay(cl);%0D%0A%0D%0A        // Add listener and send a close event -%3E should end up in listener once%0D%0A        window.addListener(cl);%0D%0A        sendClose(window);%0D%0A%0D%0A        // Ensure listener was called once%0D%0A        EasyMock.verify(cl);%0D%0A%0D%0A        // Remove the listener and send close event -%3E should not end up in%0D%0A        // listener%0D%0A        window.removeListener(cl);%0D%0A        sendClose(window);%0D%0A%0D%0A        // Ensure listener still has been called only once%0D%0A        EasyMock.verify(cl);%0D%0A%0D%0A    %7D%0D%0A%0D%0A    public void testResizeListener() %7B%0D%0A        ResizeListener rl = EasyMock.createMock(Window.ResizeListener.class);%0D%0A%0D%0A        // Expectations%0D%0A        rl.windowResized(EasyMock.isA(ResizeEvent.class));%0D%0A%0D%0A        // Start actual test%0D%0A        EasyMock.replay(rl);%0D%0A%0D%0A        // Add listener and send a resize event -%3E should end up in listener%0D%0A        // once%0D%0A        window.addListener(rl);%0D%0A        sendResize(window);%0D%0A%0D%0A        // Ensure listener was called once%0D%0A        EasyMock.verify(rl);%0D%0A%0D%0A        // Remove the listener and send close event -%3E should not end up in%0D%0A        // listener%0D%0A        window.removeListener(rl);%0D%0A        sendResize(window);%0D%0A%0D%0A        // Ensure listener still has been called only once%0D%0A        EasyMock.verify(rl);%0D%0A%0D%0A    %7D%0D%0A%0D%0A    private void sendResize(Window window2) %7B%0D%0A        Map%3CString, Object%3E variables = new HashMap%3CString, Object%3E();%0D%0A        variables.put(%22height%22, 1234);%0D%0A        window.changeVariables(window, variables);%0D%0A%0D%0A    %7D%0D%0A%0D%0A    private static void sendClose(Window window) %7B%0D%0A        Map%3CString, Object%3E variables = new HashMap%3CString, Object%3E();%0D%0A        variables.put(%22close%22, true);%0D%0A        window.changeVariables(window, variables);%0D%0A    %7D%0D%0A%7D%0D%0A

Test for Window listeners (#4222)