2 QUnit.module("Properties", {
6 this.cb = function(e) {
7 QUnit.ok(true, "Scene loaded");
8 var iframe = document.getElementById('daliframe');
9 that.doc = iframe.contentDocument || iframe.contentWindow.document;
10 that.doc.Module.postDaliWrapperRun = function() {
11 dali = that.doc.Module;
15 loadDocument("dali-page.html"+window.location.search, this.cb);
17 teardown : function() {
18 var v = document.getElementById("daliframe");
19 v.removeEventListener("load", this.cb, true);
23 QUnit.test( "dotted property access", function( assert ) {
25 var actor = new dali.Actor();
27 assert.ok( "" === actor.name );
28 assert.ok( compareArrays(actor.position, [0, 0, 0]) );
29 assert.ok( compareArrays(actor.parentOrigin, [0, 0, 0.5]) );
33 QUnit.test( "hierarchy", function( assert ) {
35 var actor = new dali.Actor();
36 actor.parentOrigin = [0.5, 0.5, 0.5];
37 actor.anchorPoint = [0.5, 0.5, 0.5];
39 actor.name = actor.text;
40 actor.size = [100, 100, 1];
41 actor.position = [0, 0, 10];
42 dali.stage.add(actor);
44 var hello = new dali.Actor();
46 hello.name = hello.text;
49 var hellochild = new dali.Actor();
50 hellochild.text = "hello-child";
51 hellochild.name = hellochild.text;
52 hello.add(hellochild);
54 var hellochild2 = new dali.Actor();
55 hellochild2.text = "hello-child2";
56 hellochild2.name = hellochild2.text;
57 hello.add(hellochild2);
59 var hellochildchild = new dali.Actor();
60 hellochildchild.text = "hello-child-child1";
61 hellochildchild.name = "hello-child-child1";
62 hellochildchild.name = hellochildchild.text;
63 hellochild.add(hellochildchild);
66 var depthfirst = actor.findAllChildren();
68 assert.ok(actor.getChildCount() === 1);
70 var directChildren = actor.directChildren();
72 assert.ok(directChildren.length === 1);
73 assert.ok(directChildren[0].getId() === hello.getId());
75 actor.position = [100, 100, 0];
77 var root = dali.stage.getRootLayer(); //rootRotationActor;
80 assert.ok(actor.getChildCount() === 0);
83 assert.ok(actor.getChildCount() === 1);
85 var rootLayerCount = root.getChildCount();
86 dali.stage.remove(actor); // check these don't assert
87 assert.ok(root.getChildCount() === rootLayerCount - 1);
89 dali.stage.add(actor);
90 assert.ok(root.getChildCount() === rootLayerCount);
92 assert.ok(root.findChildByName("none") === null);
96 QUnit.test( "register property", function( assert ) {
98 var root = s.getRootLayer(); //rootRotationActor;
100 var another = new dali.Actor();
101 another.parentOrigin = [0.5, 0.5, 0.5];
102 another.anchorPoint = [0.5, 0.5, 0.5];
103 another.text = "peppa";
104 another.name = another.text;
105 another.size = [100, 100, 1];
106 another.position = [-50, 100, 0];
109 var c = root.getChildAt(root.getChildCount() - 1);
110 //var n = c.getChildCount();
111 var p = c.getParent();
112 assert.ok(p.getId() == root.getId());
114 var matrix = c.worldMatrix;
116 assert.ok(matrix.length === 16);
120 QUnit.test( "get/set", function( assert ) {
126 var p = actor.position;
127 actor.position = [1, 1, 1];
128 assert.ok(compareArrays(actor.position, [1, 1, 1]));
129 actor.position = [3, 3, 3];
130 assert.ok(compareArrays(actor.position, [3, 3, 3]));