Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/PushButtonLabs/PushButton…
- Loading branch information
Showing
6 changed files
with
203 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
test/src/com/pblabs/engine/tests/InstantiateTemplateWithEntityNameTests.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.pblabs.engine.tests | ||
{ | ||
import com.pblabs.engine.PBE; | ||
import com.pblabs.engine.entity.IEntity; | ||
|
||
import flexunit.framework.Assert; | ||
|
||
public class InstantiateTemplateWithEntityNameTests | ||
{ | ||
|
||
public var templateXML:XML = <template name="testTemplate" />; | ||
public var entityXML:XML = <entity name="testEntity" />; | ||
|
||
[Test] | ||
public function testInstantiateTemplateWithEntityName():void{ | ||
//Register xml templates to test with | ||
PBE.templateManager.addXML(templateXML, "testTemplateXML", 0); | ||
PBE.templateManager.addXML(entityXML, "testEntityXML", 0); | ||
|
||
var entity:IEntity; | ||
|
||
//Test the default behaviour | ||
entity = PBE.templateManager.instantiateEntity("testTemplate"); | ||
Assert.assertEquals("", entity.name); | ||
entity.destroy(); | ||
|
||
//Test whether the entity name is used upon a template | ||
entity = PBE.templateManager.instantiateEntity("testTemplate", "entityName"); | ||
Assert.assertEquals("entityName", entity.name); | ||
entity.destroy(); | ||
|
||
//Test the default behaviour for an entity | ||
entity = PBE.templateManager.instantiateEntity("testEntity"); | ||
Assert.assertEquals("testEntity", entity.name); | ||
entity.destroy(); | ||
|
||
//Test whether the entityname is not overriden when passing an entityName | ||
entity = PBE.templateManager.instantiateEntity("testEntity", "overrideEntityName"); | ||
Assert.assertEquals("testEntity", entity.name); | ||
entity.destroy(); | ||
|
||
//Cleanup xml | ||
PBE.templateManager.removeXML("testTemplateXML"); | ||
PBE.templateManager.removeXML("testEntityXML"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.pblabs.engine.tests | ||
{ | ||
import com.pblabs.engine.PBE; | ||
import com.pblabs.engine.entity.IEntity; | ||
import com.pblabs.engine.entity.allocateEntity; | ||
|
||
import flexunit.framework.Assert; | ||
|
||
import mx.core.UIComponent; | ||
|
||
import org.fluint.uiImpersonation.UIImpersonator; | ||
|
||
/** | ||
* Unit test for registerAlias and unregisterAlias functionality on NameManager | ||
**/ | ||
public class RegisterAliasTests | ||
{ | ||
|
||
|
||
[Test] | ||
public function testRegisterAlias():void{ | ||
var entity:IEntity = allocateEntity(); | ||
entity.initialize("testEntity"); | ||
|
||
Assert.assertNull(PBE.nameManager.lookup("testAlias")); | ||
|
||
//Register the alias and check if lookups work ok | ||
PBE.nameManager.registerAlias(entity, "testAlias"); | ||
PBE.nameManager.registerAlias(entity, "testAlias2"); | ||
Assert.assertEquals(entity, PBE.nameManager.lookup("testAlias")); | ||
Assert.assertEquals(entity, PBE.nameManager.lookup("testAlias2")); | ||
|
||
//Unregister the alias | ||
PBE.nameManager.unregisterAlias(entity, "testAlias"); | ||
Assert.assertNull(PBE.nameManager.lookup("testAlias")); | ||
Assert.assertEquals(entity, PBE.nameManager.lookup("testAlias2")); | ||
PBE.nameManager.unregisterAlias(entity, "testAlias2"); | ||
Assert.assertNull(PBE.nameManager.lookup("testAlias2")); | ||
|
||
//Try to unregister the entityname, this should not remove the entity registration | ||
PBE.nameManager.unregisterAlias(entity, "testEntity"); | ||
Assert.assertEquals(entity, PBE.nameManager.lookup("testEntity")); | ||
|
||
//Re-register the alias and destroy the entity | ||
PBE.nameManager.registerAlias(entity, "testAlias"); | ||
PBE.nameManager.registerAlias(entity, "testAlias2"); | ||
Assert.assertEquals(entity, PBE.nameManager.lookup("testAlias")); | ||
Assert.assertEquals(entity, PBE.nameManager.lookup("testAlias2")); | ||
entity.destroy(); | ||
Assert.assertNull(PBE.nameManager.lookup("testAlias")); | ||
Assert.assertNull(PBE.nameManager.lookup("testAlias2")); | ||
} | ||
} | ||
} |