diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-10-26 15:18:18 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-10-26 12:45:47 +0000 |
commit | 41fb6006d916c8cb512c9aa6fbf8e5d1f4e377db (patch) | |
tree | 68e11d3095a7610dca05908e68b4ceab2428ae16 /server/tests/src/com/vaadin | |
parent | 722464863eaaf3fa72f5e105754e38e4e3a64c57 (diff) | |
download | vaadin-framework-41fb6006d916c8cb512c9aa6fbf8e5d1f4e377db.tar.gz vaadin-framework-41fb6006d916c8cb512c9aa6fbf8e5d1f4e377db.zip |
Call UI.detach in UI cleanup (#9755)
Change-Id: I0050994247018270f8b39b103bcfdce2b5053c6f
Diffstat (limited to 'server/tests/src/com/vaadin')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/TestUICleanup.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/TestUICleanup.java b/server/tests/src/com/vaadin/tests/server/TestUICleanup.java new file mode 100644 index 0000000000..83d6838bfe --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/TestUICleanup.java @@ -0,0 +1,48 @@ +package com.vaadin.tests.server; + +import org.easymock.EasyMock; +import org.junit.Test; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinService; +import com.vaadin.server.VaadinServiceSession; +import com.vaadin.ui.UI; +import com.vaadin.ui.UI.CleanupEvent; +import com.vaadin.ui.UI.CleanupListener; + +public class TestUICleanup { + + @Test + public void uiDetach() { + VaadinService service = EasyMock.createMock(VaadinService.class); + + UI ui = EasyMock.createMock(UI.class); + ui.setSession(null); + ui.detach(); + ui.fireCleanupEvent(); + EasyMock.expect(ui.getUIId()).andReturn(1); + + EasyMock.replay(service, ui); + + VaadinServiceSession session = new VaadinServiceSession(service); + + session.cleanupUI(ui); + } + + @Test + public void uiCleanupListeners() { + CleanupListener listener = EasyMock.createMock(CleanupListener.class); + listener.cleanup(EasyMock.anyObject(CleanupEvent.class)); + + EasyMock.replay(listener); + + UI ui = new UI() { + @Override + protected void init(VaadinRequest request) { + } + }; + + ui.addCleanupListener(listener); + ui.fireCleanupEvent(); + } +} |