1 /*
2  *   Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
3  *
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.
8  *
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  *
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
17  *
18  *
19  */
20 
21 #define INPUT_FILENAME "streamingSoundTest2.swf"
22 
23 #include "MovieTester.h"
24 #include "MovieClip.h"
25 #include "DisplayObject.h"
26 #include "DisplayList.h"
27 #include "log.h"
28 #include "GnashException.h"
29 #include "GnashSleep.h"
30 
31 #include "check.h"
32 
33 #include <string>
34 #include <iostream>
35 #include <cassert>
36 #include <memory>
37 
38 using namespace gnash;
39 using namespace std;
40 
41 TRYMAIN(_runtest);
42 int
trymain(int,char **)43 trymain(int /*argc*/, char** /*argv*/)
44 {
45     string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
46 
47     gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
48 
49     MovieTester tester(filename);
50 
51     dbglogfile.setVerbosity(1);
52 
53     MovieClip* root = tester.getRootMovie();
54     assert(root);
55 
56     check_equals(root->get_frame_count(), 48);
57 
58     if (!tester.canTestSound()) {
59         cout << "UNTESTED: sounds can't be tested with this build." << endl;
60         return EXIT_SUCCESS; // so testing doesn't abort
61     }
62 
63     check_equals(tester.streamingSound(), true);
64 
65     // The Movie contains a sprite with a streaming sound. The sprite
66     // has 4 frames, the movie 8. We expect the streaming sound to play
67     // twice through.
68 
69     while (root->get_current_frame() < root->get_frame_count() - 1) {
70 
71         // Check twice per frame so we don't get out of sync.
72         tester.advanceClock(10);
73         tester.advance(false);
74 
75         check_equals(tester.streamingSound(), true);
76     }
77 
78     return EXIT_SUCCESS;
79 }
80 
81