Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/media/router/ChromeMediaRouterTest.java

Issue 1376703002: Presentation API: reject screen availability observing on Android low ram devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/junit/src/org/chromium/chrome/browser/media/router/ChromeMediaRouterTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/media/router/ChromeMediaRouterTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/media/router/ChromeMediaRouterTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..5f623e8663d8d7da685a77d58fa5724060c02a1b
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/media/router/ChromeMediaRouterTest.java
@@ -0,0 +1,67 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.media.router;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import android.app.ActivityManager;
+import android.os.Build;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.shadows.ShadowActivityManager;
+
+/**
+ * Robolectric tests for ChromeMediaRouter.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE,
+ shadows = { ChromeMediaRouterTest.FakeActivityManager.class })
+public class ChromeMediaRouterTest {
+
+ private static boolean sIsLowRamDevice;
+ private ChromeMediaRouter mChromeMediaRouter;
+
+ /**
+ * Robolectric's ShadowActivityManager implementation in order to extend
+ * isLowRamDevice and be able to instrument the tests.
+ */
+ @Implements(ActivityManager.class)
+ public static class FakeActivityManager extends ShadowActivityManager {
+ @Implementation
+ public boolean isLowRamDevice() {
+ return sIsLowRamDevice;
+ }
+ }
+
+ @Before
+ public void setUp() {
+ sIsLowRamDevice = false;
+ mChromeMediaRouter = new ChromeMediaRouter(0, Robolectric.application);
+ }
+
+ @Test
+ @Feature({"MediaRouter"})
+ public void testNotLowRamDevice() {
+ sIsLowRamDevice = false;
+ assertTrue(mChromeMediaRouter.startObservingMediaSinks(""));
+ }
+
+ @Test
+ @Feature({"MediaRouter"})
+ public void testIsLowRamDevice() {
+ sIsLowRamDevice = true;
+ assertEquals(Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2,
+ mChromeMediaRouter.startObservingMediaSinks(""));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698