2 * Copyright (C) 2007, 2008, 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #define INPUT_FILENAME "eventSoundTest1.swf"
23 #include "MovieTester.h"
24 #include "MovieClip.h"
25 #include "DisplayObject.h"
26 #include "DisplayList.h"
28 #include "GnashException.h"
38 using namespace gnash
;
42 main(int /*argc*/, char** /*argv*/)
44 string filename
= string(TGTDIR
) + string("/") + string(INPUT_FILENAME
);
45 auto_ptr
<MovieTester
> t
;
49 t
.reset(new MovieTester(filename
));
51 catch (const GnashException
& e
)
53 std::cerr
<< "Error initializing MovieTester: " << e
.what() << std::endl
;
57 MovieTester
& tester
= *t
;
61 MovieClip
* root
= tester
.getRootMovie();
64 VM
& vm
= getVM(*getObject(root
));
65 string_table
& st
= vm
.getStringTable();
67 if ( ! tester
.canTestSound() )
69 cout
<< "UNTESTED: sounds can't be tested with this build." << endl
;
70 return EXIT_SUCCESS
; // so testing doesn't abort
73 const int totalFrames
= root
->get_frame_count();
75 // Make sure you adjust this with the test!
76 cerr
<< "Total frames: " << totalFrames
<< endl
;
77 assert (totalFrames
== 23);
79 int numSoundsStarted
[] = {
81 4, // Multiple (+4 sounds started)
82 6, // NoMultiple (+2 sounds started)
83 9, // Trimmed (+3 sounds started)
84 14 // Attached (+5 sounds started)
87 /// Expected success for each test
96 // Advance and check...
97 int frame
= root
->get_current_frame();
99 while (frame
<= totalFrames
) {
101 if (getObject(root
)->get_member(getURI(vm
, "testReady"), &testReady
))
103 getObject(root
)->delProperty(getURI(vm
, "testReady"));
105 // When a test is ready, check the result of the previous test.
106 if (testPasses
[test
]) {
107 check_equals(tester
.soundsStarted(), numSoundsStarted
[test
]);
110 xcheck_equals(tester
.soundsStarted(), numSoundsStarted
[test
]);
113 check_equals(tester
.soundsStopped(), tester
.soundsStarted());
122 if (testPasses
[test
]) {
123 check_equals(tester
.soundsStarted(), numSoundsStarted
[test
]);
126 xcheck_equals(tester
.soundsStarted(), numSoundsStarted
[test
]);
129 // Consistency checking
131 bool endOfTestFound
= getObject(root
)->get_member(getURI(vm
, "endoftest"), &eot
);
132 check(endOfTestFound
);