2 // Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011, 2012
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.
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.
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
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
29 #if OUTPUT_VERSION
< 6
31 // Added in SWF6; some versions of the pp won't care, but not
33 // Use changes quite significantly from SWF6 (connections to media
34 // server) to SWF7 (streaming from various sources).
36 #else // OUTPUT_VERSION >= 6
38 check_equals
(typeof(NetStream), 'function');
39 check_equals
(typeof(NetStream.prototype
), 'object');
41 var netstreamObj
= new NetStream;
46 // test the NetStream constuct FAILED: ! NetStream.prototype.hasOwnProperty('bufferLength')or
47 check_equals
( typeof(netstreamObj
), 'object' );
51 * These properties should not yet exist. They may be added *
52 * when the NetStream connection is established. *
55 check
(! NetStream.prototype
.hasOwnProperty
('currentFps'));
56 check
(! netstreamObj
.hasOwnProperty
('currentFps'));
58 check
(! NetStream.prototype
.hasOwnProperty
('bufferLength'));
59 check
(! netstreamObj
.hasOwnProperty
('bufferLength'));
61 check
(! NetStream.prototype
.hasOwnProperty
('bufferTime'));
62 check
(! netstreamObj
.hasOwnProperty
('bufferTime'));
64 check
(! NetStream.prototype
.hasOwnProperty
('liveDelay'));
65 check
(! netstreamObj
.hasOwnProperty
('liveDelay'));
67 check
(! NetStream.prototype
.hasOwnProperty
('time'));
68 check
(! netstreamObj
.hasOwnProperty
('time'));
70 /* Added in SWF7 (still apply to SWF6) */
71 check
(! NetStream.prototype
.hasOwnProperty
('bytesLoaded'));
72 check
(! netstreamObj
.hasOwnProperty
('bytesLoaded'));
74 check
(! NetStream.prototype
.hasOwnProperty
('bytesTotal'));
75 check
(! netstreamObj
.hasOwnProperty
('bytesTotal'));
77 check
( NetStream.prototype
.hasOwnProperty
('close'));
78 check
(! netstreamObj
.hasOwnProperty
('close'));
80 check
( NetStream.prototype
.hasOwnProperty
('pause'));
81 check
(! netstreamObj
.hasOwnProperty
('pause'));
83 check
( NetStream.prototype
.hasOwnProperty
('play'));
84 check
(! netstreamObj
.hasOwnProperty
('play'));
87 /* Subscriber Methods */
89 # if OUTPUT_VERSION
> 5
90 // test the NetStream::close method
91 check_equals
( typeof(netstreamObj
.close
), 'function' );
92 // test the NetStream::setBufferTime method
93 check_equals
( typeof(netstreamObj
.setBufferTime
), 'function');
95 // this is verified on at least one pp version for SWF5, but we
97 // test the NetStream::close method
98 check_equals
( typeof(netstreamObj
.close
), 'undefined' );
99 // test the NetStream::setBufferTime method
100 check_equals
( typeof(netstreamObj
.setBufferTime
), 'undefined');
102 check_equals
( typeof(netstreamObj
.pause
), 'function' );
103 // test the NetStream::play method
104 check_equals
( typeof(netstreamObj
.play
), 'function');
105 // test the NetStream::seek method
106 check_equals
( typeof(netstreamObj
.seek
), 'function' );
108 // receiveAudio (use with media server)
109 check_equals
( typeof(netstreamObj
.receiveAudio
()), 'undefined');
110 // receiveVideo (use with media server)
111 check_equals
( typeof(netstreamObj
.receiveVideo
()), 'undefined');
113 # if OUTPUT_VERSION
== 6
114 check_equals
( typeof(netstreamObj
.setbuffertime
), 'function');
116 // SWF7 up is case-sensitive !
117 check_equals
( typeof(netstreamObj
.setbuffertime
), 'undefined');
121 /* Publisher Methods */
123 // For use with a media server, in SWF6
125 check_equals
( typeof(netstreamObj
.attachAudio
()), 'undefined');
127 check_equals
( typeof(netstreamObj
.attachVideo
()), 'undefined');
129 check_equals
( typeof(netstreamObj
.publish
()), 'undefined');
131 check_equals
( typeof(netstreamObj
.send
()), 'undefined');
136 check_equals
(typeof(netstreamObj
.onPlayStatus
), 'undefined');
137 netstreamObj
.onPlayStatus
= 4;
138 check_equals
(typeof(netstreamObj
.onPlayStatus
), 'number');
139 netstreamObj
.onPlayStatus
= "str";
140 check_equals
(typeof(netstreamObj
.onPlayStatus
), 'string');
142 check_equals
(typeof(netstreamObj
.onStatus
), 'undefined');
143 netstreamObj
.onStatus
= 4;
144 check_equals
(typeof(netstreamObj
.onStatus
), 'number');
145 netstreamObj
.onStatus
= "str";
146 check_equals
(typeof(netstreamObj
.onStatus
), 'string');
148 check_equals
(typeof(netstreamObj
.onCuePoint
), 'undefined');
149 netstreamObj
.onCuePoint
= 4;
150 check_equals
(typeof(netstreamObj
.onCuePoint
), 'number');
151 netstreamObj
.onCuePoint
= "str";
152 check_equals
(typeof(netstreamObj
.onCuePoint
), 'string');
154 check_equals
(typeof(netstreamObj
.onMetaData
), 'undefined');
155 netstreamObj
.onMetaData
= 4;
156 check_equals
(typeof(netstreamObj
.onMetaData
), 'number');
157 netstreamObj
.onMetaData
= "str";
158 check_equals
(typeof(netstreamObj
.onMetaData
), 'string');
163 // currentFps (read-only)
164 check_equals
( typeof(netstreamObj
.currentFps
), 'undefined' );
165 netstreamObj
.currentFps
= 'string';
166 check_equals
( typeof(netstreamObj
.currentFps
), 'string' );
167 netstreamObj
.currentFps
= false;
168 check_equals
( typeof(netstreamObj
.currentFps
), 'boolean' );
170 // bufferLength (read-only)
171 check_equals
( typeof(netstreamObj
.bufferLength
), 'undefined' );
172 netstreamObj
.bufferLength
= 'string';
174 check_equals
( typeof(netstreamObj
.bufferLength
), 'string' );
175 netstreamObj
.bufferLength
= false;
176 check_equals
( typeof(netstreamObj
.bufferLength
), 'boolean' );
179 check_equals
( typeof(netstreamObj
.bufferTime
), 'undefined' );
180 netstreamObj
.setBufferTime
(10);
181 check_equals
(netstreamObj
.bufferTime
, NULL
);
182 netstreamObj
.bufferTime
= 20;
183 check_equals
(netstreamObj
.bufferTime
, 20);
184 netstreamObj
.setBufferTime
= 30;
185 check_equals
(netstreamObj
.bufferTime
, 20);
186 netstreamObj
.setBufferTime
(false);
187 check_equals
(netstreamObj
.bufferTime
, 20);
188 netstreamObj
.setBufferTime
('string');
189 check_equals
(netstreamObj
.bufferTime
, 20);
190 netstreamObj
.setBufferTime
('5');
191 check_equals
(netstreamObj
.bufferTime
, 20);
193 // liveDelay (read-only)
194 check_equals
( typeof(netstreamObj
.liveDelay
), 'undefined' );
195 netstreamObj
.liveDelay
= 'string';
196 check_equals
( typeof(netstreamObj
.liveDelay
), 'string' );
199 check_equals
( typeof(netstreamObj
.time
), 'undefined' );
200 netstreamObj
.time
= 'string';
201 check_equals
( typeof(netstreamObj
.time
), 'string' );
204 /* Two properties added in SWF7 */
206 // bytesLoaded (read-only)
207 check_equals
( typeof(netstreamObj
.bytesLoaded
), 'undefined' );
208 // bytesLoaded (read-only)
209 check_equals
( typeof(netstreamObj
.bytesTotal
), 'undefined' );
211 // See when NetStream object is populated
212 check
(! NetStream.prototype
.hasOwnProperty
('currentFps'));
213 nc
= { isConnected
: true };
214 netstreamObj
= new NetStream(nc
);
215 check
(! NetStream.prototype
.hasOwnProperty
('currentFps'));
216 nc
= new NetConnection();
217 check
(! NetStream.prototype
.hasOwnProperty
('currentFps'));
218 netstreamObj
= new NetStream(nc
);
219 check
(! NetStream.prototype
.hasOwnProperty
('currentFps'));
221 check
(! NetStream.prototype
.hasOwnProperty
('currentFps'));
222 netstreamObj
= new NetStream(nc
); // Here's when !
223 check
(NetStream.prototype
.hasOwnProperty
('currentFps'));
224 var NetStreamProtoBackup
= NetStream.prototype
;
225 NetStream.prototype
= {};
226 netstreamObj
= new NetStream();
227 check
(!NetStream.prototype
.hasOwnProperty
('currentFps'));
228 netstreamObj
= new NetStream(nc
); // And prototype is populated again!
229 check
(NetStream.prototype
.hasOwnProperty
('currentFps'));
231 #endif
// OUTPUT_VERSION >= 6
233 #if OUTPUT_VERSION
< 6