1 38 package com.gargoylesoftware.htmlunit; 39 40 import java.util.Arrays; 41 import java.util.List; 42 43 import com.gargoylesoftware.base.testing.EventCatcher; 44 45 46 52 public class TopLevelWindowTest extends WebTestCase { 53 54 59 public TopLevelWindowTest( final String name ) { 60 super( name ); 61 } 62 63 67 public void testCloseOnlyWindow() throws Exception { 68 final WebClient webClient = new WebClient(); 69 final EventCatcher eventCatcher = new EventCatcher(); 70 eventCatcher.listenTo(webClient); 71 72 final WebWindow windowToClose = webClient.getCurrentWindow(); 73 ((TopLevelWindow)windowToClose).close(); 74 75 final List expectedEvents = Arrays.asList( new Object[] { 76 new WebWindowEvent(windowToClose, WebWindowEvent.CLOSE, null, null) 77 } ); 78 assertEquals( expectedEvents, eventCatcher.getEvents() ); 79 80 assertNotNull( webClient.getCurrentWindow() ); 83 assertTrue( webClient.getCurrentWindow() != windowToClose ); 84 85 assertEquals(1, webClient.getWebWindows().size()); 86 } 87 } 88 | Popular Tags |