blob: 87d367fcb2b281519579fba43936e0fe09f71f44 [file] [log] [blame]
Adrian Roos0da67d662017-04-17 14:50:22 -07001/*
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
17package com.android.server.am;
18
19import android.content.Context;
20import android.os.Handler;
Brett Chabota26eda92018-07-23 13:08:30 -070021
22import androidx.test.InstrumentationRegistry;
23import androidx.test.annotation.UiThreadTest;
24import androidx.test.filters.SmallTest;
25import androidx.test.runner.AndroidJUnit4;
Adrian Roos0da67d662017-04-17 14:50:22 -070026
27import com.android.server.AppOpsService;
28
29import org.junit.Before;
30import org.junit.Test;
31import org.junit.runner.RunWith;
32
33import java.io.File;
34
35/**
36 * runtest -c com.android.server.am.AppErrorDialogTest frameworks-services
37 */
38@RunWith(AndroidJUnit4.class)
39@SmallTest
40public class AppErrorDialogTest {
41
42 private Context mContext;
43 private ActivityManagerService mService;
44
45 @Before
46 public void setUp() throws Exception {
47 mContext = InstrumentationRegistry.getTargetContext();
48 mService = new ActivityManagerService(new ActivityManagerService.Injector() {
49 @Override
50 public AppOpsService getAppOpsService(File file, Handler handler) {
51 return null;
52 }
53
54 @Override
55 public Handler getUiHandler(ActivityManagerService service) {
56 return null;
57 }
58
59 @Override
60 public boolean isNetworkRestrictedForUid(int uid) {
61 return false;
62 }
63 });
64 }
65
66 @Test
67 @UiThreadTest
68 public void testCreateWorks() throws Exception {
69 AppErrorDialog.Data data = new AppErrorDialog.Data();
Bookatz152623f2018-07-23 15:57:44 -070070 data.proc = new ProcessRecord(null, mContext.getApplicationInfo(), "name", 12345);
Adrian Roos0da67d662017-04-17 14:50:22 -070071 data.result = new AppErrorResult();
72
73 AppErrorDialog dialog = new AppErrorDialog(mContext, mService, data);
74
75 dialog.create();
76 }
77}