Skip to content

Commit

Permalink
SignalContext constructor now accepts Context parameters and passes t…
Browse files Browse the repository at this point in the history
…hem to super(). Closes joelhooks#1.
  • Loading branch information
Robert Penner authored and destroytoday committed Feb 20, 2010
1 parent c0f418c commit f1fff6a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/org/robotlegs/mvcs/SignalContext.as
@@ -1,5 +1,6 @@
package org.robotlegs.mvcs
{
import flash.display.DisplayObjectContainer;
import org.robotlegs.base.SignalCommandMap;
import org.robotlegs.core.ISignalCommandMap;
import org.robotlegs.core.ISignalContext;
Expand All @@ -8,6 +9,11 @@ package org.robotlegs.mvcs
{
protected var _signalCommandMap:ISignalCommandMap;

public function SignalContext(contextView:DisplayObjectContainer = null, autoStartup:Boolean = true)
{
super(contextView, autoStartup);
}

public function get signalCommandMap():ISignalCommandMap
{
return _signalCommandMap || (_signalCommandMap = new SignalCommandMap(injector));
Expand All @@ -24,4 +30,4 @@ package org.robotlegs.mvcs
injector.mapValue(ISignalCommandMap, signalCommandMap);
}
}
}
}
23 changes: 22 additions & 1 deletion test/org/robotlegs/mvcs/SignalContextTests.as
@@ -1,5 +1,7 @@
package org.robotlegs.mvcs
{
import flash.display.Sprite;
import flash.events.Event;
import asunit.asserts.*;

import org.robotlegs.core.ISignalCommandMap;
Expand All @@ -26,5 +28,24 @@ package org.robotlegs.mvcs
{
assertTrue( signalContext.signalCommandMap is ISignalCommandMap );
}

[Test]
public function contextView_roundtrips_through_constructor():void
{
var contextView:Sprite = new Sprite();
signalContext = new SignalContext(contextView);

assertEquals(contextView, SignalContext(signalContext).contextView);
}

[Test]
public function autoStartup_in_constructor_creates_listener_for_ADDED_TO_STAGE_on_contextView():void
{
var contextView:Sprite = new Sprite();
var autoStartup:Boolean = false;
signalContext = new SignalContext(contextView, autoStartup);

assertTrue(contextView.hasEventListener(Event.ADDED_TO_STAGE));
}
}
}
}

0 comments on commit f1fff6a

Please sign in to comment.