summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Gillin <peteg@google.com>2018-03-08 10:55:00 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-03-08 10:55:00 +0000
commit62ae4ff83460778ba80f07078a006820b7454966 (patch)
treef5d673e6d832bf4b6e8741cc80eaa4f8316ff348
parenta76903d096e8b7cff5f7c8f6c41ea614fc5339b9 (diff)
parent852092c6a85bdacb154f8b889db66dc5e45f31d2 (diff)
downloadcts-o-mr1-iot-preview-7.tar.gz
Merge "Test the new 'explicit GC' policy in StrictMode."android-o-mr1-iot-preview-7o-mr1-iot-preview-7
-rw-r--r--tests/tests/os/src/android/os/cts/StrictModeTest.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/tests/os/src/android/os/cts/StrictModeTest.java b/tests/tests/os/src/android/os/cts/StrictModeTest.java
index 21730c6bfd1..58c8fb1e17d 100644
--- a/tests/tests/os/src/android/os/cts/StrictModeTest.java
+++ b/tests/tests/os/src/android/os/cts/StrictModeTest.java
@@ -305,6 +305,17 @@ public class StrictModeTest extends InstrumentationTestCase {
});
}
+ public void testExplicitGc() throws Exception {
+ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
+ .detectExplicitGc()
+ .penaltyLog()
+ .build());
+
+ assertViolation("StrictModeExplicitGcViolation", () -> {
+ Runtime.getRuntime().gc();
+ });
+ }
+
private static void assertViolation(String expected, ThrowingRunnable r) throws Exception {
final LinkedBlockingQueue<String> violations = new LinkedBlockingQueue<>();
StrictMode.setViolationListener(new ViolationListener() {