1 /*
2  *   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
3  *   Free Software Foundation, Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  *
20  */
21 
22 #define INPUT_FILENAME "NetStream-SquareTest.swf"
23 
24 #include "MovieTester.h"
25 #include "VM.h"
26 #include "string_table.h"
27 #include "MovieClip.h"
28 #include "DisplayObject.h"
29 #include "DisplayList.h"
30 #include "log.h"
31 #include "GnashSleep.h"
32 
33 #include "check.h"
34 #include <string>
35 #include <cassert>
36 #include "GnashSystemIOHeaders.h"
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 	MovieTester tester(filename);
47 
48 	gnash::RcInitFile& rc = gnash::RcInitFile::getDefaultInstance();
49 	rc.addLocalSandboxPath(MEDIADIR);
50 
51 	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
52 	dbglogfile.setVerbosity(1);
53 
54 	MovieClip* root = tester.getRootMovie();
55 	assert(root);
56 
57 	if ( ! tester.canTestVideo() )
58 	{
59 		cout << "UNTESTED: NetStream video (not supported by this build)."
60 		     << endl;
61 		return EXIT_SUCCESS;
62 	}
63 
64 	// On NetStatus.Play.Stop we jump to last frame and stop,
65 	// so this loop is about equivalent to running a
66 	// generic self-contained test.
67 	//
68 	// When all possible tests are implemented as self-contained, we'll
69 	// add tests that can't be self-contained.
70 	//
71 	VM& vm = tester.vm();
72 
73 	const ObjectURI& k = getURI(vm, "startNotified");
74 	as_value tmp;
75 	while (!getObject(root)->get_member(k, &tmp) )
76 	{
77 		tester.advance();
78 
79 		// sleep to give the NetStream a chance to load
80         // data and trigger notifications
81 		// needs more analisys to find a good way for doing this..
82         gnashSleep(10000); // 10 milliseconds should be enough for loading
83 	}
84 
85 	cout << "Pressing space" << endl;
86 	tester.pressKey(key::SPACE);
87 	tester.releaseKey(key::SPACE);
88 
89     while (root->get_current_frame() < 2)
90 	{
91 		tester.advance();
92 
93 		// sleep to give the NetStream a chance to
94 		// load data and trigger notifications
95 		// needs more analisys to find a good way for doing this..
96         gnashSleep(10000); // 10 milliseconds should be enough for loading
97 	}
98 
99 	// Consistency check
100 	as_value eot;
101 	bool endOfTestFound = getObject(root)->get_member(getURI(vm, "end_of_test"),
102 		&eot);
103 	check(endOfTestFound);
104 
105 	return 0;
106 }
107 
108