Add unit test for flash.net.URLRequest

This commit is contained in:
Jeff Dyer 2013-06-05 16:14:47 -07:00
Родитель 9238fb3fb5
Коммит 8ef59fb012
5 изменённых файлов: 72 добавлений и 0 удалений

1
test/swfs/data.txt Normal file
Просмотреть файл

@ -0,0 +1 @@
BOO!

Просмотреть файл

@ -0,0 +1,58 @@
/* -*- Mode: java; indent-tabs-mode: nil -*- */
/*
Compiled with:
java -jar utils/asc.jar -import playerglobal.abc -swf URLRequestTest,100,100 test/swfs/flash_net_URLRequest.as
*/
package {
import flash.display.Sprite;
import flash.events.Event;
public class URLRequestTest extends Sprite {
public var loader;
public function URLRequestTest() {
loader = new TestObject();
}
}
}
import flash.display.*;
import flash.events.*;
import flash.net.*;
class TestObject extends URLLoader {
private var bgColor: uint = 0xFFCC00;
private var pos: uint = 10;
private var size: uint = 80;
private var url = "flash_net_URLRequest.as";
private var request;
public function TestObject() {
configureListeners(this);
request = new URLRequest();
request.url = "data.txt";
request.data = { "foo": 10, "bar": 20 };
request.method = "GET";
load(request);
}
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
}
private function completeHandler(event:Event):void {
var data = event.target.data;
var result = data.split("\n")[0] === "BOO!" ? "PASS" : "FAIL";
trace(result + ": flash.net::URLRequest/set url ()");
trace(result + ": flash.net::URLRequest/set data ()");
trace(result + ": flash.net::URLRequest/set method ()");
var result = request.url === "data.txt" ? "PASS" : "FAIL";
trace(result + ": flash.net::URLRequest/get url ()");
var result = request.data.bar === 20 ? "PASS" : "FAIL";
trace(result + ": flash.net::URLRequest/get data ()");
var result = request.method === "GET" ? "PASS" : "FAIL";
trace(result + ": flash.net::URLRequest/get method ()");
}
}

Двоичные данные
test/swfs/flash_net_URLRequest.swf Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,6 @@
PASS: flash.net::URLRequest/set url ()
PASS: flash.net::URLRequest/set data ()
PASS: flash.net::URLRequest/set method ()
PASS: flash.net::URLRequest/get url ()
PASS: flash.net::URLRequest/get data ()
PASS: flash.net::URLRequest/get method ()

Просмотреть файл

@ -155,6 +155,13 @@
],
"type": "stas"
},
{ "id": "flash_net_URLRequest trace",
"stas": "swfs/trace.stas",
"filenames": [
"swfs/flash_net_URLRequest.swf"
],
"type": "stas"
},
{ "id": "flash_display_Shape trace",
"stas": "swfs/trace.stas",
"filenames": [