Update with current status
[gnash.git] / testsuite / misc-ming.all / red5test.as
blob43fd249ba9301e44c39ef18ae17bc6db06d0b4e5
1 // This test relies on a default deploy of red5 on localhost
2 //
3 // Build with:
4 // makeswf -n network -o red5test.swf ../Dejagnu.swf red5test.as ../actionscript.all/dejagnu_so_fini.as
5 // Run with:
6 // firefox red5test.swf
7 // Or:
8 // gnash red5test.swf
9 //
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"
25 stop();
27 endOfTest = function()
29 totals(38);
30 trace("ENDOFTEST");
31 play();
34 // -P FlashVars='hostname=localhost,rtmptport5080=rtmpport=1935'
35 hostname = RED5_HOST;
37 if (rtmpport == undefined) {
38 rtmpport = 1935;
39 note("No RTMP port specified, defaulting to "+rtmpport);
42 test1 = function(nc)
44 note("Running test 1");
45 o = {};
46 o.onResult = function(arg)
48 check_equals(arguments.length, 1);
49 check_equals(arg, "hello");
50 check_equals(typeof(arg), "string");
51 test2(nc);
53 nc.call("echo", o, "hello");
56 test2 = function(nc)
58 note("Running test 2");
59 o = {};
60 o.onResult = function(arg)
62 check_equals(arguments.length, 1);
63 check_equals(typeof(arg), "number");
64 test3(nc);
66 nc.call("echo", o, 24);
69 // Send several arguments, get an array back.
70 test3 = function(nc)
72 note("Running test 3");
73 o = {};
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);
94 test4(nc);
96 nc.call("echo", o, 24, { x:23, y:67, text:"a string" }, [ 1, 2, 3, 4, 5] );
99 // Send more things.
100 test4 = function(nc)
102 note("Running test 4");
103 o = {};
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);
111 // It's a date.
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);
119 test5(nc);
121 nc.call("echo", o, new Date(0), new String(), {}, undefined, null);
124 test5 = function(nc)
126 note("Running test 5");
127 o = {};
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");
143 endOfTest();
146 nc.call("nonexistentfunc", o, "hello", null);
149 runtests = function(nc)
151 test1(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");
163 } else {
164 fail("RTMP connection - status Success");
166 runtests(this);
169 rtmpuri = "rtmp://"+hostname+":"+rtmpport+"/echo";
170 note("Connecting to "+rtmpuri);
171 ncrtmp.connect(rtmpuri);