Removing pss checks in memory tests

Test: presubmit
Bug: 185181057
Change-Id: I4f504f9540b80c62cd3f1024ff1d1b57102f2ed6
This commit is contained in:
vadimt
2021-05-12 18:29:23 -07:00
parent 91c27f28c6
commit e2801bcb77
4 changed files with 5 additions and 47 deletions

View File

@@ -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 @@ public class DebugTestInformationHandler extends TestInformationHandler {
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;
}

View File

@@ -87,9 +87,7 @@ public final class TestProtocol {
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";

View File

@@ -138,7 +138,7 @@ public abstract class AbstractLauncherUiTest {
// 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);

View File

@@ -1358,11 +1358,10 @@ public final class LauncherInstrumentation {
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 @@ public final class LauncherInstrumentation {
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);
}