AI 143779: am: CL 143727 Make the test runner and results assets of DumpRendertree. This is done so that we could have
1) Lab machines can run layout tests without having build environment setup
2) We could have different set of pass/fail results per branch
Also added a simple python script which runs run_layout_tests.py
Original author: sridharg
Merged from: //branches/cupcake/...
Automated import of CL 143779
diff --git a/tests/DumpRenderTree/results/layout_tests_crashed.txt b/tests/DumpRenderTree/assets/results/layout_tests_crashed.txt
similarity index 100%
rename from tests/DumpRenderTree/results/layout_tests_crashed.txt
rename to tests/DumpRenderTree/assets/results/layout_tests_crashed.txt
diff --git a/tests/DumpRenderTree/results/layout_tests_failed.txt b/tests/DumpRenderTree/assets/results/layout_tests_failed.txt
similarity index 100%
rename from tests/DumpRenderTree/results/layout_tests_failed.txt
rename to tests/DumpRenderTree/assets/results/layout_tests_failed.txt
diff --git a/tests/DumpRenderTree/results/layout_tests_nontext.txt b/tests/DumpRenderTree/assets/results/layout_tests_nontext.txt
similarity index 100%
rename from tests/DumpRenderTree/results/layout_tests_nontext.txt
rename to tests/DumpRenderTree/assets/results/layout_tests_nontext.txt
diff --git a/tests/DumpRenderTree/results/layout_tests_passed.txt b/tests/DumpRenderTree/assets/results/layout_tests_passed.txt
similarity index 100%
rename from tests/DumpRenderTree/results/layout_tests_passed.txt
rename to tests/DumpRenderTree/assets/results/layout_tests_passed.txt
diff --git a/tests/DumpRenderTree/run_layout_tests.py b/tests/DumpRenderTree/assets/run_layout_tests.py
similarity index 100%
rename from tests/DumpRenderTree/run_layout_tests.py
rename to tests/DumpRenderTree/assets/run_layout_tests.py
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
index a857e68..39eae02 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
@@ -42,6 +42,8 @@
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Vector;
//TestRecorder creates two files, one for passing tests
@@ -122,6 +124,18 @@
static final String ANDROID_EXPECTED_RESULT_DIR = "/sdcard/android/expected_results/";
static final String LAYOUT_TESTS_LIST_FILE = "/sdcard/android/layout_tests_list.txt";
static final String TEST_STATUS_FILE = "/sdcard/android/running_test.txt";
+ static final String LAYOUT_TESTS_RESULTS_REFERENCE_FILES[] = {
+ "results/layout_tests_passed.txt",
+ "results/layout_tests_failed.txt",
+ "results/layout_tests_nontext.txt",
+ "results/layout_tests_crashed.txt",
+ "run_layout_tests.py"
+ };
+
+ static final String LAYOUT_RESULTS_FAILED_RESULT_FILE = "results/layout_tests_failed.txt";
+ static final String LAYOUT_RESULTS_NONTEXT_RESULT_FILE = "results/layout_tests_nontext.txt";
+ static final String LAYOUT_RESULTS_CRASHED_RESULT_FILE = "results/layout_tests_crashed.txt";
+ static final String LAYOUT_TESTS_RUNNER = "run_layout_tests.py";
private MyTestRecorder mResultRecorder;
private Vector<String> mTestList;
@@ -452,4 +466,28 @@
public void resumeLayoutTests() {
executeLayoutTests(true);
}
+
+ public void copyResultsAndRunnerAssetsToCache() {
+ try {
+ String out_dir = getActivity().getApplicationContext().getCacheDir().getPath() + "/";
+
+ for( int i=0; i< LAYOUT_TESTS_RESULTS_REFERENCE_FILES.length; i++) {
+ InputStream in = getActivity().getAssets().open(LAYOUT_TESTS_RESULTS_REFERENCE_FILES[i]);
+ OutputStream out = new FileOutputStream(out_dir + LAYOUT_TESTS_RESULTS_REFERENCE_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();
+ }
+
+ }
+
}