blob: d192748762fef4d3e9b9573873c340e678bfce24 [file] [log] [blame]
Jeff Sharkey5790af02018-08-13 17:42:54 -06001/*
2 * Copyright (C) 2018 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 */
16package com.android.server;
17
Jeff Sharkey5790af02018-08-13 17:42:54 -060018import static org.mockito.Mockito.when;
19
20import android.content.Context;
Jeff Sharkey5790af02018-08-13 17:42:54 -060021import android.content.pm.PackageManager;
22import android.content.pm.PackageManagerInternal;
Jeff Sharkey5790af02018-08-13 17:42:54 -060023import android.os.storage.StorageManagerInternal;
Brett Chabotec6bcbc2018-11-05 21:21:35 -080024
Sudheer Shanka3a0df3b2018-12-12 12:43:43 -080025import androidx.test.filters.SmallTest;
26import androidx.test.runner.AndroidJUnit4;
27
Sudheer Shankae73ae322019-04-29 10:46:26 -070028import org.junit.Before;
29import org.junit.runner.RunWith;
30import org.mockito.Mock;
31import org.mockito.MockitoAnnotations;
32
Jeff Sharkey5790af02018-08-13 17:42:54 -060033@SmallTest
34@RunWith(AndroidJUnit4.class)
35public class StorageManagerServiceTest {
36
37 private StorageManagerService mService;
38
39 @Mock private Context mContext;
40 @Mock private PackageManager mPm;
41 @Mock private PackageManagerInternal mPmi;
Jeff Sharkey5790af02018-08-13 17:42:54 -060042
43 @Before
44 public void setUp() throws Exception {
45 MockitoAnnotations.initMocks(this);
46
47 LocalServices.removeServiceForTest(StorageManagerInternal.class);
48
49 LocalServices.removeServiceForTest(PackageManagerInternal.class);
50 LocalServices.addService(PackageManagerInternal.class, mPmi);
Jeff Sharkey5790af02018-08-13 17:42:54 -060051
52 when(mContext.getPackageManager()).thenReturn(mPm);
53
Jeff Sharkey5790af02018-08-13 17:42:54 -060054 mService = new StorageManagerService(mContext);
Jeff Sharkey5790af02018-08-13 17:42:54 -060055 }
Jeff Sharkey5790af02018-08-13 17:42:54 -060056}