-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add test for MovieClip._lockroot in avm1
- Loading branch information
Showing
8 changed files
with
159 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function setLock(lock) { | ||
this._lockroot = lock; | ||
} | ||
|
||
function test(lock) { | ||
trace("Child: level is " + this + ", root is " + _root + ", _lockroot is " + this._lockroot + ", parent is " + this._parent); | ||
} |
Binary file not shown.
Binary file not shown.
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,29 @@ | ||
Parent: level is _level0, root is _level0, _lockroot is false | ||
Parent: setting _lockroot to true sets it to true. | ||
Parent: setting _lockroot to false sets it to false. | ||
Parent: setting _lockroot to undefined sets it to false. | ||
Parent: setting _lockroot to null sets it to false. | ||
Parent: setting _lockroot to NaN sets it to false. | ||
Parent: setting _lockroot to -1 sets it to true. | ||
Parent: setting _lockroot to 0 sets it to false. | ||
Parent: setting _lockroot to 1 sets it to true. | ||
Parent: setting _lockroot to 1337 sets it to true. | ||
Parent: setting _lockroot to "true" sets it to true. | ||
Parent: setting _lockroot to "false" sets it to true. | ||
Parent: setting _lockroot to "foo" sets it to true. | ||
Parent: setting _lockroot to "" sets it to false. | ||
Parent: setting _lockroot to "0" sets it to true. | ||
Parent: setting _lockroot to [object Object] sets it to true. | ||
Child: level is _level0.child1, root is _level0, _lockroot is false, parent is _level0 | ||
Child: level is _level0.child2, root is _level0.child2, _lockroot is true, parent is _level0 | ||
Child: level is _level0.child3, root is _level0.child3, _lockroot is true, parent is _level0 | ||
Child: level is _level0.child1.child1, root is _level0, _lockroot is false, parent is _level0.child1 | ||
Child: level is _level0.child1.child2, root is _level0.child1.child2, _lockroot is true, parent is _level0.child1 | ||
Child: level is _level0.child1.child3, root is _level0.child1.child3, _lockroot is true, parent is _level0.child1 | ||
Child: level is _level0.child2.child1, root is _level0.child2, _lockroot is false, parent is _level0.child2 | ||
Child: level is _level0.child2.child2, root is _level0.child2.child2, _lockroot is true, parent is _level0.child2 | ||
Child: level is _level0.child2.child3, root is _level0.child2.child3, _lockroot is true, parent is _level0.child2 | ||
Child: level is _level0.child3.child1, root is _level0.child3, _lockroot is false, parent is _level0.child3 | ||
Child: level is _level0.child3.child2, root is _level0.child3.child2, _lockroot is true, parent is _level0.child3 | ||
Child: level is _level0.child3.child3, root is _level0.child3.child3, _lockroot is true, parent is _level0.child3 | ||
All tests done. |
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,122 @@ | ||
var levels = 1; | ||
|
||
function testSet(value) { | ||
var valueLabel = typeof value == "string" ? "\"" + value + "\"" : value; | ||
this._lockroot = false; | ||
this._lockroot = value; | ||
if (this._lockroot) { | ||
trace("Parent: setting _lockroot to " + valueLabel + " sets it to true."); | ||
this._lockroot = false; | ||
return; | ||
} | ||
this._lockroot = true; | ||
this._lockroot = value; | ||
if (!this._lockroot) { | ||
trace("Parent: setting _lockroot to " + valueLabel + " sets it to false."); | ||
return; | ||
} | ||
|
||
this._lockroot = false; | ||
trace("Parent: setting _lockroot to " + valueLabel + " has no effect."); | ||
} | ||
|
||
function testSelf() { | ||
// Prints _level0, _level0, false | ||
trace("Parent: level is " + this + ", root is " + _root + ", _lockroot is " + this._lockroot); | ||
|
||
// Edge case tests | ||
testSet(true); /// true | ||
testSet(false); // false | ||
testSet(undefined); //false | ||
testSet(null); // false | ||
testSet(NaN); // false | ||
testSet(-1); // true | ||
testSet(0); // false | ||
testSet(1); // true | ||
testSet(1337); // true | ||
testSet("true"); // true | ||
testSet("false"); // true | ||
testSet("foo"); // true | ||
testSet(""); // false | ||
testSet("0"); // true | ||
testSet({}); // true | ||
} | ||
|
||
function testChildren() { | ||
// 1 = normal child, lockroot unset | ||
// 2 = lockroot set on container before loading (must inherit) | ||
// 3 = lockroot set by child function | ||
|
||
// Top | ||
createEmptyMovieClip("child1", levels++); | ||
child1.loadMovie("child.swf"); | ||
createEmptyMovieClip("child2", levels++); | ||
child2._lockroot = true; | ||
child2.loadMovie("child.swf"); | ||
createEmptyMovieClip("child3", levels++); | ||
child3.loadMovie("child.swf"); | ||
|
||
// Wait for initial loads | ||
setTimeout(createGrandChildren, 50); | ||
|
||
// Test it all | ||
setTimeout(testAllChildren, 250); | ||
} | ||
|
||
function createGrandChildren() { | ||
// Each grandchild | ||
_root.child1.createEmptyMovieClip("child1", levels++); | ||
_root.child1.child1.loadMovie("child.swf"); | ||
_root.child1.createEmptyMovieClip("child2", levels++); | ||
_root.child1.child2._lockroot = true; | ||
_root.child1.child2.loadMovie("child.swf"); | ||
_root.child1.createEmptyMovieClip("child3", levels++); | ||
_root.child1.child3.loadMovie("child.swf"); | ||
|
||
_root.child2.createEmptyMovieClip("child1", levels++); | ||
_root.child2.child1.loadMovie("child.swf"); | ||
_root.child2.createEmptyMovieClip("child2", levels++); | ||
_root.child2.child2._lockroot = true; | ||
_root.child2.child2.loadMovie("child.swf"); | ||
_root.child2.createEmptyMovieClip("child3", levels++); | ||
_root.child2.child3.loadMovie("child.swf"); | ||
|
||
_root.child3.createEmptyMovieClip("child1", levels++); | ||
_root.child3.child1.loadMovie("child.swf"); | ||
_root.child3.createEmptyMovieClip("child2", levels++); | ||
_root.child3.child2._lockroot = true; | ||
_root.child3.child2.loadMovie("child.swf"); | ||
_root.child3.createEmptyMovieClip("child3", levels++); | ||
_root.child3.child3.loadMovie("child.swf"); | ||
} | ||
|
||
function testAllChildren() { | ||
_root.child1.test(); // Root is _level0, lockroot false | ||
_root.child2.test(); // Root is self, lockroot true | ||
_root.child3.setLock(true); | ||
_root.child3.test(); // Root is self, lockroot true | ||
|
||
_root.child1.child1.test(); // Root is _level0, lockroot false | ||
_root.child1.child2.test(); // Root is self, lockroot true | ||
_root.child1.child3.setLock(true); | ||
_root.child1.child3.test(); // Root is self, lockroot true | ||
|
||
_root.child2.child1.test(); // Root is _parent, lockroot true | ||
_root.child2.child2.test(); // Root is self, lockroot true | ||
_root.child2.child3.setLock(true); | ||
_root.child2.child3.test(); // Root is self, lockroot true | ||
|
||
_root.child3.child1.test(); // Root is _parent, lockroot true | ||
_root.child3.child2.test(); // Root is self, lockroot true | ||
_root.child3.child3.setLock(true); | ||
_root.child3.child3.test(); // Root is self, lockroot true | ||
|
||
trace("All tests done."); | ||
} | ||
|
||
function test() { | ||
testSelf(); | ||
testChildren(); | ||
} | ||
|
||
test(); |
Binary file not shown.
Binary file not shown.