Changed some parts of the code to prepare it for script support that will come in later commit.

Bug: 2903591

Change-Id: If8fcfad1557c8140c476212d8be9f99987cdaa18
This commit is contained in:
Maksymilian Osowski
2010-08-10 11:33:10 +01:00
parent 8aff3c0571
commit c8fb818b94
3 changed files with 29 additions and 8 deletions

View File

@@ -25,8 +25,15 @@ limitations under the License.
</intent-filter>
</activity>
<!-- android:launchMode="singleTask" is there so we only have a one instance
of this activity. However, it doesn't seem to work exactly like described in the
documentation, because the behaviour of the application suggest
there is only a single task for all 3 activities. We don't understand
how exactly it all works, but at the moment it works just fine.
It can lead to some weird behaviour in the future. -->
<activity android:name=".TestsListActivity"
android:label="Tests' list activity">
android:label="Tests' list activity"
android:launchMode="singleTask">
</activity>
<activity android:name=".LayoutTestsExecutor"

View File

@@ -93,6 +93,11 @@ public class ManagerService extends Service {
case MSG_ALL_TESTS_FINISHED:
mSummarizer.summarize();
Intent intent = new Intent(ManagerService.this, TestsListActivity.class);
intent.setAction(Intent.ACTION_SHUTDOWN);
/** This flag is needed because we send the intent from the service */
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
break;
}
}
@@ -166,7 +171,8 @@ public class ManagerService extends Service {
Intent intent = new Intent(this, TestsListActivity.class);
intent.setAction(Intent.ACTION_REBOOT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
/** This flag is needed because we send the intent from the service */
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("crashedTestIndex", mCurrentlyRunningTestIndex);
startActivity(intent);
}

View File

@@ -85,6 +85,15 @@ public class TestsListActivity extends Activity {
new TestsListPreloaderThread(path, doneMsg).start();
}
@Override
protected void onNewIntent(Intent intent) {
if (intent.getAction().equals(Intent.ACTION_REBOOT)) {
onCrashIntent(intent);
} else if (intent.getAction().equals(Intent.ACTION_SHUTDOWN)) {
onEverythingFinishedIntent(intent);
}
}
/**
* This method handles an intent that comes from ManageService when crash is detected.
* The intent contains an index in mTestsList of the test that crashed. TestsListActivity
@@ -94,18 +103,17 @@ public class TestsListActivity extends Activity {
* LayoutTestExecutor runs then as usual, sending reports to ManagerService. If it
* detects the crash it sends a new intent and the flow repeats.
*/
@Override
protected void onNewIntent(Intent intent) {
if (!intent.getAction().equals(Intent.ACTION_REBOOT)) {
return;
}
private void onCrashIntent(Intent intent) {
int nextTestToRun = intent.getIntExtra("crashedTestIndex", -1) + 1;
if (nextTestToRun > 0 && nextTestToRun <= mTotalTestCount) {
restartExecutor(nextTestToRun);
}
}
private void onEverythingFinishedIntent(Intent intent) {
/** TODO: Show some kind of summary to the user */
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putStringArrayList("testsList", mTestsList);