blob: 3d11c4c84ff169771970d8f72b1faec8832616fe [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;
21import android.support.test.InstrumentationRegistry;
22import android.support.test.annotation.UiThreadTest;
23import android.support.test.filters.SmallTest;
24import android.support.test.runner.AndroidJUnit4;
25
26import com.android.server.AppOpsService;
27
28import org.junit.Before;
29import org.junit.Test;
30import org.junit.runner.RunWith;
31
32import java.io.File;
33
34/**
Tadashi G. Takaoka18c909c2018-10-11 07:51:35 +000035 * runtest -c com.android.server.am.AppErrorDialogTest frameworks-services
Adrian Roos0da67d662017-04-17 14:50:22 -070036 */
37@RunWith(AndroidJUnit4.class)
38@SmallTest
39public 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 Hackborne9d9b4b2018-03-28 13:51:46 -070069 data.proc = new ProcessRecord(null, null, mContext.getApplicationInfo(), "name", 12345);
Adrian Roos0da67d662017-04-17 14:50:22 -070070 data.result = new AppErrorResult();
71
72 AppErrorDialog dialog = new AppErrorDialog(mContext, mService, data);
73
74 dialog.create();
75 }
76}