1cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk/* 2cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * Copyright (C) 2017 The Android Open Source Project 3cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * 4cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * except in compliance with the License. You may obtain a copy of the License at 6cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * 7cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * http://www.apache.org/licenses/LICENSE-2.0 8cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * 9cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * Unless required by applicable law or agreed to in writing, software distributed under the 10cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * KIND, either express or implied. See the License for the specific language governing 12cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk * permissions and limitations under the License. 13cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk */ 14cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 15cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkpackage com.android.systemui.qs; 16cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 17cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport static org.mockito.ArgumentMatchers.any; 18cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport static org.mockito.ArgumentMatchers.anyBoolean; 19cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport static org.mockito.Mockito.never; 20cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport static org.mockito.Mockito.verify; 21cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport static org.mockito.Mockito.when; 22cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 23fba8faf5c5f58f115fa3c099da9ef0953b484147Jason Monkimport android.support.test.filters.SmallTest; 24cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport android.testing.AndroidTestingRunner; 25cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport android.testing.TestableLooper; 26cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport android.testing.TestableLooper.RunWithLooper; 27cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport android.view.LayoutInflater; 28cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport android.view.View; 29cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 30cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport com.android.systemui.R; 31cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport com.android.systemui.R.id; 32cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport com.android.systemui.plugins.ActivityStarter; 33cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport com.android.systemui.statusbar.policy.DeviceProvisionedController; 34cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport com.android.systemui.utils.leaks.LeakCheckedTest; 35cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 36cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport org.junit.Before; 37351a321371c307e92ee73ea6d179de41518d1ef3Geoffrey Pitschimport org.junit.Ignore; 38cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport org.junit.Test; 39cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monkimport org.junit.runner.RunWith; 40cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 41cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk@RunWith(AndroidTestingRunner.class) 42cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk@RunWithLooper 43fba8faf5c5f58f115fa3c099da9ef0953b484147Jason Monk@SmallTest 44eefa3be55d941bc0193edae515b9e1b01b50e908Geoffrey Pitsch@Ignore("failing") 4554daefe3aa8dcdee149ce95fd4f8ecf60632c9f1Anthony Chenpublic class QSFooterImplTest extends LeakCheckedTest { 46cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 4754daefe3aa8dcdee149ce95fd4f8ecf60632c9f1Anthony Chen private QSFooterImpl mFooter; 48cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk private ActivityStarter mActivityStarter; 49cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk private DeviceProvisionedController mDeviceProvisionedController; 50cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 51cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk @Before 52cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk public void setup() throws Exception { 53cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES); 54cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk mActivityStarter = mDependency.injectMockDependency(ActivityStarter.class); 55cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk mDeviceProvisionedController = mDependency.injectMockDependency( 56cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk DeviceProvisionedController.class); 5754daefe3aa8dcdee149ce95fd4f8ecf60632c9f1Anthony Chen TestableLooper.get(this).runWithLooper( 5854daefe3aa8dcdee149ce95fd4f8ecf60632c9f1Anthony Chen () -> mFooter = (QSFooterImpl) LayoutInflater.from(mContext).inflate( 5954daefe3aa8dcdee149ce95fd4f8ecf60632c9f1Anthony Chen R.layout.qs_footer_impl, null)); 60cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk } 61cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 62cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk @Test 63cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk public void testSettings_UserNotSetup() { 64cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk View settingsButton = mFooter.findViewById(id.settings_button); 65cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false); 66cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk 67cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk mFooter.onClick(settingsButton); 68cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk // Verify Settings wasn't launched. 69cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk verify(mActivityStarter, never()).startActivity(any(), anyBoolean()); 70cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk } 71cd74f6971f3720dab682b6a1cfb952802cc3a080Jason Monk} 72