blob: d4688d77a840e2265e3f696a4b21515434b02c25 [file] [log] [blame]
Jason Monkcd74f692017-03-27 11:17:04 -04001/*
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.qs;
16
17import static org.mockito.ArgumentMatchers.any;
18import static org.mockito.ArgumentMatchers.anyBoolean;
19import static org.mockito.Mockito.never;
20import static org.mockito.Mockito.verify;
21import static org.mockito.Mockito.when;
22
23import android.testing.AndroidTestingRunner;
24import android.testing.TestableLooper;
25import android.testing.TestableLooper.RunWithLooper;
26import android.view.LayoutInflater;
27import android.view.View;
28
Brett Chabot84151d92019-02-27 15:37:59 -080029import androidx.test.filters.SmallTest;
30
Jason Monkcd74f692017-03-27 11:17:04 -040031import com.android.systemui.R;
32import com.android.systemui.R.id;
33import com.android.systemui.plugins.ActivityStarter;
34import com.android.systemui.statusbar.policy.DeviceProvisionedController;
35import com.android.systemui.utils.leaks.LeakCheckedTest;
36
37import org.junit.Before;
Geoffrey Pitsch351a3212017-05-22 15:20:20 -040038import org.junit.Ignore;
Jason Monkcd74f692017-03-27 11:17:04 -040039import org.junit.Test;
40import org.junit.runner.RunWith;
41
42@RunWith(AndroidTestingRunner.class)
43@RunWithLooper
Jason Monkfba8faf2017-05-23 10:42:59 -040044@SmallTest
Anthony Chen54daefe2017-04-07 17:19:54 -070045public class QSFooterImplTest extends LeakCheckedTest {
Jason Monkcd74f692017-03-27 11:17:04 -040046
Anthony Chen54daefe2017-04-07 17:19:54 -070047 private QSFooterImpl mFooter;
Jason Monkcd74f692017-03-27 11:17:04 -040048 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 Chen54daefe2017-04-07 17:19:54 -070057 TestableLooper.get(this).runWithLooper(
58 () -> mFooter = (QSFooterImpl) LayoutInflater.from(mContext).inflate(
59 R.layout.qs_footer_impl, null));
Jason Monkcd74f692017-03-27 11:17:04 -040060 }
61
62 @Test
Alison Cichowlas5d7d9592018-07-17 15:30:28 -040063 @Ignore("failing")
Jason Monkcd74f692017-03-27 11:17:04 -040064 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 Monkcd74f692017-03-27 11:17:04 -040072}