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; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 21 | |
| 22 | import androidx.test.InstrumentationRegistry; |
| 23 | import androidx.test.annotation.UiThreadTest; |
Dan Shi | ebfde33 | 2018-10-19 14:25:36 -0700 | [diff] [blame^] | 24 | import androidx.test.filters.FlakyTest; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 25 | import androidx.test.filters.SmallTest; |
| 26 | import androidx.test.runner.AndroidJUnit4; |
Adrian Roos | 0da67d66 | 2017-04-17 14:50:22 -0700 | [diff] [blame] | 27 | |
| 28 | import com.android.server.AppOpsService; |
| 29 | |
| 30 | import org.junit.Before; |
| 31 | import org.junit.Test; |
| 32 | import org.junit.runner.RunWith; |
| 33 | |
| 34 | import java.io.File; |
| 35 | |
| 36 | /** |
John Reck | 3d294e7 | 2018-09-21 20:26:48 +0000 | [diff] [blame] | 37 | * runtest -c com.android.server.am.AppErrorDialogTest frameworks-services |
Adrian Roos | 0da67d66 | 2017-04-17 14:50:22 -0700 | [diff] [blame] | 38 | */ |
| 39 | @RunWith(AndroidJUnit4.class) |
| 40 | @SmallTest |
Dan Shi | ebfde33 | 2018-10-19 14:25:36 -0700 | [diff] [blame^] | 41 | @FlakyTest(bugId = 113616538) |
Adrian Roos | 0da67d66 | 2017-04-17 14:50:22 -0700 | [diff] [blame] | 42 | public class AppErrorDialogTest { |
| 43 | |
| 44 | private Context mContext; |
| 45 | private ActivityManagerService mService; |
| 46 | |
| 47 | @Before |
| 48 | public void setUp() throws Exception { |
| 49 | mContext = InstrumentationRegistry.getTargetContext(); |
| 50 | mService = new ActivityManagerService(new ActivityManagerService.Injector() { |
| 51 | @Override |
| 52 | public AppOpsService getAppOpsService(File file, Handler handler) { |
| 53 | return null; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public Handler getUiHandler(ActivityManagerService service) { |
| 58 | return null; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public boolean isNetworkRestrictedForUid(int uid) { |
| 63 | return false; |
| 64 | } |
| 65 | }); |
| 66 | } |
| 67 | |
| 68 | @Test |
| 69 | @UiThreadTest |
| 70 | public void testCreateWorks() throws Exception { |
| 71 | AppErrorDialog.Data data = new AppErrorDialog.Data(); |
Yunfan Chen | 75157d7 | 2018-07-27 14:47:21 +0900 | [diff] [blame] | 72 | data.proc = new ProcessRecord(null, mContext.getApplicationInfo(), "name", 12345, null); |
Adrian Roos | 0da67d66 | 2017-04-17 14:50:22 -0700 | [diff] [blame] | 73 | data.result = new AppErrorResult(); |
| 74 | |
| 75 | AppErrorDialog dialog = new AppErrorDialog(mContext, mService, data); |
| 76 | |
| 77 | dialog.create(); |
| 78 | } |
| 79 | } |