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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.compositor.layouts;
6
7 import android.content.Context;
8 import android.content.pm.ApplicationInfo;
9 import android.content.pm.PackageManager;
10 import android.content.res.Resources;
11 import android.os.Looper;
12 import android.test.mock.MockContext;
13 import android.test.mock.MockResources;
14
15 /**
16 * This is the minimal {@link Context} needed by the {@link LayoutManager} to be working properly.
17 * It points to a {@link MockResources} for anything that is based on xml config urations. For
18 * everything else the standard provided Context should be sufficient.
19 */
20 public class MockContextForLayout extends MockContext {
21 private final Context mValidContext;
22 private final MockResourcesForLayout mResources;
23 private final Resources.Theme mTheme;
24
25 public MockContextForLayout(Context validContext) {
26 mValidContext = validContext;
27 mResources = new MockResourcesForLayout(validContext.getResources());
28 mTheme = mResources.newTheme();
29 }
30
31 @Override
32 public Resources getResources() {
33 return mResources;
34 }
35
36 @Override
37 public ApplicationInfo getApplicationInfo() {
38 return mValidContext.getApplicationInfo();
39 }
40
41 @Override
42 public Object getSystemService(String name) {
43 return mValidContext.getSystemService(name);
44 }
45
46 @Override
47 public PackageManager getPackageManager() {
48 return mValidContext.getPackageManager();
49 }
50
51 @Override
52 public Context getApplicationContext() {
53 return this;
54 }
55
56 @Override
57 public int checkCallingOrSelfPermission(String permission) {
58 return mValidContext.checkCallingOrSelfPermission(permission);
59 }
60
61 @Override
62 public Looper getMainLooper() {
63 return mValidContext.getMainLooper();
64 }
65
66 @Override
67 public Resources.Theme getTheme() {
68 return mTheme;
69 }
70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698