1//
2//   Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011, 2012
3//      2013 Free Software
4//   Foundation, Inc
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 3 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19//
20
21// Test case for NetStream ActionScript class
22// compile this test case with Ming makeswf, and then
23// execute it like this gnash -1 -r 0 -v out.swf
24
25
26rcsid="NetStream.as";
27#include "check.as"
28
29#if OUTPUT_VERSION < 6
30
31// Added in SWF6; some versions of the pp won't care, but not
32// testing anyway.
33// Use changes quite significantly from SWF6 (connections to media
34// server) to SWF7 (streaming from various sources).
35
36#else // OUTPUT_VERSION >= 6
37
38check_equals(typeof(NetStream), 'function');
39check_equals(typeof(NetStream.prototype), 'object');
40
41var netstreamObj = new NetStream;
42
43
44/* Constructor */
45
46// test the NetStream constuct FAILED: ! NetStream.prototype.hasOwnProperty('bufferLength')or
47check_equals ( typeof(netstreamObj), 'object' );
48
49
50/*
51 * These properties should not yet exist. They may be added  *
52 * when the NetStream connection is established.             *
53 *                                                           */
54
55check(! NetStream.prototype.hasOwnProperty('currentFps'));
56check(! netstreamObj.hasOwnProperty('currentFps'));
57
58check(! NetStream.prototype.hasOwnProperty('bufferLength'));
59check(! netstreamObj.hasOwnProperty('bufferLength'));
60
61check(! NetStream.prototype.hasOwnProperty('bufferTime'));
62check(! netstreamObj.hasOwnProperty('bufferTime'));
63
64check(! NetStream.prototype.hasOwnProperty('liveDelay'));
65check(! netstreamObj.hasOwnProperty('liveDelay'));
66
67check(! NetStream.prototype.hasOwnProperty('time'));
68check(! netstreamObj.hasOwnProperty('time'));
69
70/* Added in SWF7 (still apply to SWF6) */
71check(! NetStream.prototype.hasOwnProperty('bytesLoaded'));
72check(! netstreamObj.hasOwnProperty('bytesLoaded'));
73
74check(! NetStream.prototype.hasOwnProperty('bytesTotal'));
75check(! netstreamObj.hasOwnProperty('bytesTotal'));
76
77check( NetStream.prototype.hasOwnProperty('close'));
78check(! netstreamObj.hasOwnProperty('close'));
79
80check( NetStream.prototype.hasOwnProperty('pause'));
81check(! netstreamObj.hasOwnProperty('pause'));
82
83check( NetStream.prototype.hasOwnProperty('play'));
84check(! netstreamObj.hasOwnProperty('play'));
85
86
87/* Subscriber Methods */
88
89# if OUTPUT_VERSION > 5
90// test the NetStream::close method
91check_equals ( typeof(netstreamObj.close), 'function' );
92// test the NetStream::setBufferTime method
93check_equals ( typeof(netstreamObj.setBufferTime), 'function');
94# else
95// this is verified on at least one pp version for SWF5, but we
96// aren't testing it.
97// test the NetStream::close method
98check_equals ( typeof(netstreamObj.close), 'undefined' );
99// test the NetStream::setBufferTime method
100check_equals ( typeof(netstreamObj.setBufferTime), 'undefined');
101# endif
102check_equals ( typeof(netstreamObj.pause), 'function' );
103// test the NetStream::play method
104check_equals ( typeof(netstreamObj.play), 'function');
105// test the NetStream::seek method
106check_equals ( typeof(netstreamObj.seek), 'function' );
107
108// receiveAudio (use with media server)
109check_equals ( typeof(netstreamObj.receiveAudio()), 'undefined');
110// receiveVideo (use with media server)
111check_equals ( typeof(netstreamObj.receiveVideo()), 'undefined');
112
113# if OUTPUT_VERSION == 6
114check_equals ( typeof(netstreamObj.setbuffertime), 'function');
115# else
116// SWF7 up is case-sensitive !
117check_equals ( typeof(netstreamObj.setbuffertime), 'undefined');
118# endif
119
120
121/* Publisher Methods */
122
123// For use with a media server, in SWF6
124// test attachAudio
125check_equals ( typeof(netstreamObj.attachAudio()), 'undefined');
126// test attachVideo
127check_equals ( typeof(netstreamObj.attachVideo()), 'undefined');
128// test publish
129check_equals ( typeof(netstreamObj.publish()), 'undefined');
130// test send
131check_equals ( typeof(netstreamObj.send()), 'undefined');
132
133
134/* Event Handlers */
135
136check_equals(typeof(netstreamObj.onPlayStatus), 'undefined');
137netstreamObj.onPlayStatus = 4;
138check_equals(typeof(netstreamObj.onPlayStatus), 'number');
139netstreamObj.onPlayStatus = "str";
140check_equals(typeof(netstreamObj.onPlayStatus), 'string');
141
142check_equals(typeof(netstreamObj.onStatus), 'undefined');
143netstreamObj.onStatus = 4;
144check_equals(typeof(netstreamObj.onStatus), 'number');
145netstreamObj.onStatus = "str";
146check_equals(typeof(netstreamObj.onStatus), 'string');
147
148check_equals(typeof(netstreamObj.onCuePoint), 'undefined');
149netstreamObj.onCuePoint = 4;
150check_equals(typeof(netstreamObj.onCuePoint), 'number');
151netstreamObj.onCuePoint = "str";
152check_equals(typeof(netstreamObj.onCuePoint), 'string');
153
154check_equals(typeof(netstreamObj.onMetaData), 'undefined');
155netstreamObj.onMetaData = 4;
156check_equals(typeof(netstreamObj.onMetaData), 'number');
157netstreamObj.onMetaData = "str";
158check_equals(typeof(netstreamObj.onMetaData), 'string');
159
160
161/* Properties */
162
163// currentFps (read-only)
164check_equals ( typeof(netstreamObj.currentFps), 'undefined' );
165netstreamObj.currentFps = 'string';
166check_equals ( typeof(netstreamObj.currentFps), 'string' );
167netstreamObj.currentFps = false;
168check_equals ( typeof(netstreamObj.currentFps), 'boolean' );
169
170// bufferLength (read-only)
171check_equals ( typeof(netstreamObj.bufferLength), 'undefined' );
172netstreamObj.bufferLength = 'string';
173
174check_equals ( typeof(netstreamObj.bufferLength), 'string' );
175netstreamObj.bufferLength = false;
176check_equals ( typeof(netstreamObj.bufferLength), 'boolean' );
177
178// bufferTime
179check_equals ( typeof(netstreamObj.bufferTime), 'undefined' );
180netstreamObj.setBufferTime(10);
181check_equals(netstreamObj.bufferTime, NULL);
182netstreamObj.bufferTime = 20;
183check_equals(netstreamObj.bufferTime, 20);
184netstreamObj.setBufferTime = 30;
185check_equals(netstreamObj.bufferTime, 20);
186netstreamObj.setBufferTime(false);
187check_equals(netstreamObj.bufferTime, 20);
188netstreamObj.setBufferTime('string');
189check_equals(netstreamObj.bufferTime, 20);
190netstreamObj.setBufferTime('5');
191check_equals(netstreamObj.bufferTime, 20);
192
193// liveDelay (read-only)
194check_equals ( typeof(netstreamObj.liveDelay), 'undefined' );
195netstreamObj.liveDelay = 'string';
196check_equals ( typeof(netstreamObj.liveDelay), 'string' );
197
198// time (read-only)
199check_equals ( typeof(netstreamObj.time), 'undefined' );
200netstreamObj.time = 'string';
201check_equals ( typeof(netstreamObj.time), 'string' );
202
203
204/* Two properties added in SWF7 */
205
206// bytesLoaded (read-only)
207check_equals ( typeof(netstreamObj.bytesLoaded), 'undefined' );
208// bytesLoaded (read-only)
209check_equals ( typeof(netstreamObj.bytesTotal), 'undefined' );
210
211// See when NetStream object is populated
212check(! NetStream.prototype.hasOwnProperty('currentFps'));
213nc = { isConnected: true };
214netstreamObj = new NetStream(nc);
215check(! NetStream.prototype.hasOwnProperty('currentFps'));
216nc = new NetConnection();
217check(! NetStream.prototype.hasOwnProperty('currentFps'));
218netstreamObj = new NetStream(nc);
219check(! NetStream.prototype.hasOwnProperty('currentFps'));
220nc.connect(null);
221check(! NetStream.prototype.hasOwnProperty('currentFps'));
222netstreamObj = new NetStream(nc); // Here's when !
223check(NetStream.prototype.hasOwnProperty('currentFps'));
224var NetStreamProtoBackup = NetStream.prototype;
225NetStream.prototype = {};
226netstreamObj = new NetStream();
227check(!NetStream.prototype.hasOwnProperty('currentFps'));
228netstreamObj = new NetStream(nc); // And prototype is populated again!
229check(NetStream.prototype.hasOwnProperty('currentFps'));
230
231#endif // OUTPUT_VERSION >= 6
232
233#if OUTPUT_VERSION < 6
234check_totals(0);
235#else
236check_totals(74);
237#endif
238