From b933f669e26afad8a2466edcae8c1ffda6c15721 Mon Sep 17 00:00:00 2001 From: Guang Zhu Date: Tue, 5 May 2009 01:02:14 -0700 Subject: [PATCH] Back-merge all changes done in master to DumpRenderTree to donut. --- .../{ => assets}/run_page_cycler.py | 5 +- .../dumprendertree/LayoutTestsAutoTest.java | 28 ++-- .../dumprendertree/LoadTestsAutoTest.java | 154 +++++++++++------- .../dumprendertree/TestShellActivity.java | 3 +- 4 files changed, 108 insertions(+), 82 deletions(-) rename tests/DumpRenderTree/{ => assets}/run_page_cycler.py (92%) diff --git a/tests/DumpRenderTree/run_page_cycler.py b/tests/DumpRenderTree/assets/run_page_cycler.py similarity index 92% rename from tests/DumpRenderTree/run_page_cycler.py rename to tests/DumpRenderTree/assets/run_page_cycler.py index 9a099b52694b4..2325047a1840e 100755 --- a/tests/DumpRenderTree/run_page_cycler.py +++ b/tests/DumpRenderTree/assets/run_page_cycler.py @@ -56,10 +56,11 @@ 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: + if adb_output.find('INSTRUMENTATION_FAILED') != -1 or \ + adb_output.find('Process crashed.') != -1: logging.error("Error happened : " + adb_output) sys.exit(1) diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java index 39eae02940d21..562b1f32aacac 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java @@ -16,24 +16,11 @@ package com.android.dumprendertree; -import android.app.Activity; import android.app.Instrumentation; -import android.app.Instrumentation.ActivityMonitor; -import android.content.ContentResolver; -import android.content.ContentValues; import android.content.Intent; - -import android.util.Log; -import android.view.KeyEvent; -import android.webkit.WebSettings; - import android.os.Bundle; -import android.os.Message; import android.test.ActivityInstrumentationTestCase2; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.LargeTest; - -import com.android.dumprendertree.TestShellActivity; +import android.util.Log; import java.io.BufferedOutputStream; import java.io.BufferedReader; @@ -141,6 +128,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2 mTestList; private boolean mRebaselineResults; private String mTestPathPrefix; + private boolean mFinished; public LayoutTestsAutoTest() { super("com.android.dumprendertree", TestShellActivity.class); @@ -290,6 +278,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2 0 ) { + while ((len = in.read(buf)) >= 0 ) { out.write(buf, 0, len); } out.close(); diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java index b064dbb404290..5cb51554abfc4 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java @@ -16,52 +16,34 @@ package com.android.dumprendertree; -import android.app.Activity; import android.app.Instrumentation; -import android.app.Instrumentation.ActivityMonitor; import android.content.Intent; import android.util.Log; import android.os.Bundle; +import android.os.Debug; +import android.os.Debug.MemoryInfo; import android.test.ActivityInstrumentationTestCase2; import com.android.dumprendertree.TestShellActivity; import com.android.dumprendertree.TestShellCallback; -import java.io.InputStream; -import java.io.OutputStream; import java.io.FileOutputStream; import java.io.IOException; - -class StreamPipe extends Thread { - InputStream in; - OutputStream out; - - StreamPipe(InputStream in, OutputStream out) { - this.in = in; - this.out = out; - } - - public void run() { - try { - byte[] buf = new byte[1024]; - int nofb = this.in.read(buf); - while (nofb != -1) { - this.out.write(buf, 0, nofb); - nofb = this.in.read(buf); - } - } catch (IOException e) { - e.printStackTrace(); - } - } -} +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2 { 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); } @@ -74,17 +56,17 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2= 0 ) { + out.write(buf, 0, len); + } + out.close(); + in.close(); + } + }catch (IOException e) { + e.printStackTrace(); + } + + } + } diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java index bf8a3b35a443f..404d1012c7dd7 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java @@ -165,7 +165,8 @@ public class TestShellActivity extends Activity implements LayoutTestController if (mDialogStrings != null) os.write(mDialogStrings.toString().getBytes()); mDialogStrings = null; - os.write(webkitData.getBytes()); + if (webkitData != null) + os.write(webkitData.getBytes()); os.flush(); os.close(); } catch (IOException ex) {