blob: 42f476bdc8edc8d62db99365fb350e5adb299ce5 [file] [log] [blame]
Eliot Courtney012fae92018-01-10 18:22:55 +09001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.systemui.statusbar;
18
19import static org.junit.Assert.assertFalse;
Eliot Courtney012fae92018-01-10 18:22:55 +090020
21import android.os.Handler;
Eliot Courtney012fae92018-01-10 18:22:55 +090022import android.testing.AndroidTestingRunner;
23import android.testing.TestableLooper;
24
Brett Chabot84151d92019-02-27 15:37:59 -080025import androidx.test.filters.SmallTest;
26
Eliot Courtney012fae92018-01-10 18:22:55 +090027import com.android.systemui.Dependency;
Jason Monk297c04e2018-08-23 17:16:59 -040028import com.android.systemui.InitController;
Eliot Courtney012fae92018-01-10 18:22:55 +090029import com.android.systemui.SysuiTestCase;
Gus Prevas26bc59b2018-12-19 11:26:39 -050030import com.android.systemui.statusbar.notification.NotificationEntryListener;
Rohan Shah20790b82018-07-02 17:21:04 -070031import com.android.systemui.statusbar.notification.NotificationEntryManager;
32import com.android.systemui.statusbar.notification.logging.NotificationLogger;
33import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
Jason Monk297c04e2018-08-23 17:16:59 -040034import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener;
35import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSaveListener;
Rohan Shah20790b82018-07-02 17:21:04 -070036import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
Jason Monk297c04e2018-08-23 17:16:59 -040037import com.android.systemui.statusbar.phone.ShadeController;
Lucas Dupin1a8588d2018-08-21 12:18:47 -070038import com.android.systemui.statusbar.phone.StatusBarWindowController;
Eliot Courtney012fae92018-01-10 18:22:55 +090039import com.android.systemui.statusbar.policy.HeadsUpManager;
40
41import org.junit.Before;
Alison Cichowlas29c64fb2018-10-25 09:32:16 -040042import org.junit.Ignore;
Eliot Courtney012fae92018-01-10 18:22:55 +090043import org.junit.Test;
44import org.junit.runner.RunWith;
45import org.mockito.Mock;
46import org.mockito.MockitoAnnotations;
47
48/**
49 * Verifies that particular sets of dependencies don't have dependencies on others. For example,
50 * code managing notifications shouldn't directly depend on StatusBar, since there are platforms
51 * which want to manage notifications, but don't use StatusBar.
52 */
53@SmallTest
54@RunWith(AndroidTestingRunner.class)
Jason Monka716bac2018-12-05 15:48:21 -050055@TestableLooper.RunWithLooper
Julien Desprez7e8798c1b2019-02-08 20:12:28 +000056@Ignore("b/118400112")
Eliot Courtney012fae92018-01-10 18:22:55 +090057public class NonPhoneDependencyTest extends SysuiTestCase {
58 @Mock private NotificationPresenter mPresenter;
59 @Mock private NotificationListContainer mListContainer;
Gus Prevas26bc59b2018-12-19 11:26:39 -050060 @Mock
Gus Prevas8621bd22018-12-20 15:04:25 -050061 private NotificationEntryListener mEntryListener;
Eliot Courtney012fae92018-01-10 18:22:55 +090062 @Mock private HeadsUpManager mHeadsUpManager;
63 @Mock private RemoteInputController.Delegate mDelegate;
Eliot Courtney012fae92018-01-10 18:22:55 +090064 @Mock private NotificationRemoteInputManager.Callback mRemoteInputManagerCallback;
Jason Monk297c04e2018-08-23 17:16:59 -040065 @Mock private CheckSaveListener mCheckSaveListener;
66 @Mock private OnSettingsClickListener mOnSettingsClickListener;
Eliot Courtney012fae92018-01-10 18:22:55 +090067
Eliot Courtney012fae92018-01-10 18:22:55 +090068 @Before
69 public void setUp() {
70 MockitoAnnotations.initMocks(this);
Jason Monk297c04e2018-08-23 17:16:59 -040071 mDependency.injectTestDependency(Dependency.MAIN_HANDLER,
72 new Handler(TestableLooper.get(this).getLooper()));
Eliot Courtney012fae92018-01-10 18:22:55 +090073 }
74
75 @Test
Alison Cichowlas29c64fb2018-10-25 09:32:16 -040076 @Ignore("b/118400112")
Eliot Courtney012fae92018-01-10 18:22:55 +090077 public void testNotificationManagementCodeHasNoDependencyOnStatusBarWindowManager() {
Jason Monk297c04e2018-08-23 17:16:59 -040078 mDependency.injectMockDependency(ShadeController.class);
Eliot Courtney012fae92018-01-10 18:22:55 +090079 NotificationEntryManager entryManager = Dependency.get(NotificationEntryManager.class);
80 NotificationGutsManager gutsManager = Dependency.get(NotificationGutsManager.class);
81 NotificationListener notificationListener = Dependency.get(NotificationListener.class);
82 NotificationLogger notificationLogger = Dependency.get(NotificationLogger.class);
83 NotificationMediaManager mediaManager = Dependency.get(NotificationMediaManager.class);
84 NotificationRemoteInputManager remoteInputManager =
85 Dependency.get(NotificationRemoteInputManager.class);
86 NotificationLockscreenUserManager lockscreenUserManager =
87 Dependency.get(NotificationLockscreenUserManager.class);
88 NotificationViewHierarchyManager viewHierarchyManager =
89 Dependency.get(NotificationViewHierarchyManager.class);
Jason Monk297c04e2018-08-23 17:16:59 -040090 Dependency.get(InitController.class).executePostInitTasks();
Gus Prevas8621bd22018-12-20 15:04:25 -050091 entryManager.setUpWithPresenter(mPresenter, mListContainer, mHeadsUpManager);
92 entryManager.addNotificationEntryListener(mEntryListener);
Jason Monk297c04e2018-08-23 17:16:59 -040093 gutsManager.setUpWithPresenter(mPresenter, mListContainer,
94 mCheckSaveListener, mOnSettingsClickListener);
95 notificationLogger.setUpWithContainer(mListContainer);
96 mediaManager.setUpWithPresenter(mPresenter);
Gus Prevas21437b32018-12-05 10:36:13 -050097 remoteInputManager.setUpWithCallback(mRemoteInputManagerCallback,
Eliot Courtney012fae92018-01-10 18:22:55 +090098 mDelegate);
Jason Monk297c04e2018-08-23 17:16:59 -040099 lockscreenUserManager.setUpWithPresenter(mPresenter);
100 viewHierarchyManager.setUpWithPresenter(mPresenter, mListContainer);
Eliot Courtney012fae92018-01-10 18:22:55 +0900101
Jason Monk297c04e2018-08-23 17:16:59 -0400102 TestableLooper.get(this).processAllMessages();
Lucas Dupin1a8588d2018-08-21 12:18:47 -0700103 assertFalse(mDependency.hasInstantiatedDependency(StatusBarWindowController.class));
Eliot Courtney012fae92018-01-10 18:22:55 +0900104 }
105}