Merge "Go to home screen after launching each app." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
04d5b9fbd1
@@ -72,6 +72,7 @@ public class MemoryUsageTest extends InstrumentationTestCase {
|
|||||||
try {
|
try {
|
||||||
processName = startApp(app);
|
processName = startApp(app);
|
||||||
measureMemory(app, processName, results);
|
measureMemory(app, processName, results);
|
||||||
|
closeApp();
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Log.i(TAG, "Application " + app + " not found");
|
Log.i(TAG, "Application " + app + " not found");
|
||||||
}
|
}
|
||||||
@@ -139,13 +140,22 @@ public class MemoryUsageTest extends InstrumentationTestCase {
|
|||||||
return process;
|
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,
|
private void measureMemory(String appName, String processName,
|
||||||
Bundle results) {
|
Bundle results) {
|
||||||
List<Integer> pssData = new ArrayList<Integer>();
|
List<Integer> pssData = new ArrayList<Integer>();
|
||||||
int pss = 0;
|
int pss = 0;
|
||||||
int iteration = 0;
|
int iteration = 0;
|
||||||
while (iteration < MAX_ITERATIONS) {
|
while (iteration < MAX_ITERATIONS) {
|
||||||
sleep();
|
sleep(SLEEP_TIME);
|
||||||
pss = getPss(processName);
|
pss = getPss(processName);
|
||||||
Log.i(TAG, appName + "=" + pss);
|
Log.i(TAG, appName + "=" + pss);
|
||||||
if (pss < 0) {
|
if (pss < 0) {
|
||||||
@@ -184,9 +194,9 @@ public class MemoryUsageTest extends InstrumentationTestCase {
|
|||||||
return (diff1 + diff2) < THRESHOLD;
|
return (diff1 + diff2) < THRESHOLD;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sleep() {
|
private void sleep(int time) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(SLEEP_TIME);
|
Thread.sleep(time);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user