From c1a2764a6e488bfdc9952fa9270b6a78309741cd Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 8 Aug 2019 11:49:24 -0700 Subject: [PATCH] Support for memory tests Change-Id: I867a232a293f7bddbc630f563f18c0db94ac4b6e --- .../android/launcher3/testing/TestInformationHandler.java | 7 +++++++ src/com/android/launcher3/testing/TestProtocol.java | 1 + .../android/launcher3/tapl/LauncherInstrumentation.java | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index bab454f070..4fd0f884d6 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -112,6 +112,13 @@ public class TestInformationHandler implements ResourceBasedOverride { } break; } + + case TestProtocol.REQUEST_ALLOCATED_MEMORY: { + final Runtime runtime = Runtime.getRuntime(); + response.putLong(TestProtocol.TEST_INFO_RESPONSE_FIELD, + runtime.totalMemory() - runtime.freeMemory()); + break; + } } return response; } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index cb8f811cb2..f9f5dc42ab 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -73,6 +73,7 @@ public final class TestProtocol { public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags"; 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_ALLOCATED_MEMORY = "allocated-memory"; 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 6348c41af2..c012628c15 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -956,4 +956,9 @@ public final class LauncherInstrumentation { public void disableDebugTracing() { getTestInfo(TestProtocol.REQUEST_DISABLE_DEBUG_TRACING); } + + public long getAllocatedMemory() { + return getTestInfo(TestProtocol.REQUEST_ALLOCATED_MEMORY). + getLong(TestProtocol.TEST_INFO_RESPONSE_FIELD); + } } \ No newline at end of file