Skip to content

Commit

Permalink
Implemented clone method, and unit test for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikechambers committed Sep 21, 2009
1 parent c048bc7 commit 4278414
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
26 changes: 20 additions & 6 deletions src/com/adobe/air/net/events/ResourceCacheEvent.as
Expand Up @@ -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;
}

}
}
26 changes: 25 additions & 1 deletion tests/src/com/adobe/air/net/events/ResourceCacheEventTest.as
Expand Up @@ -32,6 +32,8 @@

package com.adobe.air.net.events
{
import flash.filesystem.File;

import flexunit.framework.TestCase;

public class ResourceCacheEventTest extends TestCase
Expand All @@ -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);
}
}
}

0 comments on commit 4278414

Please sign in to comment.