OSDN Git Service

package run_page_cycler.py into apk and add code for extraction
authorGuang Zhu <guangzhu@google.com>
Wed, 22 Apr 2009 16:58:25 +0000 (09:58 -0700)
committerGuang Zhu <guangzhu@google.com>
Wed, 22 Apr 2009 17:47:44 +0000 (10:47 -0700)
tests/DumpRenderTree/assets/run_page_cycler.py [moved from tests/DumpRenderTree/run_page_cycler.py with 95% similarity]
tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java

similarity index 95%
rename from tests/DumpRenderTree/run_page_cycler.py
rename to tests/DumpRenderTree/assets/run_page_cycler.py
index 7f728a3..2325047 100755 (executable)
@@ -56,7 +56,7 @@ def main(options, args):
   run_load_test_cmd_postfix = " -w com.android.dumprendertree/.LayoutTestsAutoRunner"
 
   # Call LoadTestsAutoTest::runTest.
-  run_load_test_cmd = run_load_test_cmd_prefix + " -e class com.android.dumprendertree.LoadTestsAutoTest#runTest -e path \"" + path + "\" -e timeout " + timeout_ms + run_load_test_cmd_postfix
+  run_load_test_cmd = run_load_test_cmd_prefix + " -e class com.android.dumprendertree.LoadTestsAutoTest#runPageCyclerTest -e path \"" + path + "\" -e timeout " + timeout_ms + run_load_test_cmd_postfix
 
   (adb_output, adb_error) = subprocess.Popen(run_load_test_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
   if adb_output.find('INSTRUMENTATION_FAILED') != -1 or \
index 910cb8d..562b1f3 100644 (file)
@@ -470,7 +470,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
                 byte[] buf = new byte[2048];
                 int len;
 
-                while ((len = in.read(buf)) > 0 ) {
+                while ((len = in.read(buf)) >= 0 ) {
                     out.write(buf, 0, len);
                 }
                 out.close();
index e793ed4..5cb5155 100644 (file)
@@ -31,6 +31,8 @@ import com.android.dumprendertree.TestShellCallback;
 
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.io.PrintStream;
 
 public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShellActivity> {
@@ -38,6 +40,9 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel
     private final static String LOGTAG = "LoadTest";
     private final static String LOAD_TEST_RESULT = "/sdcard/load_test_result.txt";
     private boolean mFinished;
+    static final String LOAD_TEST_RUNNER_FILES[] = {
+        "run_page_cycler.py"
+  };
 
     public LoadTestsAutoTest() {
         super("com.android.dumprendertree", TestShellActivity.class);
@@ -54,7 +59,7 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel
 
     // Invokes running of layout tests
     // and waits till it has finished running.
-    public void runTest() {
+    public void runPageCyclerTest() {
         LayoutTestsAutoRunner runner = (LayoutTestsAutoRunner) getInstrumentation();
 
         if (runner.mTestPath == null) {
@@ -149,4 +154,31 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel
             }
         }
     }
+
+    public void copyRunnerAssetsToCache() {
+        try {
+            String out_dir = getActivity().getApplicationContext()
+                .getCacheDir().getPath() + "/";
+
+            for( int i=0; i< LOAD_TEST_RUNNER_FILES.length; i++) {
+                InputStream in = getActivity().getAssets().open(
+                        LOAD_TEST_RUNNER_FILES[i]);
+                OutputStream out = new FileOutputStream(
+                        out_dir + LOAD_TEST_RUNNER_FILES[i]);
+
+                byte[] buf = new byte[2048];
+                int len;
+
+                while ((len = in.read(buf)) >= 0 ) {
+                    out.write(buf, 0, len);
+                }
+                out.close();
+                in.close();
+            }
+        }catch (IOException e) {
+          e.printStackTrace();
+        }
+
+    }
+
 }