blob: 19ad7ca645771a98e51ded5a6e788dabe8742c49 [file] [log] [blame]
Alison Cichowlas3e340502018-08-07 17:15:01 -04001/*
2 * Copyright (C) 2016 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.systemui.chooser;
18
19import static org.mockito.Mockito.any;
20import static org.mockito.Mockito.anyBoolean;
21import static org.mockito.Mockito.anyInt;
22import static org.mockito.Mockito.eq;
23import static org.mockito.Mockito.mock;
24import static org.mockito.Mockito.times;
25import static org.mockito.Mockito.verify;
26import static org.mockito.Mockito.when;
27
28import android.app.Activity;
29import android.app.ActivityTaskManager;
30import android.content.Intent;
31import android.os.Binder;
32import android.support.test.runner.AndroidJUnit4;
33import android.test.suitebuilder.annotation.SmallTest;
34
35import com.android.systemui.SysuiTestCase;
36
37import org.junit.Test;
38import org.junit.runner.RunWith;
39
40@SmallTest
41@RunWith(AndroidJUnit4.class)
42public class ChooserHelperTest extends SysuiTestCase {
43
44 @Test
45 public void testOnChoose_CallsStartActivityAsCallerWithToken() {
46 final Intent intent = new Intent();
47 final Binder token = new Binder();
48 intent.putExtra(ActivityTaskManager.EXTRA_PERMISSION_TOKEN, token);
49
50 final Activity mockActivity = mock(Activity.class);
51 when(mockActivity.getIntent()).thenReturn(intent);
52
53 ChooserHelper.onChoose(mockActivity);
54 verify(mockActivity, times(1)).startActivityAsCaller(
55 any(), any(), eq(token), anyBoolean(), anyInt());
56 }
57}