summaryrefslogtreecommitdiffstats
path: root/tests/MemoryUsage
diff options
context:
space:
mode:
authorMaxim Siniavine <siniavine@google.com>2012-09-14 17:53:18 -0700
committerMaxim Siniavine <siniavine@google.com>2012-09-17 14:21:20 -0700
commita9d9decf87a040087a9bda4340d53c21cd3e672a (patch)
treea5c16b82a676684f7a25713e1c84b18e6b0960ca /tests/MemoryUsage
parente2f0ec8923d42b47225225345a960e41dfbb5bd1 (diff)
downloadframeworks_base-a9d9decf87a040087a9bda4340d53c21cd3e672a.zip
frameworks_base-a9d9decf87a040087a9bda4340d53c21cd3e672a.tar.gz
frameworks_base-a9d9decf87a040087a9bda4340d53c21cd3e672a.tar.bz2
Go to home screen after launching each app.
Instead of starting one app after another the MemoryUsage instrumentation goes to the home screen between launching apps. Change-Id: Ia0acf9f6f65a23f537b96c98743b59d746681447
Diffstat (limited to 'tests/MemoryUsage')
-rw-r--r--tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
index e39d53c..5e27ba7 100644
--- a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
+++ b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
@@ -72,6 +72,7 @@ public class MemoryUsageTest extends InstrumentationTestCase {
try {
processName = startApp(app);
measureMemory(app, processName, results);
+ closeApp();
} catch (NameNotFoundException e) {
Log.i(TAG, "Application " + app + " not found");
}
@@ -139,13 +140,22 @@ public class MemoryUsageTest extends InstrumentationTestCase {
return process;
}
+ private void closeApp() {
+ Intent homeIntent = new Intent(Intent.ACTION_MAIN);
+ homeIntent.addCategory(Intent.CATEGORY_HOME);
+ homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ getInstrumentation().getContext().startActivity(homeIntent);
+ sleep(3000);
+ }
+
private void measureMemory(String appName, String processName,
Bundle results) {
List<Integer> pssData = new ArrayList<Integer>();
int pss = 0;
int iteration = 0;
while (iteration < MAX_ITERATIONS) {
- sleep();
+ sleep(SLEEP_TIME);
pss = getPss(processName);
Log.i(TAG, appName + "=" + pss);
if (pss < 0) {
@@ -184,9 +194,9 @@ public class MemoryUsageTest extends InstrumentationTestCase {
return (diff1 + diff2) < THRESHOLD;
}
- private void sleep() {
+ private void sleep(int time) {
try {
- Thread.sleep(SLEEP_TIME);
+ Thread.sleep(time);
} catch (InterruptedException e) {
// ignore
}