2 * Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Zou Lunkai, zoulunkai@gmail.com
25 * frame1: tests simulate the layout of youtube player2.swf
26 * frame2: export libItem1, export libItem2
27 * frame3: DoInitAction(libItem1), DoInitAction(libItem2), PlaceObject(libItem2)
28 * "Object.registerClass('libItem1', theClass1)" is called in DoInitAction(libItem1)
29 * "Object.registerClass('libItem2', theClass2)" is called in DoInitAction(libItem2)
31 * the effect of "Object.registerClass('libItem2', theClass2)" is not visible
32 * in DoInitAction(libItem2). Note: there's no attachMovie for libItem2 in DoInitAction(libItem2)
35 // use swf6 for case sensitiviness
36 .flash bbox=800x600 filename="registerclass_test3.sc" background=white version=6 fps=12
39 .box b1 fill=green width=100 height=100
45 // make sure Dejagnu is available in the first frame
49 // Define fullDisplay and export it
54 note("root DoAction of frame1");
55 check_equals(typeof(player.movie), 'movieclip');
56 check_equals(player.movie.__proto__, logic_Movie.prototype);
57 player.movie.setMovie();
58 check_equals(_root.testvar, 100);
62 // Place a child sprite name it as 'movie'
63 .put movie=fullDisplay
67 note("root first InitAction of frame1 (where we check if object placed after is visible)");
68 check_equals(typeof(player.movie), 'movieclip');
69 check_equals(player.movie.__proto__, MovieClip.prototype);
72 // Place sprite id141 and name it as 'player'
75 // Define _Packages.logic.Movie and export it
76 .sprite _Packages.logic.Movie
79 // Define class logic_Movie
80 .initaction _Packages.logic.Movie:
81 note("root second InitAction of frame1 (where the class is defined)");
82 check_equals(typeof(player.movie), 'movieclip');
83 check_equals(player.movie.__proto__, MovieClip.prototype);
84 logic_Movie = function() {};
85 logic_Movie.prototype = new MovieClip();
86 logic_Movie.prototype.setMovie = function () { _root.testvar = 100; };
89 // register sprite player.movie to class logic_Movie
90 .initaction fullDisplay:
91 note("root third InitAction of frame1 (where registerClass is invoked)");
92 Object.registerClass("fullDisplay", logic_Movie);
105 .sprite libItem1 // Define a sprite libItem1
108 .sprite libItem2 // Define a sprite libItem2
116 // registerClass effects are visible here
117 check_equals(libItem2.__proto__, theClass2.prototype);
120 .initaction libItem1:
121 theClass1 = function() { this.testvar = 60;};
122 theClass1.prototype = new MovieClip();
123 Object.registerClass('libItem1', theClass1);
125 _root.attachMovie('libItem1', 'clip1', 10);
126 check_equals(typeof(clip1), 'movieclip');
127 check_equals(clip1.__proto__, theClass1.prototype);
129 clip1.duplicateMovieClip("dup1", 10);
130 check_equals(typeof(dup1), 'movieclip');
131 check_equals(dup1.__proto__, theClass1.prototype);
132 check_equals(dup1.testvar, 60);
134 // sprite libItem1 never placed.
135 check_equals(typeof(libItem1), 'undefined');
137 .initaction libItem2:
138 theClass2 = function() { this.testvar = 60;};
139 theClass2.prototype = new MovieClip();
140 Object.registerClass('libItem2', theClass2);
142 // Gnash failed by executing init actions before DLIST tags.
143 check_equals(typeof(libItem2), 'movieclip');
144 check_equals(libItem2.__proto__, MovieClip.prototype);
145 check_equals(libItem2.__proto__, MovieClip.prototype);
147 // Childs of libItem2 have also been placed already
148 // Gnash fails by executing init actions before frame0 tags
149 check_equals(typeof(libItem2.child2), 'movieclip');
156 check_equals(libItem2.__proto__, theClass2.prototype);
166 .end // end of the file