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; 18 import static org.mockito.Matchers.any; 19 import static org.mockito.Mockito.spy; 20 import static org.mockito.Mockito.verify; 21 22 import android.content.Context; 23 import android.content.Intent; 24 import android.content.IntentFilter; 25 import android.support.test.filters.SmallTest; 26 import android.testing.AndroidTestingRunner; 27 import android.testing.TestableLooper.RunWithLooper; 28 29 import com.android.systemui.SysuiTestCase; 30 31 import org.junit.Before; 32 import org.junit.Test; 33 import org.junit.runner.RunWith; 34 import org.mockito.ArgumentCaptor; 35 36 37 @RunWith(AndroidTestingRunner.class) 38 @RunWithLooper(setAsMainLooper = true) 39 @SmallTest 40 public class SystemUIDialogTest extends SysuiTestCase { 41 42 private SystemUIDialog mDialog; 43 44 Context mContextSpy; 45 46 @Before 47 public void setup() { 48 mContextSpy = spy(mContext); 49 mDialog = new SystemUIDialog(mContextSpy); 50 } 51 52 @Test 53 public void testRegisterReceiver() { 54 final ArgumentCaptor<IntentFilter> intentFilterCaptor = 55 ArgumentCaptor.forClass(IntentFilter.class); 56 57 verify(mContextSpy).registerReceiverAsUser(any(), any(), 58 intentFilterCaptor.capture(), any(), any()); 59 60 assertTrue(intentFilterCaptor.getValue().hasAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); 61 } 62 63 } 64