Jason Monk | cd74f69 | 2017-03-27 11:17:04 -0400 | [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.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.testing.AndroidTestingRunner; |
| 24 | import android.testing.TestableLooper; |
| 25 | import android.testing.TestableLooper.RunWithLooper; |
| 26 | import android.view.LayoutInflater; |
| 27 | import android.view.View; |
| 28 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 29 | import androidx.test.filters.SmallTest; |
| 30 | |
Jason Monk | cd74f69 | 2017-03-27 11:17:04 -0400 | [diff] [blame] | 31 | import com.android.systemui.R; |
| 32 | import com.android.systemui.R.id; |
| 33 | import com.android.systemui.plugins.ActivityStarter; |
| 34 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
| 35 | import com.android.systemui.utils.leaks.LeakCheckedTest; |
| 36 | |
| 37 | import org.junit.Before; |
Geoffrey Pitsch | 351a321 | 2017-05-22 15:20:20 -0400 | [diff] [blame] | 38 | import org.junit.Ignore; |
Jason Monk | cd74f69 | 2017-03-27 11:17:04 -0400 | [diff] [blame] | 39 | import org.junit.Test; |
| 40 | import org.junit.runner.RunWith; |
| 41 | |
| 42 | @RunWith(AndroidTestingRunner.class) |
| 43 | @RunWithLooper |
Jason Monk | fba8faf | 2017-05-23 10:42:59 -0400 | [diff] [blame] | 44 | @SmallTest |
Anthony Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 45 | public class QSFooterImplTest extends LeakCheckedTest { |
Jason Monk | cd74f69 | 2017-03-27 11:17:04 -0400 | [diff] [blame] | 46 | |
Anthony Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 47 | private QSFooterImpl mFooter; |
Jason Monk | cd74f69 | 2017-03-27 11:17:04 -0400 | [diff] [blame] | 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); |
Anthony Chen | 54daefe | 2017-04-07 17:19:54 -0700 | [diff] [blame] | 57 | TestableLooper.get(this).runWithLooper( |
| 58 | () -> mFooter = (QSFooterImpl) LayoutInflater.from(mContext).inflate( |
| 59 | R.layout.qs_footer_impl, null)); |
Jason Monk | cd74f69 | 2017-03-27 11:17:04 -0400 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | @Test |
Alison Cichowlas | 5d7d959 | 2018-07-17 15:30:28 -0400 | [diff] [blame] | 63 | @Ignore("failing") |
Jason Monk | cd74f69 | 2017-03-27 11:17:04 -0400 | [diff] [blame] | 64 | public void testSettings_UserNotSetup() { |
| 65 | View settingsButton = mFooter.findViewById(id.settings_button); |
| 66 | when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false); |
| 67 | |
| 68 | mFooter.onClick(settingsButton); |
| 69 | // Verify Settings wasn't launched. |
| 70 | verify(mActivityStarter, never()).startActivity(any(), anyBoolean()); |
| 71 | } |
Jason Monk | cd74f69 | 2017-03-27 11:17:04 -0400 | [diff] [blame] | 72 | } |