modify wait mechanism so that it checks whether activity has already finished or not first

squashed commit of the following:

commit e2c2d1c09475ce2e319b935fb5627c82a7693a9b
Author: Guang Zhu <guangzhu@google.com>
Date:   Mon Apr 20 13:33:08 2009 -0700

    modify wait mechanism so that it checks whether activity has already finished or not first

    This reverts commit deb6e8792dd563916724bbc127a6fe16ffe81647.

commit deb6e8792dd563916724bbc127a6fe16ffe81647
Author: Guang Zhu <guangzhu@google.com>
Date:   Mon Apr 20 10:58:52 2009 -0700

    changed callback mechanism in TestShellActivity to use condition
This commit is contained in:
Guang Zhu
2009-04-20 13:57:46 -07:00
parent c421e9ad74
commit 20b4935f2a
2 changed files with 17 additions and 20 deletions

View File

@@ -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<TestSh
private Vector<String> 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<TestSh
activity.setCallback(new TestShellCallback() {
public void finished() {
synchronized (LayoutTestsAutoTest.this) {
mFinished = true;
LayoutTestsAutoTest.this.notifyAll();
}
}
@@ -306,6 +295,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
resultFile = getAndroidExpectedResultFile(expectedResultFile);
}
mFinished = false;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClass(activity, TestShellActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
@@ -316,9 +306,11 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
// Wait until done.
synchronized (this) {
try {
this.wait();
} catch (InterruptedException e) { }
while(!mFinished){
try {
this.wait();
} catch (InterruptedException e) { }
}
}
if (!mRebaselineResults) {

View File

@@ -37,6 +37,7 @@ 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;
public LoadTestsAutoTest() {
super("com.android.dumprendertree", TestShellActivity.class);
@@ -124,11 +125,13 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel
activity.setCallback(new TestShellCallback() {
public void finished() {
synchronized (LoadTestsAutoTest.this) {
mFinished = true;
LoadTestsAutoTest.this.notifyAll();
}
}
});
mFinished = false;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClass(activity, TestShellActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
@@ -139,9 +142,11 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel
// Wait until done.
synchronized (this) {
try {
this.wait();
} catch (InterruptedException e) { }
while(!mFinished) {
try {
this.wait();
} catch (InterruptedException e) { }
}
}
}
}