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.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.support.test.filters.SmallTest;
24import android.testing.AndroidTestingRunner;
25import android.testing.TestableLooper;
26import android.testing.TestableLooper.RunWithLooper;
27import android.view.LayoutInflater;
28import android.view.View;
29
30import com.android.systemui.R;
31import com.android.systemui.R.id;
32import com.android.systemui.plugins.ActivityStarter;
33import com.android.systemui.statusbar.policy.DeviceProvisionedController;
34import com.android.systemui.utils.leaks.LeakCheckedTest;
35
36import org.junit.Before;
37import org.junit.Ignore;
38import org.junit.Test;
39import org.junit.runner.RunWith;
40
41@RunWith(AndroidTestingRunner.class)
42@RunWithLooper
43@SmallTest
44@Ignore("failing")
45public 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