diff options
author | Ben Murdoch <benm@google.com> | 2010-06-01 18:45:10 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-06-03 12:39:09 +0100 |
commit | 9b815d080145f0bc8effc9e011090010ad51f203 (patch) | |
tree | 8499934b8fd93502fae44ba5ef87b663fc6660b4 /tests/DumpRenderTree | |
parent | 22449c1d3b37471558a43a0425800971ea37e377 (diff) | |
download | frameworks_base-9b815d080145f0bc8effc9e011090010ad51f203.zip frameworks_base-9b815d080145f0bc8effc9e011090010ad51f203.tar.gz frameworks_base-9b815d080145f0bc8effc9e011090010ad51f203.tar.bz2 |
DumpRenderTree changes
- Make the layout test counter work when you run tests through the GUI
- Use the progress bar in the applications title bar to display test progress
Change-Id: I3d4b778470e812b80b7a64297b3a64ba6f9d083c
Diffstat (limited to 'tests/DumpRenderTree')
4 files changed, 43 insertions, 18 deletions
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java index 322b0d2..0883387 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java @@ -42,8 +42,13 @@ public class FsUtils { //no creation of instances } - public static void findLayoutTestsRecursively(BufferedOutputStream bos, + /** + * @return the number of tests in the list. + */ + public static int writeLayoutTestListRecursively(BufferedOutputStream bos, String dir, boolean ignoreResultsInDir) throws IOException { + + int testCount = 0; Log.v(LOGTAG, "Searching tests under " + dir); File d = new File(dir); @@ -61,7 +66,7 @@ public class FsUtils { // If this is not a test directory, we don't recurse into it. if (!FileFilter.isNonTestDir(s)) { Log.v(LOGTAG, "Recursing on " + s); - findLayoutTestsRecursively(bos, s, ignoreResultsInDir); + testCount += writeLayoutTestListRecursively(bos, s, ignoreResultsInDir); } continue; } @@ -81,8 +86,10 @@ public class FsUtils { bos.write((" IGNORE_RESULT").getBytes()); } bos.write('\n'); + testCount++; } } + return testCount; } public static void updateTestStatus(String statusFile, String s) { diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java index a2809c3..fabbf89 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java @@ -290,7 +290,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh } } - private void runTestAndWaitUntilDone(TestShellActivity activity, String test, int timeout, boolean ignoreResult, int testIndex) { + private void runTestAndWaitUntilDone(TestShellActivity activity, String test, int timeout, boolean ignoreResult, int testNumber) { activity.setCallback(new TestShellCallback() { public void finished() { synchronized (LayoutTestsAutoTest.this) { @@ -326,8 +326,8 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh intent.putExtra(TestShellActivity.TEST_URL, FsUtils.getTestUrl(test)); intent.putExtra(TestShellActivity.RESULT_FILE, resultFile); intent.putExtra(TestShellActivity.TIMEOUT_IN_MILLIS, timeout); - intent.putExtra(TestShellActivity.TEST_COUNT, mTestCount); - intent.putExtra(TestShellActivity.TEST_INDEX, testIndex); + intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, mTestCount); + intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, testNumber); activity.startActivity(intent); // Wait until done. @@ -402,7 +402,9 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh boolean ignoreResult = mTestListIgnoreResult.elementAt(i); FsUtils.updateTestStatus(TEST_STATUS_FILE, s); // Run tests - runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis, ignoreResult, i + mResumeIndex); + // i is 0 based, but test count is 1 based so add 1 to i here. + runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis, ignoreResult, + i + 1 + mResumeIndex); } FsUtils.updateTestStatus(TEST_STATUS_FILE, "#DONE"); @@ -427,7 +429,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh try { File tests_list = new File(LAYOUT_TESTS_LIST_FILE); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false)); - FsUtils.findLayoutTestsRecursively(bos, getTestPath(), false); // Don't ignore results + FsUtils.writeLayoutTestListRecursively(bos, getTestPath(), false); // Don't ignore results bos.flush(); bos.close(); } catch (Exception e) { diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java b/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java index 82671eb..5ffe6b0 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java @@ -51,29 +51,38 @@ public class Menu extends FileList { intent.setClass(this, TestShellActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(TestShellActivity.TEST_URL, "file://" + filename); + intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, 1); + intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, 1); startActivity(intent); } @Override void processDirectory(String path, boolean selection) { - generateTestList(path); + int testCount = generateTestList(path); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, TestShellActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(TestShellActivity.UI_AUTO_TEST, LAYOUT_TESTS_LIST_FILE); + intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, testCount); + // TestShellActivity will process this intent once and increment the test index + // before running the first test, so pass 0 here to allow for that. + intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, 0); startActivity(intent); } - private void generateTestList(String path) { + private int generateTestList(String path) { + int testCount = 0; try { File tests_list = new File(LAYOUT_TESTS_LIST_FILE); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false)); - FsUtils.findLayoutTestsRecursively(bos, path, false); // Don't ignore results + testCount = FsUtils.writeLayoutTestListRecursively( + bos, path, false); // Don't ignore results bos.flush(); bos.close(); } catch (Exception e) { Log.e(LOGTAG, "Error when creating test list: " + e.getMessage()); } + return testCount; } } diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java index 5b4cf22..31cbf03 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java @@ -34,6 +34,7 @@ import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.ViewGroup; +import android.view.Window; import android.webkit.ConsoleMessage; import android.webkit.GeolocationPermissions; import android.webkit.HttpAuthHandler; @@ -117,6 +118,7 @@ public class TestShellActivity extends Activity implements LayoutTestController @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); + requestWindowFeature(Window.FEATURE_PROGRESS); LinearLayout contentView = new LinearLayout(this); contentView.setOrientation(LinearLayout.VERTICAL); @@ -159,6 +161,9 @@ public class TestShellActivity extends Activity implements LayoutTestController return; } + mTotalTestCount = intent.getIntExtra(TOTAL_TEST_COUNT, mTotalTestCount); + mCurrentTestNumber = intent.getIntExtra(CURRENT_TEST_NUMBER, mCurrentTestNumber); + mTestUrl = intent.getStringExtra(TEST_URL); if (mTestUrl == null) { mUiAutoTestPath = intent.getStringExtra(UI_AUTO_TEST); @@ -172,9 +177,10 @@ public class TestShellActivity extends Activity implements LayoutTestController mTimeoutInMillis = intent.getIntExtra(TIMEOUT_IN_MILLIS, 0); mGetDrawtime = intent.getBooleanExtra(GET_DRAW_TIME, false); mSaveImagePath = intent.getStringExtra(SAVE_IMAGE); - mTestCount = intent.getIntExtra(TEST_COUNT, 0); - mTestIndex = intent.getIntExtra(TEST_INDEX, 0); - setTitle("Test " + (mTestIndex + 1) + " of " + mTestCount); + setTitle("Test " + mCurrentTestNumber + " of " + mTotalTestCount); + float ratio = (float)mCurrentTestNumber / mTotalTestCount; + int progress = (int)(ratio * Window.PROGRESS_END); + getWindow().setFeatureInt(Window.FEATURE_PROGRESS, progress); Log.v(LOGTAG, " Loading " + mTestUrl); mWebView.loadUrl(mTestUrl); @@ -240,6 +246,7 @@ public class TestShellActivity extends Activity implements LayoutTestController Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(TestShellActivity.TEST_URL, FsUtils.getTestUrl(url)); + intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, ++mCurrentTestNumber); intent.putExtra(TIMEOUT_IN_MILLIS, 10000); executeIntent(intent); } @@ -574,7 +581,7 @@ public class TestShellActivity extends Activity implements LayoutTestController @Override public void onReceivedTitle(WebView view, String title) { - setTitle("Test " + (mTestIndex + 1) + " of " + mTestCount + ": "+ title); + setTitle("Test " + mCurrentTestNumber + " of " + mTotalTestCount + ": "+ title); if (mDumpTitleChanges) { mTitleChanges.append("TITLE CHANGED: "); mTitleChanges.append(title); @@ -843,8 +850,8 @@ public class TestShellActivity extends Activity implements LayoutTestController private String mSaveImagePath; private BufferedReader mTestListReader; private boolean mGetDrawtime; - private int mTestCount; - private int mTestIndex; + private int mTotalTestCount; + private int mCurrentTestNumber; // States private boolean mTimedOut; @@ -882,8 +889,8 @@ public class TestShellActivity extends Activity implements LayoutTestController static final String UI_AUTO_TEST = "UiAutoTest"; static final String GET_DRAW_TIME = "GetDrawTime"; static final String SAVE_IMAGE = "SaveImage"; - static final String TEST_COUNT = "TestCount"; - static final String TEST_INDEX = "TestIndex"; + static final String TOTAL_TEST_COUNT = "TestCount"; + static final String CURRENT_TEST_NUMBER = "TestNumber"; static final int DRAW_RUNS = 5; static final String DRAW_TIME_LOG = "/sdcard/android/page_draw_time.txt"; |