PageRenderTime 14ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/tests/org/osflash/signals/RedispatchedEventTest.as

http://github.com/robertpenner/as3-signals
ActionScript | 51 lines | 42 code | 8 blank | 1 comment | 0 complexity | b46f4cfa211be551f7393eb2765d8627 MD5 | raw file
 1package org.osflash.signals
 2{
 3	import asunit.asserts.*;
 4	import asunit.framework.IAsync;
 5
 6	import org.osflash.signals.events.GenericEvent;
 7
 8	public class RedispatchedEventTest
 9	{	
10	    [Inject]
11	    public var async:IAsync;
12	    
13		public var completed:DeluxeSignal;
14		protected var originalEvent:GenericEvent;
15
16		[Before]
17		public function setUp():void
18		{
19			completed = new DeluxeSignal(this);
20		}
21
22		[After]
23		public function tearDown():void
24		{
25			completed.removeAll();
26			completed = null;
27		}
28		//////
29		[Test]
30		public function dispatch_event_already_dispatched_should_clone_it():void
31		{
32			completed.add(async.add(redispatchEvent, 10));
33			originalEvent = new GenericEvent();
34			completed.dispatch(originalEvent);
35		}
36		
37		private function redispatchEvent(e:GenericEvent):void
38		{
39			DeluxeSignal(e.signal).removeAll();
40			assertSame(originalEvent, e);
41			completed.add(async.add(check_redispatched_event_is_not_original, 10));
42			
43			completed.dispatch(originalEvent);
44		}
45		
46		private function check_redispatched_event_is_not_original(e:GenericEvent):void
47		{
48			assertNotSame(originalEvent, e);
49		}
50	}
51}