Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package com.android.server; |
| 17 | |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 18 | import static org.mockito.Mockito.when; |
| 19 | |
| 20 | import android.content.Context; |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 21 | import android.content.pm.PackageManager; |
| 22 | import android.content.pm.PackageManagerInternal; |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 23 | import android.os.storage.StorageManagerInternal; |
Brett Chabot | ec6bcbc | 2018-11-05 21:21:35 -0800 | [diff] [blame] | 24 | |
Sudheer Shanka | 3a0df3b | 2018-12-12 12:43:43 -0800 | [diff] [blame] | 25 | import androidx.test.filters.SmallTest; |
| 26 | import androidx.test.runner.AndroidJUnit4; |
| 27 | |
Sudheer Shanka | e73ae32 | 2019-04-29 10:46:26 -0700 | [diff] [blame] | 28 | import org.junit.Before; |
| 29 | import org.junit.runner.RunWith; |
| 30 | import org.mockito.Mock; |
| 31 | import org.mockito.MockitoAnnotations; |
| 32 | |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 33 | @SmallTest |
| 34 | @RunWith(AndroidJUnit4.class) |
| 35 | public class StorageManagerServiceTest { |
| 36 | |
| 37 | private StorageManagerService mService; |
| 38 | |
| 39 | @Mock private Context mContext; |
| 40 | @Mock private PackageManager mPm; |
| 41 | @Mock private PackageManagerInternal mPmi; |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 42 | |
| 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 Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 51 | |
| 52 | when(mContext.getPackageManager()).thenReturn(mPm); |
| 53 | |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 54 | mService = new StorageManagerService(mContext); |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 55 | } |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 56 | } |