phweiss | 679dc24 | 2017-07-05 18:54:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
| 5 | * except in compliance with the License. You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under the |
| 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 11 | * KIND, either express or implied. See the License for the specific language governing |
| 12 | * permissions and limitations under the License. |
| 13 | */ |
| 14 | |
| 15 | package com.android.systemui.statusbar.phone; |
| 16 | |
| 17 | import static junit.framework.Assert.assertTrue; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 18 | |
phweiss | 679dc24 | 2017-07-05 18:54:54 +0200 | [diff] [blame] | 19 | import static org.mockito.Matchers.any; |
| 20 | import static org.mockito.Mockito.spy; |
| 21 | import static org.mockito.Mockito.verify; |
| 22 | |
| 23 | import android.content.Context; |
| 24 | import android.content.Intent; |
| 25 | import android.content.IntentFilter; |
| 26 | import android.support.test.filters.SmallTest; |
| 27 | import android.testing.AndroidTestingRunner; |
| 28 | import android.testing.TestableLooper.RunWithLooper; |
| 29 | |
| 30 | import com.android.systemui.SysuiTestCase; |
| 31 | |
| 32 | import org.junit.Before; |
| 33 | import org.junit.Test; |
| 34 | import org.junit.runner.RunWith; |
| 35 | import org.mockito.ArgumentCaptor; |
| 36 | |
| 37 | |
| 38 | @RunWith(AndroidTestingRunner.class) |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 39 | @RunWithLooper |
phweiss | 679dc24 | 2017-07-05 18:54:54 +0200 | [diff] [blame] | 40 | @SmallTest |
| 41 | public class SystemUIDialogTest extends SysuiTestCase { |
| 42 | |
| 43 | private SystemUIDialog mDialog; |
| 44 | |
| 45 | Context mContextSpy; |
| 46 | |
| 47 | @Before |
| 48 | public void setup() { |
| 49 | mContextSpy = spy(mContext); |
| 50 | mDialog = new SystemUIDialog(mContextSpy); |
| 51 | } |
| 52 | |
| 53 | @Test |
| 54 | public void testRegisterReceiver() { |
| 55 | final ArgumentCaptor<IntentFilter> intentFilterCaptor = |
| 56 | ArgumentCaptor.forClass(IntentFilter.class); |
| 57 | |
| 58 | verify(mContextSpy).registerReceiverAsUser(any(), any(), |
| 59 | intentFilterCaptor.capture(), any(), any()); |
| 60 | |
| 61 | assertTrue(intentFilterCaptor.getValue().hasAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); |
| 62 | } |
| 63 | |
| 64 | } |