View Javadoc
1 /* 2 * Angkor Web Framework 3 * 4 * Distributable under LGPL license. 5 * See terms of license at gnu.org. 6 */ 7 8 package com.tirsen.angkor.test.unit; 9 10 import junit.framework.TestCase; 11 12 import java.util.EventListener; 13 import java.util.EventObject; 14 15 import com.tirsen.angkor.*; 16 import com.tirsen.angkor.event.*; 17 18 /*** 19 * <!-- $Id: EventQueueTest.java,v 1.1 2002/10/07 19:49:23 tirsen Exp $ --> 20 * <!-- $Author: tirsen $ --> 21 * 22 * @author Jon Tirs´n (tirsen@users.sourceforge.net) 23 * @version $Revision: 1.1 $ 24 */ 25 public class EventQueueTest extends TestCase 26 { 27 public EventQueueTest(String s) 28 { 29 super(s); 30 } 31 32 public class MyEvent extends EventObject 33 { 34 public MyEvent(Object source) 35 { 36 super(source); 37 } 38 } 39 40 public interface MyEventListener extends EventListener 41 { 42 void eventHappened(MyEvent evt); 43 } 44 45 private class ListenerImpl implements MyEventListener, ActionListener 46 { 47 private EventObject receivedEvent; 48 49 public EventObject getReceivedEvent() 50 { 51 return receivedEvent; 52 } 53 54 public void eventHappened(MyEvent evt) 55 { 56 this.receivedEvent = evt; 57 } 58 59 public void actionPerformed(ActionEvent evt) 60 { 61 this.receivedEvent = evt; 62 } 63 } 64 65 public void testSignalEvent() throws Exception 66 { 67 ListenerImpl listener = new ListenerImpl(); 68 69 EventQueue queue = new EventQueue(); 70 71 Object source = new Object(); 72 MyEvent my = new MyEvent(source); 73 queue.postEvent(MyEventListener.class, listener, my, "eventHappened"); 74 75 queue.processEvents(null); 76 77 assertSame("listener did not receive the correct my event", listener.getReceivedEvent(), my); 78 79 ActionEvent action = new ActionEvent(source); 80 queue.postEvent(ActionListener.class, listener, action, "actionPerformed"); 81 82 queue.processEvents(null); 83 assertSame("listener did not receive the correct action event", listener.getReceivedEvent(), action); 84 } 85 }

This page was automatically generated by Maven