diff options
author | Guang Zhu <guangzhu@google.com> | 2010-12-06 11:17:38 -0800 |
---|---|---|
committer | Guang Zhu <guangzhu@google.com> | 2010-12-06 11:24:01 -0800 |
commit | 0006952a8dc5a115cceb597ac53ec5bce703fd4f (patch) | |
tree | 50133d20f474789e3421867c590f730a605dc837 /tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java | |
parent | 02047f7e88f1d78b29d6d93dc521df279398505d (diff) |
change how assets are copied out of apk
Currently test code use getActivity to get DRT's assets. However
the side effect is that this will actually launch the activity.
This is not affecting any tests yet, however there are cleaner
ways to do this. The instrumentation framework provides a
getTargetContext call which will give access to app under test's
context, and therefore granting access to its assets.
Change-Id: I0560b0fa5681f80bcb9296beec3fd0549c40cc8e
Diffstat (limited to 'tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java')
-rw-r--r-- | tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java index 9352f3999915..4982c4611767 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java @@ -19,6 +19,7 @@ package com.android.dumprendertree; import dalvik.system.VMRuntime; import android.app.Instrumentation; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Debug; @@ -27,6 +28,7 @@ import android.os.Process; import android.test.ActivityInstrumentationTestCase2; import android.util.Log; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -202,14 +204,14 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel public void copyRunnerAssetsToCache() { try { - String out_dir = getActivity().getApplicationContext() - .getCacheDir().getPath() + "/"; + Context targetContext = getInstrumentation().getTargetContext(); + File cacheDir = targetContext.getCacheDir(); for( int i=0; i< LOAD_TEST_RUNNER_FILES.length; i++) { - InputStream in = getActivity().getAssets().open( + InputStream in = targetContext.getAssets().open( LOAD_TEST_RUNNER_FILES[i]); OutputStream out = new FileOutputStream( - out_dir + LOAD_TEST_RUNNER_FILES[i]); + new File(cacheDir, LOAD_TEST_RUNNER_FILES[i])); byte[] buf = new byte[2048]; int len; |