| 1 |
package com.android.frameworkperf; |
| 2 |
|
| 3 |
import android.app.Activity; |
| 4 |
import android.os.Bundle; |
| 5 |
import android.test.ActivityInstrumentationTestCase2; |
| 6 |
|
| 7 |
public class FrameworkPerfTest extends ActivityInstrumentationTestCase2<FrameworkPerfActivity> { |
| 8 |
|
| 9 |
private static final int TEST_TIMEOUT = 15 * 60 * 1000; |
| 10 |
|
| 11 |
public FrameworkPerfTest() { |
| 12 |
super("com.android.frameworkperf", FrameworkPerfActivity.class); |
| 13 |
} |
| 14 |
|
| 15 |
public void testFrameworkPerf() { |
| 16 |
final FrameworkPerfActivity activity = getActivity(); |
| 17 |
synchronized (activity.mResultNotifier) { |
| 18 |
getInstrumentation().runOnMainSync(new Runnable() { |
| 19 |
@Override |
| 20 |
public void run() { |
| 21 |
activity.startRunning(); |
| 22 |
} |
| 23 |
}); |
| 24 |
try { |
| 25 |
activity.mResultNotifier.wait(TEST_TIMEOUT); |
| 26 |
} catch (InterruptedException e) { |
| 27 |
fail("test interrupted."); |
| 28 |
} |
| 29 |
} |
| 30 |
Bundle testResult = new Bundle(); |
| 31 |
synchronized (activity.mResults) { |
| 32 |
assertTrue("test results were empty.", activity.mResults.size() > 0); |
| 33 |
for (RunResult result : activity.mResults) { |
| 34 |
testResult.putString(result.name, String.format("%f,%d,%d,%f,%d,%d", |
| 35 |
result.getFgMsPerOp(), result.fgOps, result.fgTime, |
| 36 |
result.getBgMsPerOp(), result.bgOps, result.bgTime)); |
| 37 |
} |
| 38 |
} |
| 39 |
getInstrumentation().sendStatus(Activity.RESULT_OK, testResult); |
| 40 |
} |
| 41 |
} |