Removing pss checks in memory tests
Test: presubmit
Bug: 185181057
Change-Id: I4f504f9540b80c62cd3f1024ff1d1b57102f2ed6
diff --git a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
index aa3710b..c6ae6be 100644
--- a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
+++ b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
@@ -16,16 +16,11 @@
package com.android.launcher3.testing;
-import static android.graphics.Bitmap.Config.ARGB_8888;
-
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Color;
import android.os.Binder;
import android.os.Bundle;
-import android.os.Debug;
import android.system.Os;
import android.view.View;
@@ -106,34 +101,8 @@
return response;
}
- case TestProtocol.REQUEST_TOTAL_PSS_KB: {
+ case TestProtocol.REQUEST_FORCE_GC: {
runGcAndFinalizersSync();
- Debug.MemoryInfo mem = new Debug.MemoryInfo();
- Debug.getMemoryInfo(mem);
- response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, mem.getTotalPss());
- return response;
- }
-
- case TestProtocol.REQUEST_JAVA_LEAK: {
- if (sLeaks == null) sLeaks = new LinkedList();
-
- // Allocate and dirty the memory.
- final int leakSize = 1024 * 1024;
- final byte[] bytes = new byte[leakSize];
- for (int i = 0; i < leakSize; i += 239) {
- bytes[i] = (byte) (i % 256);
- }
- sLeaks.add(bytes);
- return response;
- }
-
- case TestProtocol.REQUEST_NATIVE_LEAK: {
- if (sLeaks == null) sLeaks = new LinkedList();
-
- // Allocate and dirty a bitmap.
- final Bitmap bitmap = Bitmap.createBitmap(512, 512, ARGB_8888);
- bitmap.eraseColor(Color.RED);
- sLeaks.add(bitmap);
return response;
}
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index 4012e89..b6da7fc 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -87,9 +87,7 @@
public static final String REQUEST_WIDGETS_SCROLL_Y = "widgets-scroll-y";
public static final String REQUEST_WINDOW_INSETS = "window-insets";
public static final String REQUEST_PID = "pid";
- public static final String REQUEST_TOTAL_PSS_KB = "total_pss";
- public static final String REQUEST_JAVA_LEAK = "java-leak";
- public static final String REQUEST_NATIVE_LEAK = "native-leak";
+ public static final String REQUEST_FORCE_GC = "gc";
public static final String REQUEST_VIEW_LEAK = "view-leak";
public static final String REQUEST_RECENT_TASKS_LIST = "recent-tasks-list";
public static final String REQUEST_START_EVENT_LOGGING = "start-event-logging";
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 8936f39..ca463e6 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -138,7 +138,7 @@
// Check whether activity leak detector has found leaked activities.
Wait.atMost(AbstractLauncherUiTest::getActivityLeakErrorMessage,
() -> {
- launcher.getTotalPssKb(); // Triggers GC
+ launcher.forceGc();
return MAIN_EXECUTOR.submit(
() -> ACTIVITY_LEAK_TRACKER.noLeakedActivities()).get();
}, DEFAULT_UI_TIMEOUT, launcher);
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index f993bcf..57f40db 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -1358,11 +1358,10 @@
getTestInfo(TestProtocol.REQUEST_DISABLE_DEBUG_TRACING);
}
- public int getTotalPssKb() {
+ public void forceGc() {
// GC the system & sysui first before gc'ing launcher
logShellCommand("cmd statusbar run-gc");
- return getTestInfo(TestProtocol.REQUEST_TOTAL_PSS_KB).
- getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ getTestInfo(TestProtocol.REQUEST_FORCE_GC);
}
public Integer getPid() {
@@ -1370,14 +1369,6 @@
return testInfo != null ? testInfo.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD) : null;
}
- public void produceJavaLeak() {
- getTestInfo(TestProtocol.REQUEST_JAVA_LEAK);
- }
-
- public void produceNativeLeak() {
- getTestInfo(TestProtocol.REQUEST_NATIVE_LEAK);
- }
-
public void produceViewLeak() {
getTestInfo(TestProtocol.REQUEST_VIEW_LEAK);
}