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

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

Issue 1593313011: Adding unittests for media casting sink observation and route handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed avayvod@'s comments Created 4 years, 11 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/cast/TestUtils.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/media/router/cast/TestUtils.java b/chrome/android/junit/src/org/chromium/chrome/browser/media/router/cast/TestUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..2ced15f650ad86549b8e12d65c2d44d07c730e0d
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/media/router/cast/TestUtils.java
@@ -0,0 +1,33 @@
+// Copyright 2016 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.cast;
+
+import android.support.v7.media.MediaRouter;
+import android.support.v7.media.MediaRouter.RouteInfo;
+
+import org.robolectric.internal.ReflectionHelpers;
+
+/**
+ * Utility classes and methods for MediaRouterTests.
+ */
+public class TestUtils {
+ /**
+ * Creates a mock {@link RouteInfo} to supply where needed in the tests.
+ * @param id The id of the route
+ * @param name The user friendly name of the route
+ * @return The initialized mock RouteInfo instance
+ */
+ static RouteInfo createMockRouteInfo(String id, String name) {
+ Class<?>[] paramClasses = new Class[] {
+ MediaRouter.ProviderInfo.class, String.class, String.class};
+ Object[] paramValues = new Object[] {null, "", ""};
+ RouteInfo routeInfo = ReflectionHelpers.callConstructorReflectively(
+ RouteInfo.class,
+ ReflectionHelpers.ClassParameter.fromComponentLists(paramClasses, paramValues));
+ ReflectionHelpers.setFieldReflectively(routeInfo, "mUniqueId", id);
+ ReflectionHelpers.setFieldReflectively(routeInfo, "mName", name);
+ return routeInfo;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698