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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockContextForLayout.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockContextForLayout.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockContextForLayout.java b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockContextForLayout.java
new file mode 100644
index 0000000000000000000000000000000000000000..e2cfe5c4b5e52d3e4cc662f864e759f55bfb3984
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/MockContextForLayout.java
@@ -0,0 +1,70 @@
+// 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.compositor.layouts;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.os.Looper;
+import android.test.mock.MockContext;
+import android.test.mock.MockResources;
+
+/**
+ * This is the minimal {@link Context} needed by the {@link LayoutManager} to be working properly.
+ * It points to a {@link MockResources} for anything that is based on xml configurations. For
+ * everything else the standard provided Context should be sufficient.
+ */
+public class MockContextForLayout extends MockContext {
+ private final Context mValidContext;
+ private final MockResourcesForLayout mResources;
+ private final Resources.Theme mTheme;
+
+ public MockContextForLayout(Context validContext) {
+ mValidContext = validContext;
+ mResources = new MockResourcesForLayout(validContext.getResources());
+ mTheme = mResources.newTheme();
+ }
+
+ @Override
+ public Resources getResources() {
+ return mResources;
+ }
+
+ @Override
+ public ApplicationInfo getApplicationInfo() {
+ return mValidContext.getApplicationInfo();
+ }
+
+ @Override
+ public Object getSystemService(String name) {
+ return mValidContext.getSystemService(name);
+ }
+
+ @Override
+ public PackageManager getPackageManager() {
+ return mValidContext.getPackageManager();
+ }
+
+ @Override
+ public Context getApplicationContext() {
+ return this;
+ }
+
+ @Override
+ public int checkCallingOrSelfPermission(String permission) {
+ return mValidContext.checkCallingOrSelfPermission(permission);
+ }
+
+ @Override
+ public Looper getMainLooper() {
+ return mValidContext.getMainLooper();
+ }
+
+ @Override
+ public Resources.Theme getTheme() {
+ return mTheme;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698