1
// LocalConnection_as.hx: ActionScript 3 "LocalConnection" class, for Gnash.
3
// Generated by gen-as3.sh on: 20090514 by "rob". Remove this
4
// after any hand editing loosing changes.
6
// Copyright (C) 2009 Free Software Foundation, Inc.
8
// This program is free software; you can redistribute it and/or modify
9
// it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation; either version 3 of the License, or
11
// (at your option) any later version.
13
// This program is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
// GNU General Public License for more details.
18
// You should have received a copy of the GNU General Public License
19
// along with this program; if not, write to the Free Software
20
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
// This test case must be processed by CPP before compiling to include the
24
// DejaGnu.hx header file for the testing framework support.
26
// There are several event handlers there, we will fix them later.
30
import flash.net.LocalConnection;
31
import flash.display.MovieClip;
33
import flash.LocalConnection;
34
import flash.MovieClip;
42
// import our testing API
45
// Class must be named with the _as suffix, as that's the same name as the file.
46
class LocalConnection_as {
47
static function main() {
48
var x1:LocalConnection = new LocalConnection();
49
//x1: rec in the old ming tests.
51
// Make sure we actually get a valid class
53
// DejaGnu.note("Type of x1: " + Type.typeof(x1)); // TObject
57
// DejaGnu.note( "LocalConnection type is" + Type.typeof(LocalConnection) );
58
// DejaGnu.note( "x1 type is" + Type.typeof(x1) );
61
// DejaGnu.note( "LocalConnection type of v9 is" + Type.typeof(LocalConnection) );
62
if (Type.typeof(LocalConnection) == ValueType.TObject && x1 != null) {
63
DejaGnu.pass("LocalConnection class exists");
65
DejaGnu.fail("LocalConnection class doesn't exist");
68
// DejaGnu.note( "LocalConnection type of v8 is" + Type.typeof(LocalConnection) );
69
if (Type.typeof(x1) == ValueType.TObject && x1 != null) {
70
DejaGnu.pass("LocalConnection class exists");
72
DejaGnu.fail("LocalConnection class doesn't exist");
76
// Tests to see if all the properties exist. All these do is test for
77
// existance of a property, and don't test the functionality at all. This
78
// is primarily useful only to test completeness of the API implementation.
79
// if (x1.client == Object) {
80
// DejaGnu.pass("LocalConnection.client property exists");
82
// DejaGnu.fail("LocalConnection.client property doesn't exist");
87
// DejaGnu.note("ME1 " + Type.typeof(String));
88
// DejaGnu.note("ME2 " + Type.typeof(x1.domain));
89
// if (Type.typeof(x1.domain)== Type.typeof(String));
91
// DejaGnu.note("Type of x1.domain " + Type.typeof(x1.domain));
94
if (Std.is(x1.domain,String) ) {
95
DejaGnu.pass("LocalConnection.domain(String) property exists");
97
DejaGnu.fail("LocalConnection.domain(String) property doesn't exist");
101
if (Type.typeof(x1.domain) == TFunction ){
102
DejaGnu.pass("LocalConnection.domain(Function) property exists");
104
DejaGnu.fail("LocalConnection.domain(Function) property doesn't exist");
108
// Tests to see if all the methods exist. All these do is test for
109
// existance of a method, and don't test the functionality at all. This
110
// is primarily useful only to test completeness of the API implementation.
116
if (Type.typeof(x1.allowDomain) == ValueType.TFunction ) {
117
DejaGnu.pass("LocalConnection::allowDomain() method exists");
119
DejaGnu.xfail("LocalConnection::allowDomain() method doesn't exist");
122
// DejaGnu.note("Warning! A event handler here: allowDomain" + Type.typeof(x1.allowDomain));
123
if (Type.typeof(x1.allowDomain) == ValueType.TFunction) {
124
DejaGnu.pass("LocalConnection::allowDomain() method exists");
126
DejaGnu.xfail("LocalConnection::allowDomain() method doesn't exist");
133
// DejaGnu.note("Type of x1.allowInsecureDomain " + Type.typeof(x1.allowInsecureDomain));
136
if (Type.typeof(x1.allowInsecureDomain) == ValueType.TFunction) {
137
DejaGnu.pass("LocalConnection::allowInsecureDomain() method exists");
139
DejaGnu.xfail("LocalConnection::allowInsecureDomain() method doesn't exist");
142
DejaGnu.note("Warning! A event handler here: allosDa " + Type.typeof(x1.allowInsecureDomain));
144
if (Type.typeof(x1.allowInsecureDomain) == ValueType.TFunction) {
145
DejaGnu.pass("LocalConnection::allowInsecureDomain() method exists");
147
DejaGnu.xfail("LocalConnection::allowInsecureDomain() method doesn't exist");
154
if (Type.typeof(x1.close) == ValueType.TFunction) {
155
DejaGnu.pass("LocalConnection::close() method exists");
157
DejaGnu.fail("LocalConnection::close() method doesn't exist");
160
if (Type.typeof(x1.close) == ValueType.TFunction) {
161
DejaGnu.pass("LocalConnection::close() method exists");
163
DejaGnu.fail("LocalConnection::close() method doesn't exist");
170
if (Type.typeof(x1.connect) == ValueType.TFunction) {
171
DejaGnu.pass("LocalConnection::connect() method exists");
173
DejaGnu.fail("LocalConnection::connect() method doesn't exist");
176
if (Type.typeof(x1.connect) == ValueType.TFunction) {
177
DejaGnu.pass("LocalConnection::connect() method exists");
179
DejaGnu.fail("LocalConnection::connect() method doesn't exist");
186
if (Type.typeof(x1.send) == ValueType.TFunction) {
187
DejaGnu.pass("LocalConnection::send() method exists");
189
DejaGnu.fail("LocalConnection::send() method doesn't exist");
192
if (Type.typeof(x1.send) == ValueType.TFunction) {
193
DejaGnu.pass("LocalConnection::send() method exists");
195
DejaGnu.fail("LocalConnection::send() method doesn't exist");
200
// Add the following Ming test ");cases
203
DejaGnu.note("\n The following tests come from the Ming test. \n Some of the tests may be duplicated ! \n" );
205
//check_equals(LocalConnection.prototype.__proto__, Object.prototype);
207
#if ( flash6 || flash7 || flash8)
208
if ( Reflect.isObject(untyped LocalConnection.__proto__)) {
209
DejaGnu.pass("LocalConnection.prototype.__proto__ field exists");
211
DejaGnu.fail("LocalConnection.prototype.__proto__ field does not exist");
216
//Not sure what happens here.
218
#if ( flash6 || flash7 || flash8)
219
if ( untyped LocalConnection.__proto__ == untyped Object.prototype) {
220
DejaGnu.pass(" LocalConnection.prototype.__proto__ references Object.prototype");
222
DejaGnu.fail(" LocalConnection.prototype.__proto__ does not reference Object.prototype");
227
#if ( flash6 || flash7 || flash8)
228
if (untyped LocalConnection.prototype.hasOwnProperty("send")){
229
DejaGnu.pass("LocalConnection.prototype. 'send' property exists");
231
DejaGnu.fail("LocalConnection.prototype. 'send' property does not exist");
234
if (untyped LocalConnection.prototype.hasOwnProperty("connect")) {
235
DejaGnu.pass("LocalConnection.prototype. 'connect' property exists");
237
DejaGnu.fail("LocalConnection.prototype. 'connect' property does not exist");
240
if (untyped LocalConnection.prototype.hasOwnProperty("close")) {
241
DejaGnu.pass("LocalConnection.prototype. 'close' property exists");
243
DejaGnu.fail("LocalConnection.prototype. 'close' property does not exist");
246
if (untyped LocalConnection.prototype.hasOwnProperty("domain")) {
247
DejaGnu.pass("LocalConnection.prototype. 'domain' property exists");
249
DejaGnu.fail("LocalConnection.prototype. 'domain' property does not exist");
253
if (untyped LocalConnection.prototype.hasOwnProperty("allowDomain")){
254
DejaGnu.xpass("LocalConnection.prototype. 'allowdomain' property exists");
256
DejaGnu.xfail("LocalConnection.prototype. 'allowdomain' should be a event handler/function");
259
if (untyped LocalConnection.prototype.hasOwnProperty("onStatus")){
260
DejaGnu.xpass("LocalConnection.prototype. 'onStatus' property exists");
262
DejaGnu.xfail("LocalConnection.prototype. 'onStatus' should be a event handler/function");
265
//check_equals (domain, "");
266
#if ( flash6 || flash7 || flash8)
267
if (x1.domain() == "localhost"){
268
DejaGnu.pass("x1.domain is 'localhost' ");
270
DejaGnu.fail("x1.domain is not 'localhost' ");
274
if (x1.domain == "localhost"){
275
DejaGnu.pass("x1.domain is 'localhost' ");
277
DejaGnu.fail("x1.domain is not 'localhost' ");
281
#if ( flash6 || flash7 || flash8 )
282
// test the LocalConnection::domain method
283
if (Type.typeof(untyped x1.domain)== TFunction){
284
DejaGnu.pass("System.security 'domain' is a function");
286
DejaGnu.fail("System.security 'domain' is not a function");
290
// test the LocalConnection::close method
291
if (Type.typeof(untyped x1.close) == TFunction) {
292
DejaGnu.pass("System.security 'close' is a function");
294
DejaGnu.fail("System.security 'close' is not a function");
297
// test the LocalConnection::connect method
298
if (Type.typeof(untyped x1.connect)== TFunction){
299
DejaGnu.pass("System.security 'connect' is a function");
301
DejaGnu.fail("System.security 'connect' is not a function");
304
// test the LocalConnection::send method
305
if (Type.typeof(untyped x1.send)== TFunction) {
306
DejaGnu.pass("System.security 'send' is a function");
308
DejaGnu.fail("System.security 'send' is not a function");
312
//Build another LocalConnection Object x2 besides x1
313
var x2:LocalConnection = new LocalConnection();
314
//x2 :snd in the old ming tests
316
DejaGnu.pass("We build two different objects: x1 != x2");
318
DejaGnu.fail("We build two different objects. But x1 equas to x2 now!");
320
#if ( flash6 || flash7 || flash8 )
321
var my_domain:String=x1.domain();
323
DejaGnu.pass("my_domain equals to 'localhost'. ");
325
DejaGnu.fail("my_domain does not equals to 'localhost'.");
330
var my_domain:String=x1.domain;
332
DejaGnu.pass("my_domain equals to 'localhost'. ");
334
DejaGnu.fail("my_domain does not equals to 'localhost'.");
339
//Start the array tests
341
var statuses:Array<Int> = new Array();
343
#if ( flash6 || flash7 || flash8 )
344
x1.onStatus = function(obj) {
345
statuses.push(obj.code);
348
//DejaGnu.note("The following test fails!!");
349
//var tempstring:String="Hello Si";
350
var ret:Bool = x1.connect("");
353
DejaGnu.pass("x1.connect is false for empty");
355
DejaGnu.fail("x1.connect should be false");
357
if (statuses.length==0){
358
DejaGnu.pass("statuses.length is zero");
360
DejaGnu.fail("statuses.length is not zero");
367
#if ( flash6 || flash7 || flash8 )
368
x1.onStatus = function(obj) {
369
statuses.push(obj.code);
371
ret = Reflect.callMethod(x1,Reflect.field(x1,"connect"),[]);
373
DejaGnu.pass("x1.connect() should be false.");
375
DejaGnu.fail("x1.connect(0 should be false!");
378
if (statuses.length==0){
379
DejaGnu.pass("statuses.length is zero");
381
DejaGnu.fail("statuses.length is not zero");
384
ret = Reflect.callMethod(x1,Reflect.field(x1,"connect"),[3]);
386
DejaGnu.pass("x1.connect(3) should be false.");
388
DejaGnu.fail("x1.connect(3) should be false!");
390
if (statuses.length==0){
391
DejaGnu.pass("statuses.length is zero");
393
DejaGnu.fail("statuses.length is not zero");
396
//'undefined' is replaced by 'null' !!!
397
//haxe can not recognize 'undefined'.
398
ret = Reflect.callMethod(x1,Reflect.field(x1,"connect"),[null]);
400
DejaGnu.pass("x1.connect(null) should be false.");
402
DejaGnu.fail("x1.connect(null) should be false!");
404
if (statuses.length==0){
405
DejaGnu.pass("statuses.length is zero");
407
DejaGnu.fail("statuses.length is not zero");
410
ret = Reflect.callMethod(x1,Reflect.field(x1,"connect"),[""]);
412
DejaGnu.pass("x1.connect('') should be false.");
414
DejaGnu.fail("x1.connect('') shoulad be false!");
416
if (statuses.length==0){
417
DejaGnu.pass("statuses.length is zero");
419
DejaGnu.fail("statuses.length is not zero");
422
ret = Reflect.callMethod(x1,Reflect.field(x1,"connect"),["string",7]);
424
DejaGnu.pass("x1.connect('string',7) should be true.");
426
DejaGnu.fail("x1.connect('string',7) shoulad be true!");
428
if (statuses.length==0){
429
DejaGnu.pass("statuses.length is zero");
431
DejaGnu.fail("statuses.length is not zero");
434
ret = Reflect.callMethod(x1,Reflect.field(x1,"connect"),["string"]);
436
DejaGnu.pass("x1.connect('string') is false since this con");
438
DejaGnu.fail("x1.connect('string') should fail");
440
if (statuses.length==0){
441
DejaGnu.pass("statuses.length is zero");
443
DejaGnu.fail("statuses.length is not zero");
447
var ret:Bool = x1.connect("string");
449
DejaGnu.pass("x1.connect('string') is true.");
451
DejaGnu.fail("x1.connect('string') should be true");
453
if (statuses.length==0){
454
DejaGnu.pass("statuses.length is zero");
456
DejaGnu.fail("statuses.length is not zero");
460
#if ( flash6 || flash7 || flash8 )
461
var result:Bool = x1.connect("lc_test");
462
if (x1.domain()== "localhost"){
463
DejaGnu.pass("x1.connect('lc_test'); x1.domain equals to 'localhost'");
465
DejaGnu.fail("x1.connect('lc_test'); x1.domain() does not equals to 'localhost'");
468
// Old NOTE: This test will fail if a shared memory segment of the same
469
// name exists. So the first time it'll pass, then it'll fail.
470
//The old notes could be wrong!!!!
473
DejaGnu.pass("x1.connect('lc_test'); result is true for the first time");
475
DejaGnu.xfail("x1.connect('lc_test'); result could be wrong after the first time'");
478
// Checks only for syntactical correctness, not success
479
// Be more careful for these test cases which touch the shared memory.
481
result=x2.send("string","string","string","string");
483
DejaGnu.pass("x2.send('String','String','String','String'); result is true for x2.send");
485
DejaGnu.fail("x2.send('String','String','String','String'); results is true for x2.send");
488
result=x2.send("lc_test", "testfunc", "val");
490
DejaGnu.pass("x2.send('lc_test','testfunc','val'); result is true for x2.send");
492
DejaGnu.fail("x2.send('lc_test','testfunc','val'); results is true for x2.send");
495
result = x2.send("lc_test", "send");
496
if (result == false){
497
DejaGnu.pass("x2.send('lc_test','send'); result is false for this x2.send");
499
DejaGnu.fail("x2.send('lc_test','send'); results should be false for this x2.send");
502
result = x2.send("lc_test", "Send");
503
if (result == false){
504
DejaGnu.pass("x2.send('lc_test','Send'); result is false for this x2.send");
506
DejaGnu.fail("x2.send('lc_test','Send'); results should be false for this x2.send");
509
result = x2.send("lc_test", "DOMAIn");
510
if (result == false){
511
DejaGnu.pass("x2.send('lc_test',''DOMAIn); result is false for this x2.send");
513
DejaGnu.fail("x2.send('lc_test','DOMAIn'); results should be false for this x2.send");
516
result = x2.send("lc_test", "close");
517
if (result == false){
518
DejaGnu.pass("x2.send('lc_test','close'); result is false for this x2.send");
520
DejaGnu.fail("x2.send('lc_test','close'); results should be false for this x2.send");
523
result = x2.send("lc_test", "conNeCt");
524
if (result == false){
525
DejaGnu.pass("x2.send('lc_test','conNeCt'); result is false for this x2.send");
527
DejaGnu.fail("x2.send('lc_test','conNeCt'); results should be false for this x2.send");
530
result = x2.send("lc_test", "onStatus");
531
if (result == false){
532
DejaGnu.pass("x2.send('lc_test','onStatus'); result is false for this x2.send");
534
DejaGnu.fail("x2.send('lc_test','onStatus'); results should be false for this x2.send");
537
result = x2.send("lc_test", "ALLOWDOMAIN");
538
if (result == false){
539
DejaGnu.pass("x2.send('lc_test','ALLOWDOMAIN');result is false for this x2.send");
541
DejaGnu.fail("x2.send('lc_test','ALLOWDOMAIN');results should be false for this x2.send");
544
result = x2.send("lc_test", "");
545
if (result == false){
546
DejaGnu.pass("x2.send('lc_test',''); result is false for this x2.send");
548
DejaGnu.fail("x2.send('lc_test',''); results should be false for this x2.send");
b'\tresult = Reflect.callMethod(x2,Reflect.field(x2,"send"),[]);'
550
if (result == false){
551
DejaGnu.pass("x2.send() should be false.");
553
DejaGnu.fail("x2.send() should be false!");
555
result = Reflect.callMethod(x2,Reflect.field(x2,"send"),[3]);
557
DejaGnu.pass("x2.send(3) should be false.");
559
DejaGnu.fail("x2.send(3) should be false!");
561
result = Reflect.callMethod(x2,Reflect.field(x2,"send"),["lc_test", 1]);
563
DejaGnu.pass("x2.send('lc_test',1) should be false.");
565
DejaGnu.fail("x2.send('lc_test',1) should be false!");
568
//built a static function, named funcname
569
result = Reflect.callMethod(x2,Reflect.field(x2,"send"),["lc_test", funcname]);
571
DejaGnu.pass("x2.send should be false.");
573
DejaGnu.fail("x2.send should false!");
576
// But anything else is fine.
577
result = x2.send("lc_test", "8");
579
DejaGnu.pass("x2.send('lc_test', '8'); result is true");
581
DejaGnu.fail("x2.send('lc_test','8'); results should be true");
584
result = x2.send("lc_test", "ß");
586
DejaGnu.pass("x2.send('lc_test','ß'); result is true");
588
DejaGnu.fail("x2.send('lc_test','ß'); results should be true");
591
result = x2.send("lc_test", "&");
593
DejaGnu.pass("result is true");
595
DejaGnu.fail("result should be true");
597
result = x2.send("lc_test", ".");
599
DejaGnu.pass("x2.send('lc_test', '.'); result is true");
601
DejaGnu.fail(" x2.send('lc_test', '.'); results should be true");
603
result = x2.send("lc_test", "g.");
605
DejaGnu.pass(" x2.send(lc_test','g.'); result is true");
607
DejaGnu.fail(" x2.send('lc_test', 'g.'); fresults should be true");
610
result = x2.send("lc_test", "getSeconds");
612
DejaGnu.pass(" x2.send('lc_test','getSeconds');result is true");
614
DejaGnu.fail(" x2.send('lc_test','getSeconds');results should be true");
617
var funcname:String = "onFullScreen";
618
result = x2.send("lc_test", funcname);
620
DejaGnu.pass("x2.send('lc_test',funcname); result is true");
622
DejaGnu.fail("x2.send('lc_test',funcname); results should be true");
631
// Call this after finishing all tests. It prints out the totals.
636
// The following ming tests have not been implemented for some reasons.
639
result = snd.send("lc_test", funcname);
640
check_equals (result, false);
647
static function funcname () {}
652
// indent-tabs-mode: t