1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.providers.tv;
18
19import android.content.ComponentName;
20import android.content.ContentResolver;
21import android.content.Context;
22import android.content.pm.ApplicationInfo;
23import android.content.pm.PackageManager;
24import android.content.pm.ServiceInfo;
25import android.content.res.Resources;
26import android.test.IsolatedContext;
27import android.test.RenamingDelegatingContext;
28import android.test.mock.MockContext;
29import android.test.mock.MockPackageManager;
30
31class MockTvProviderContext extends IsolatedContext {
32    private final Context mBase;
33    private final MockPackageManager mMockPackageManager = new MockPackageManager() {
34        @Override
35        public ServiceInfo getServiceInfo(ComponentName className, int flags) {
36            return null;
37        }
38    };
39
40    MockTvProviderContext(ContentResolver resolver, Context base) {
41        super(resolver, new RenamingDelegatingContext(new MockContext(), base, "test."));
42        mBase = base;
43    }
44
45    @Override
46    public Resources getResources() {
47        return mBase.getResources();
48    }
49
50    @Override
51    public PackageManager getPackageManager() {
52        return mMockPackageManager;
53    }
54
55    @Override
56    public String getPackageName() {
57        return mBase.getPackageName();
58    }
59
60    @Override
61    public ApplicationInfo getApplicationInfo() {
62        return mBase.getApplicationInfo();
63    }
64
65    @Override
66    public int checkCallingOrSelfPermission(String permission) {
67        return PackageManager.PERMISSION_GRANTED;
68    }
69}
70