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 15package com.android.systemui.statusbar.phone; 16 17import static junit.framework.Assert.assertTrue; 18import static org.mockito.Matchers.any; 19import static org.mockito.Mockito.spy; 20import static org.mockito.Mockito.verify; 21 22import android.content.Context; 23import android.content.Intent; 24import android.content.IntentFilter; 25import android.support.test.filters.SmallTest; 26import android.testing.AndroidTestingRunner; 27import android.testing.TestableLooper.RunWithLooper; 28 29import com.android.systemui.SysuiTestCase; 30 31import org.junit.Before; 32import org.junit.Test; 33import org.junit.runner.RunWith; 34import org.mockito.ArgumentCaptor; 35 36 37@RunWith(AndroidTestingRunner.class) 38@RunWithLooper(setAsMainLooper = true) 39@SmallTest 40public 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