Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented clone method, and unit test for it.

  • Loading branch information...
commit 4278414bde0c56e666e20882fdf0d205330b1a69 1 parent c048bc7
@mikechambers authored
View
26 src/com/adobe/air/net/events/ResourceCacheEvent.as
@@ -41,16 +41,30 @@ package com.adobe.air.net.events
public static const ITEM_READY:String = "onPathReady";
public static const ITEM_CACHED:String = "onItemCached";
- public function ResourceCacheEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
- {
- super(type, bubbles, cancelable);
- }
-
[Bindable]
public var key:String;
[Bindable]
- public var file:File;
+ public var file:File;
+
+ public function ResourceCacheEvent(type:String,
+ bubbles:Boolean=false,
+ cancelable:Boolean=false)
+ {
+ super(type, bubbles, cancelable);
+ }
+
+ public override function clone():Event
+ {
+ var out:ResourceCacheEvent = new ResourceCacheEvent(type,
+ bubbles,
+ cancelable);
+
+ out.key = key;
+ out.file = file;
+
+ return out;
+ }
}
}
View
26 tests/src/com/adobe/air/net/events/ResourceCacheEventTest.as
@@ -32,6 +32,8 @@
package com.adobe.air.net.events
{
+ import flash.filesystem.File;
+
import flexunit.framework.TestCase;
public class ResourceCacheEventTest extends TestCase
@@ -43,7 +45,29 @@ package com.adobe.air.net.events
public function test_clone():void
{
- assertTrue(false);
+ var type:String = ResourceCacheEvent.ITEM_CACHED;
+ var key:String = "foo";
+ var file:File = new File();
+
+ var original:ResourceCacheEvent = new ResourceCacheEvent(type);
+ original.key = key;
+ original.file = file;
+
+ var clone:ResourceCacheEvent = ResourceCacheEvent(original.clone());
+
+ assertTrue("original != clone", original != clone);
+
+ trace(clone.bubbles, original.bubbles);
+ assertTrue("clone.bubbles == original.bubbles",
+ clone.bubbles == original.bubbles);
+ assertTrue("clone.cancelable == original.cancelable",
+ clone.cancelable == original.cancelable);
+ assertTrue("clone.type == original.type",
+ clone.type == original.type);
+ assertTrue("clone.key == original.key",
+ clone.key == original.key);
+ assertTrue("clone.file == original.file",
+ clone.file == original.file);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.