summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2019-09-17 19:16:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-09-17 19:16:00 +0000
commita24ed7267c956a34f19e7a0828a8ac733647514c (patch)
tree705ffcc0fc4d7337a45fc50eb0cad20d9aaf8ec8
parentc1322b6ac8677582355e700180ab554225f63952 (diff)
parent8c2ae545cf13d6c0aff6ecef1d6b0a0e87f0f980 (diff)
downloadandroid_packages_apps_Trebuchet-a24ed7267c956a34f19e7a0828a8ac733647514c.tar.gz
android_packages_apps_Trebuchet-a24ed7267c956a34f19e7a0828a8ac733647514c.tar.bz2
android_packages_apps_Trebuchet-a24ed7267c956a34f19e7a0828a8ac733647514c.zip
Merge "Support for tests that a leak is detected" into ub-launcher3-qt-qpr1-dev
-rw-r--r--src/com/android/launcher3/testing/TestInformationHandler.java29
-rw-r--r--src/com/android/launcher3/testing/TestProtocol.java2
-rw-r--r--tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java8
3 files changed, 39 insertions, 0 deletions
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index 243ff6f96..790a2e844 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -15,7 +15,11 @@
*/
package com.android.launcher3.testing;
+import static android.graphics.Bitmap.Config.ARGB_8888;
+
import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Color;
import android.os.Bundle;
import android.os.Debug;
@@ -29,6 +33,7 @@ import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsStore;
import com.android.launcher3.util.ResourceBasedOverride;
+import java.util.LinkedList;
import java.util.concurrent.ExecutionException;
public class TestInformationHandler implements ResourceBasedOverride {
@@ -42,6 +47,7 @@ public class TestInformationHandler implements ResourceBasedOverride {
protected DeviceProfile mDeviceProfile;
protected LauncherAppState mLauncherAppState;
protected Launcher mLauncher;
+ private static LinkedList mLeaks;
public void init(Context context) {
mContext = context;
@@ -120,6 +126,29 @@ public class TestInformationHandler implements ResourceBasedOverride {
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, mem.getTotalPss());
break;
}
+
+ case TestProtocol.REQUEST_JAVA_LEAK: {
+ if (mLeaks == null) mLeaks = 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);
+ }
+ mLeaks.add(bytes);
+ break;
+ }
+
+ case TestProtocol.REQUEST_NATIVE_LEAK: {
+ if (mLeaks == null) mLeaks = new LinkedList();
+
+ // Allocate and dirty a bitmap.
+ final Bitmap bitmap = Bitmap.createBitmap(512, 512, ARGB_8888);
+ bitmap.eraseColor(Color.RED);
+ mLeaks.add(bitmap);
+ break;
+ }
}
return response;
}
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index 60a59ddfa..232a764e0 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -74,6 +74,8 @@ public final class TestProtocol {
public static final String REQUEST_OVERVIEW_LEFT_GESTURE_MARGIN = "overview-left-margin";
public static final String REQUEST_OVERVIEW_RIGHT_GESTURE_MARGIN = "overview-right-margin";
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 boolean sDebugTracing = false;
public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing";
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index c6e7daceb..15615fc6b 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -961,4 +961,12 @@ public final class LauncherInstrumentation {
return getTestInfo(TestProtocol.REQUEST_TOTAL_PSS_KB).
getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
+
+ public void produceJavaLeak() {
+ getTestInfo(TestProtocol.REQUEST_JAVA_LEAK);
+ }
+
+ public void produceNativeLeak() {
+ getTestInfo(TestProtocol.REQUEST_NATIVE_LEAK);
+ }
} \ No newline at end of file