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.qs; 16 17 import static org.mockito.ArgumentMatchers.any; 18 import static org.mockito.ArgumentMatchers.anyBoolean; 19 import static org.mockito.Mockito.never; 20 import static org.mockito.Mockito.verify; 21 import static org.mockito.Mockito.when; 22 23 import android.support.test.filters.SmallTest; 24 import android.testing.AndroidTestingRunner; 25 import android.testing.TestableLooper; 26 import android.testing.TestableLooper.RunWithLooper; 27 import android.view.LayoutInflater; 28 import android.view.View; 29 30 import com.android.systemui.R; 31 import com.android.systemui.R.id; 32 import com.android.systemui.plugins.ActivityStarter; 33 import com.android.systemui.statusbar.policy.DeviceProvisionedController; 34 import com.android.systemui.utils.leaks.LeakCheckedTest; 35 36 import org.junit.Before; 37 import org.junit.Ignore; 38 import org.junit.Test; 39 import org.junit.runner.RunWith; 40 41 @RunWith(AndroidTestingRunner.class) 42 @RunWithLooper 43 @SmallTest 44 @Ignore("failing") 45 public class QSFooterImplTest extends LeakCheckedTest { 46 47 private QSFooterImpl mFooter; 48 private ActivityStarter mActivityStarter; 49 private DeviceProvisionedController mDeviceProvisionedController; 50 51 @Before 52 public void setup() throws Exception { 53 injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES); 54 mActivityStarter = mDependency.injectMockDependency(ActivityStarter.class); 55 mDeviceProvisionedController = mDependency.injectMockDependency( 56 DeviceProvisionedController.class); 57 TestableLooper.get(this).runWithLooper( 58 () -> mFooter = (QSFooterImpl) LayoutInflater.from(mContext).inflate( 59 R.layout.qs_footer_impl, null)); 60 } 61 62 @Test 63 public void testSettings_UserNotSetup() { 64 View settingsButton = mFooter.findViewById(id.settings_button); 65 when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false); 66 67 mFooter.onClick(settingsButton); 68 // Verify Settings wasn't launched. 69 verify(mActivityStarter, never()).startActivity(any(), anyBoolean()); 70 } 71 } 72