Adrian Roos | 0da67d66 | 2017-04-17 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | |
| 17 | package com.android.server.am; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.os.Handler; |
| 21 | import android.support.test.InstrumentationRegistry; |
| 22 | import android.support.test.annotation.UiThreadTest; |
| 23 | import android.support.test.filters.SmallTest; |
| 24 | import android.support.test.runner.AndroidJUnit4; |
| 25 | |
| 26 | import com.android.server.AppOpsService; |
| 27 | |
| 28 | import org.junit.Before; |
| 29 | import org.junit.Test; |
| 30 | import org.junit.runner.RunWith; |
| 31 | |
| 32 | import java.io.File; |
| 33 | |
| 34 | /** |
Tadashi G. Takaoka | 18c909c | 2018-10-11 07:51:35 +0000 | [diff] [blame^] | 35 | * runtest -c com.android.server.am.AppErrorDialogTest frameworks-services |
Adrian Roos | 0da67d66 | 2017-04-17 14:50:22 -0700 | [diff] [blame] | 36 | */ |
| 37 | @RunWith(AndroidJUnit4.class) |
| 38 | @SmallTest |
| 39 | public class AppErrorDialogTest { |
| 40 | |
| 41 | private Context mContext; |
| 42 | private ActivityManagerService mService; |
| 43 | |
| 44 | @Before |
| 45 | public void setUp() throws Exception { |
| 46 | mContext = InstrumentationRegistry.getTargetContext(); |
| 47 | mService = new ActivityManagerService(new ActivityManagerService.Injector() { |
| 48 | @Override |
| 49 | public AppOpsService getAppOpsService(File file, Handler handler) { |
| 50 | return null; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public Handler getUiHandler(ActivityManagerService service) { |
| 55 | return null; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public boolean isNetworkRestrictedForUid(int uid) { |
| 60 | return false; |
| 61 | } |
| 62 | }); |
| 63 | } |
| 64 | |
| 65 | @Test |
| 66 | @UiThreadTest |
| 67 | public void testCreateWorks() throws Exception { |
| 68 | AppErrorDialog.Data data = new AppErrorDialog.Data(); |
Dianne Hackborn | e9d9b4b | 2018-03-28 13:51:46 -0700 | [diff] [blame] | 69 | data.proc = new ProcessRecord(null, null, mContext.getApplicationInfo(), "name", 12345); |
Adrian Roos | 0da67d66 | 2017-04-17 14:50:22 -0700 | [diff] [blame] | 70 | data.result = new AppErrorResult(); |
| 71 | |
| 72 | AppErrorDialog dialog = new AppErrorDialog(mContext, mService, data); |
| 73 | |
| 74 | dialog.create(); |
| 75 | } |
| 76 | } |