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 note
("SWF" + OUTPUT_VERSION
+ " - " + System.capabilities
.version
+ "\n");
13 rcsid
="red5test.as - <bzr revno here>";
15 #define info _root
.note
16 #define note _root
.note
17 #define fail_check _root
.fail
18 #define pass_check _root
.pass
19 #define xfail_check _root
.xfail
20 #define xpass_check _root
.xpass
22 #include "../actionscript.all/check.as"
23 #include "../actionscript.all/utils.as"
27 endOfTest
= function()
34 // -P FlashVars='hostname=localhost,rtmptport5080=rtmpport=1935'
37 if (rtmpport
== undefined) {
39 note
("No RTMP port specified, defaulting to "+rtmpport
);
44 note
("Running test 1");
46 o
.onResult
= function(arg
)
48 check_equals
(arguments.length
, 1);
49 check_equals
(arg
, "hello");
50 check_equals
(typeof(arg
), "string");
53 nc
.call
("echo", o
, "hello");
58 note
("Running test 2");
60 o
.onResult
= function(arg
)
62 check_equals
(arguments.length
, 1);
63 check_equals
(typeof(arg
), "number");
66 nc
.call
("echo", o
, 24);
69 // Send several arguments, get an array back.
72 note
("Running test 3");
74 o
.onResult
= function(arg
)
76 check_equals
(arguments.length
, 1);
77 check_equals
(typeof(arg
), "object");
78 check
(arg
.hasOwnProperty
("length"));
79 check_equals
(arg
.length
, 3);
81 check_equals
(typeof(arg
[0]), "number");
83 check_equals
(typeof(arg
[1]), "object");
84 check_equals
(typeof(arg
[1].x
), "number");
85 check_equals
(arg
[1].x
, 23);
86 check_equals
(typeof(arg
[1].y
), "number");
87 check_equals
(arg
[1].y
, 67);
88 check_equals
(typeof(arg
[1].text
), "string");
89 check_equals
(arg
[1].text
, "a string");
91 check_equals
(typeof(arg
[2]), "object");
92 check_equals
(arg
[2].length
, 5);
96 nc
.call
("echo", o
, 24, { x
:23, y
:67, text
:"a string" }, [ 1, 2, 3, 4, 5] );
102 note
("Running test 4");
104 o
.onResult
= function(arg
)
106 check_equals
(arguments.length
, 1);
107 check_equals
(typeof(arg
), "object");
108 check
(arg
.hasOwnProperty
("length"));
109 check_equals
(arg
.length
, 5);
112 check_equals
(arg
[0].__proto__
, Date.prototype
);
114 check_equals
(arg
[1], null);
115 check_equals
(typeof(arg
[2]), "object");
116 check_equals
(arg
[3], undefined);
117 check_equals
(arg
[4], null);
121 nc
.call
("echo", o
, new Date(0), new String(), {}, undefined, null);
126 note
("Running test 5");
128 o
.onResult
= function(arg
)
130 fail
("onResult called when call failed");
133 nc
.onStatus
= function(obj
) {
134 check_equals
(typeof(obj
), "object");
135 check
(obj
.hasOwnProperty
("application"));
136 check
(obj
.hasOwnProperty
("level"));
137 check
(obj
.hasOwnProperty
("code"));
138 check
(obj
.hasOwnProperty
("description"));
139 check_equals
(obj
.application
, "org.red5.server.service.MethodNotFoundException");
140 check_equals
(obj
.level
, "error");
141 check_equals
(obj
.code
, "NetConnection.Call.Failed");
142 check_equals
(obj
.description
, "Method nonexistentfunc with arguments [hello, null] not found");
146 nc
.call
("nonexistentfunc", o
, "hello", null);
149 runtests
= function(nc
)
154 ncrtmp
= new NetConnection();
155 ncrtmp
.statuses
= new Array();
156 ncrtmp
.onStatus
= function()
158 this.statuses
.push
(arguments);
159 note
('NetConnection.onStatus called with args: ' + dumpObject
(arguments));
160 lastStatusArgs
= ncrtmp
.statuses
[ncrtmp
.statuses
.length
-1];
161 if ((lastStatusArgs
[0].level
== "status") && (lastStatusArgs
[0].code
== "NetConnection.Connect.Success")) {
162 pass
("RTMP connection - status Success");
164 fail
("RTMP connection - status Success");
169 rtmpuri
= "rtmp://"+hostname
+":"+rtmpport
+"/echo";
170 note
("Connecting to "+rtmpuri
);
171 ncrtmp
.connect
(rtmpuri
);