1 // This test relies on a default deploy of red5 on localhost
4 // makeswf -n network -o red5test.swf ../Dejagnu.swf red5test.as ../actionscript.all/dejagnu_so_fini.as
6 // firefox red5test.swf
12 #define info _root
.note
13 #define note _root
.note
14 #define fail_check _root
.fail
15 #define pass_check _root
.pass
16 #define xfail_check _root
.xfail
17 #define xpass_check _root
.xpass
19 note
("SWF" + OUTPUT_VERSION
+ " - " + System.capabilities
.version
+ "\n");
20 rcsid
="red5test.as - <bzr revno here>";
22 #include "../actionscript.all/check.as"
23 #include "../actionscript.all/utils.as"
24 #include "../actionscript.all/dejagnu.as"
28 endOfTest
= function()
30 //note("END OF TEST");
36 // -P FlashVars='hostname=localhost,rtmptport5080=rtmpport=1935'
37 if (hostname
== undefined) {
39 note
("No hostname specified, defaulting to "+hostname
);
42 if (rtmptport
== undefined) {
44 note
("No HTTP port specified, defaulting to "+rtmptport
);
47 if (rtmpport
== undefined) {
49 note
("No HTTP port specified, defaulting to "+rtmpport
);
52 nc
= new NetConnection;
53 nc
.statuses
= new Array();
54 nc
.onStatus
= function()
56 note
('NetConnection.onStatus called with args: '+dumpObject
(arguments));
59 nc
.onResult
= function()
61 note
('NetConnection.onResult called with args: '+dumpObject
(arguments));
62 if ((lastStatusArgs
[0].level
== "status") && (lastStatusArgs
[0].code
== "NetConnection.Connect.Success")) {
63 pass
("HTTP connection - status Success");
65 fail
("HTTP connection - status Success");
69 function ResultHandler
() {
70 this.onResult
= function(result
) {
71 note
('default onResult called with args: '+dumpObject
(arguments));
73 // this.onCustom = function(result) {
74 // note('default onCustom called with args: '+dumpObject(arguments));
76 // this.onDebugEvents = function(result) {
77 // note('default onDebugEvents called with args: '+dumpObject(arguments));
79 // this.onStatus = function(result) {
80 // note("default onStatus called with args: "+dumpObject(arguments));
86 rtmpuri
= "http://"+hostname
+":"+rtmptport
+"/echo/gateway";
87 note
("Connecting to "+rtmpuri
);
89 // The network connection is not opened at connect() time, but when
90 // the first call() is made.
92 if (nc
.isConnected
== false) { // now it is connected
93 pass
("HTTP connection - status isConnected");
95 fail
("HTTP connection - status isConnected");
98 nc
.onResult
= function()
100 note
("Got a connection result back from the server.");
101 if (nc
.isConnected
== true) { // now it is connected
102 pass
("HTTP connection - status isConnected");
104 fail
("HTTP connection - status isConnected");
106 lastStatusArgs
= nc
.statuses
[nc
.statuses
.length
-1];
107 if ((lastStatusArgs
[0].level
== "status") && (lastStatusArgs
[0].code
== "NetConnection.Connect.Success")) {
108 pass
("HTTP connection - status Success");
110 fail
("HTTP connection - status Success");
116 // The Red5 echo tests Null, Undefined, Boolean True, Boolean False,
117 // String, Number, Array, Object, Date, Custom Class Remote Class
120 // This call starts the actual network connection
122 o
=new ResultHandler
();
123 o
.onResult
= function()
125 note
("Got a null result back from the HTTP server."+dumpObject
(arguments));
127 if (arguments.length
== 1) {
128 if (arguments[0] == null) {
133 nc
.call
("echo", o
, null);
134 if (nc
.isConnected
== true) { // now it is connected
135 pass
("HTTP connection - status isConnected");
137 fail
("HTTP connection - status isConnected");
141 o
=new ResultHandler
();
142 o
.onResult
= function()
144 note
("Got an undefined result back from the HTTP server."+dumpObject
(arguments));
145 if (arguments.length
== 1) {
146 if (arguments[0] == undefined) {
151 nc
.call
("echo", o
, undefined);
153 // bt=new Boolean(true);
154 // o=new ResultHandler();
155 // o.onResult = function()
157 // check_equals(arguments.toString(), trued);
159 // nc.call("echo", o, bt);
161 // bf=new Boolean(false);
162 // nc.call("echo", o, bf);
167 o
=new ResultHandler
();
168 o
.onResult
= function()
170 note
("Got a string result back from the HTTP server."+dumpObject
(arguments));
171 if (arguments.length
== 1) {
172 if (arguments[0].length
== 0) {
177 nc
.call
("echo", o
, tstr
);
181 tstr2
= "Hello World!";
182 o
=new ResultHandler
();
183 o
.onResult
= function()
185 note
("Got a string result back from the HTTP server."+dumpObject
(arguments));
186 // note("ARG4 is: " +dumpObject(arguments[0]));
187 str
= arguments[0].toString
();
188 if (arguments.length
== 1) {
189 if ((arguments[0].length
== 12)
190 && (arguments[0].toString
() == "Hello World!")) {
195 nc
.call
("echo", o
, tstr2
);
197 // test1,test2,test3,test4
201 o
=new ResultHandler
();
202 o
.onResult
= function()
204 note
("Got a numerical 0 result back from the HTTP server."+dumpObject
(arguments));
205 if (arguments.length
== 1) {
206 if (arguments[0] == 0) {
211 nc
.call
("echo", o
, 0);
215 o
=new ResultHandler
();
216 o
.onResult
= function()
218 note
("Got a numerical 1 result back from the HTTP server."+dumpObject
(arguments));
219 if (arguments.length
== 1) {
220 if (arguments[0] == 1) {
225 nc
.call
("echo", o
, 1);
229 o
=new ResultHandler
();
230 o
.onResult
= function()
232 note
("Got a numerical -1 result back from the HTTP server."+dumpObject
(arguments));
233 if ((arguments.length
== 1)) {
234 note
("FIXME: "+arguments[0].to_number
());
238 nc
.call
("echo", o
, -1);
242 o
=new ResultHandler
();
243 o
.onResult
= function()
245 note
("Got a numerical 256 result back from the HTTP server."+dumpObject
(arguments));
246 if (arguments.length
== 1) {
247 if (arguments[0] == 256) {
252 nc
.call
("echo", o
, 256);
256 o
=new ResultHandler
();
257 o
.onResult
= function()
259 note
("Got a numerical -256 result back from the HTTP server."+dumpObject
(arguments));
260 if (arguments.length
== 1) {
261 if (arguments[0] == -256) {
266 nc
.call
("echo", o
, -256);
270 o
=new ResultHandler
();
271 o
.onResult
= function()
273 note
("Got a numerical 65536 result back from the HTTP server."+dumpObject
(arguments));
274 if (arguments.length
== 1) {
275 if (arguments[0] == 65536) {
280 nc
.call
("echo", o
, 65536);
284 o
=new ResultHandler
();
285 o
.onResult
= function()
287 note
("Got a numerical -65536 result back from the HTTP server."+dumpObject
(arguments));
288 if (arguments.length
== 1) {
289 if (arguments[0] == -65536) {
294 nc
.call
("echo", o
, -65536);
298 o
=new ResultHandler
();
299 o
.onResult
= function()
301 note
("Got a numerical 1.5 result back from the HTTP server."+dumpObject
(arguments));
302 if (arguments.length
== 1) {
303 if (arguments[0] == 1.5) {
308 nc
.call
("echo", o
, 1.5);
312 o
=new ResultHandler
();
313 o
.onResult
= function()
315 note
("Got a numerical -1.5 result back from the HTTPserver."+dumpObject
(arguments));
316 if (arguments.length
== 1) {
317 if (arguments[0] == -1.5) {
322 nc
.call
("echo", o
, -1.5);
326 o
=new ResultHandler
();
327 o
.onResult
= function()
329 note
("Got a numerical NaN result back from the HTTP server."+dumpObject
(arguments));
330 if (arguments.length
== 1) {
331 if (arguments[0] == NaN) {
336 nc
.call
("echo", o
, NaN);
340 o
=new ResultHandler
();
341 o
.onResult
= function()
343 note
("Got an numerical infinity result back from the HTTP server."+dumpObject
(arguments));
344 if (arguments.length
== 1) {
345 if (arguments[0] == infinity
) {
350 nc
.call
("echo", o
, infinity
);
354 o
=new ResultHandler
();
355 o
.onResult
= function()
357 note
("Got a numerical -infinity result back from the HTTP server."+dumpObject
(arguments));
358 if (arguments.length
== 1) {
359 if (arguments[0] == -infinity
) {
364 nc
.call
("echo", o
, -infinity
);
366 // o=new ResultHandler();
367 // o.onResult = function()
369 // note("Got a result back from the server.");
370 // check_equals(arguments.toString(), '1,two,true,4,5,6');
373 // nc.call("echo", o, 1, 'two', true, [4,5,6]);
375 // o=new ResultHandler();
376 // o.onResult = function()
378 // note("Got a result back from the server.");
379 // check_equals(arguments.toString(), '1,2,3');
381 // nc.call("echo", o, 1, 2, 3);
387 o
=new ResultHandler
();
388 o
.onResult
= function()
390 note
("Got an empty array result back from the HTTP server."+dumpObject
(arguments));
391 if (arguments.length
== 1) {
392 if (arguments[0].length
== 0) {
397 nc
.call
("echo", o
, tar
);
399 // Test array with only one item
403 o
=new ResultHandler
();
404 o
.onResult
= function()
406 note
("Got a single item array result back from the HTTP server."+dumpObject
(arguments));
407 if (arguments.length
== 1) {
408 if (arguments[0][0] == 1) {
413 nc
.call
("echo", o
, tar
);
415 // Test array with multiple items
421 o
=new ResultHandler
();
422 o
.onResult
= function()
424 note
("Got an 3 item array result back from the HTTP server."+dumpObject
(arguments));
425 if ((arguments.length
== 1) && (arguments[0].length
== 3)) {
426 if ((arguments[0][0] == 1) && (arguments[0][1] == 2) && (arguments[0][2] == 3)) {
430 // note(arguments[0].toString());
431 // check_equals(arguments[0].toString(), "1.2.3");
433 nc
.call
("echo", o
, tar
);
443 o
=new ResultHandler
();
444 o
.onResult
= function()
446 note
("Got a sparse result back from the HTTP server."+dumpObject
(arguments));
447 if ((arguments.length
== 1) && (arguments[0].length
== 2)) {
448 if ((arguments[0][0] == 1) && (arguments[0][1] == 5)) {
452 // check_equals(arguments.toString(), "1..,,5");
454 nc
.call
("echo", o
, tar2
);
456 // Do the tests to see what happened last, to give the callbacks time
457 // to be executed, as they're a background thread.
459 pass
("RTMPT: Echo NULL Object");
461 fail
("RTMPT: Echo NULL Object");
465 pass
("RTMPT: Echo UNDEFINED Object");
467 fail
("RTMPT: Echo UNDEFINED Object");
471 pass
("RTMPT: Echo empty String");
473 fail
("RTMPT: Echo empty String");
477 pass
("RTMPT: Echo short String");
479 fail
("RTMPT: Echo short String");
483 pass
("RTMPT: Echo Number 0");
485 fail
("RTMPT: Echo Number 0");
489 pass
("RTMPT: Echo Number 1");
491 fail
("RTMPT: Echo Number 1");
495 pass
("RTMPT: Echo Number -1");
497 fail
("RTMPT: Echo Number -1");
500 pass
("RTMPT: Echo Number 256");
502 fail
("RTMPT: Echo Number 256");
505 pass
("RTMPT: Echo Number -256");
507 fail
("RTMPT: Echo Number -256");
510 pass
("RTMPT: Echo Number 65536");
512 fail
("RTMPT: Echo Number 65536");
515 pass
("RTMPT: Echo Number -65536");
517 fail
("RTMPT: Echo Number -65536");
520 pass
("RTMPT: Echo Number 1.5");
522 fail
("RTMPT: Echo Number 1.5");
525 pass
("RTMPT: Echo Number -1.5");
527 fail
("RTMPT: Echo Number -1.5");
530 pass
("RTMPT: Echo Number NaN");
532 fail
("RTMPT: Echo Number NaN");
535 pass
("RTMPT: Echo Number Infinity");
537 fail
("RTMPT: Echo Number Infinity");
540 pass
("RTMPT: Echo Number -Infinity");
542 fail
("RTMPT: Echo Number -Infinity");
546 pass
("RTMPT: Echo empty array");
548 fail
("RTMPT: Echo empty array");
551 pass
("RTMPT: Echo 1 item array");
553 fail
("RTMPT: Echo 1 item array");
556 pass
("RTMPT: Echo 3 item array");
558 fail
("RTMPT: Echo 3 item array");
561 pass
("RTMPT: Echo sparse array");
563 fail
("RTMPT: cho sparse array");