Files
frameworks_base/tests/DumpRenderTree2/src/com/android/dumprendertree2/LayoutTestsRunner.java
Maksymilian Osowski 3c8ccb3845 Added the LayoutTestsRunner class that is responsible for running the tests. Also, added some methods to FileFilter.
It preloads the tests from the given path, runs them and asks for dumps and diffs. It will also prepare summaries in the future. It delegates
most of the work of actually running the individual tests to LayoutTest class and AbstractResult (and its subclasses in the future).

Change-Id: I483bf26a380b539e4769e61b4a09fa270ab0e8e9
2010-07-16 14:32:12 +01:00

90 lines
3.0 KiB
Java

/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.dumprendertree2;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
/**
* An Activity that is responsible only for updating the UI features, like titles, progress bars,
* etc.
*
* <p>Also, the webview form the test must be running in this activity's thread if we want
* to be able to display it on the screen.
*/
public class LayoutTestsRunner extends Activity {
public static final int MSG_UPDATE_PROGRESS = 1;
public static final int MSG_SHOW_PROGRESS_DIALOG = 2;
public static final int MSG_DISMISS_PROGRESS_DIALOG = 3;
/** Constants for adding extras to an intent */
public static final String EXTRA_TEST_PATH = "TestPath";
private static ProgressDialog sProgressDialog;
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_UPDATE_PROGRESS:
int i = msg.arg1;
int size = msg.arg2;
getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
i * Window.PROGRESS_END / size);
setTitle(i * 100 / size + "% (" + i + "/" + size + ")");
break;
case MSG_SHOW_PROGRESS_DIALOG:
sProgressDialog.show();
break;
case MSG_DISMISS_PROGRESS_DIALOG:
sProgressDialog.dismiss();
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/** Prepare the progress dialog */
sProgressDialog = new ProgressDialog(LayoutTestsRunner.this);
sProgressDialog.setCancelable(false);
sProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
sProgressDialog.setTitle(R.string.dialog_progress_title);
sProgressDialog.setMessage(getText(R.string.dialog_progress_msg));
requestWindowFeature(Window.FEATURE_PROGRESS);
/** Execute the intent */
Intent intent = getIntent();
if (!intent.getAction().equals(Intent.ACTION_RUN)) {
return;
}
String path = intent.getStringExtra(EXTRA_TEST_PATH);
new LayoutTestsRunnerThread(path, mHandler).start();
}
}