blob: 8e92684876f6607d7528bf0651fa6c68b55b2496 [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.support.test.filters.SmallTest;
23import android.testing.AndroidTestingRunner;
24import android.testing.TestableLooper;
25
26import com.android.systemui.Dependency;
Jason Monk297c04e2018-08-23 17:16:59 -040027import com.android.systemui.InitController;
Eliot Courtney012fae92018-01-10 18:22:55 +090028import com.android.systemui.SysuiTestCase;
Gus Prevas26bc59b2018-12-19 11:26:39 -050029import com.android.systemui.statusbar.notification.NotificationEntryListener;
Rohan Shah20790b82018-07-02 17:21:04 -070030import com.android.systemui.statusbar.notification.NotificationEntryManager;
31import com.android.systemui.statusbar.notification.logging.NotificationLogger;
32import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
Jason Monk297c04e2018-08-23 17:16:59 -040033import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener;
34import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSaveListener;
Rohan Shah20790b82018-07-02 17:21:04 -070035import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
Jason Monk297c04e2018-08-23 17:16:59 -040036import com.android.systemui.statusbar.phone.ShadeController;
Lucas Dupin1a8588d2018-08-21 12:18:47 -070037import com.android.systemui.statusbar.phone.StatusBarWindowController;
Eliot Courtney012fae92018-01-10 18:22:55 +090038import com.android.systemui.statusbar.policy.HeadsUpManager;
39
40import org.junit.Before;
Alison Cichowlas29c64fb2018-10-25 09:32:16 -040041import org.junit.Ignore;
Eliot Courtney012fae92018-01-10 18:22:55 +090042import org.junit.Test;
43import org.junit.runner.RunWith;
44import org.mockito.Mock;
45import org.mockito.MockitoAnnotations;
46
47/**
48 * Verifies that particular sets of dependencies don't have dependencies on others. For example,
49 * code managing notifications shouldn't directly depend on StatusBar, since there are platforms
50 * which want to manage notifications, but don't use StatusBar.
51 */
52@SmallTest
53@RunWith(AndroidTestingRunner.class)
Jason Monka716bac2018-12-05 15:48:21 -050054@TestableLooper.RunWithLooper
Julien Desprez7e8798c1b2019-02-08 20:12:28 +000055@Ignore("b/118400112")
Eliot Courtney012fae92018-01-10 18:22:55 +090056public class NonPhoneDependencyTest extends SysuiTestCase {
57 @Mock private NotificationPresenter mPresenter;
58 @Mock private NotificationListContainer mListContainer;
Gus Prevas26bc59b2018-12-19 11:26:39 -050059 @Mock
Gus Prevas8621bd22018-12-20 15:04:25 -050060 private NotificationEntryListener mEntryListener;
Eliot Courtney012fae92018-01-10 18:22:55 +090061 @Mock private HeadsUpManager mHeadsUpManager;
62 @Mock private RemoteInputController.Delegate mDelegate;
Eliot Courtney012fae92018-01-10 18:22:55 +090063 @Mock private NotificationRemoteInputManager.Callback mRemoteInputManagerCallback;
Jason Monk297c04e2018-08-23 17:16:59 -040064 @Mock private CheckSaveListener mCheckSaveListener;
65 @Mock private OnSettingsClickListener mOnSettingsClickListener;
Eliot Courtney012fae92018-01-10 18:22:55 +090066
Eliot Courtney012fae92018-01-10 18:22:55 +090067 @Before
68 public void setUp() {
69 MockitoAnnotations.initMocks(this);
Jason Monk297c04e2018-08-23 17:16:59 -040070 mDependency.injectTestDependency(Dependency.MAIN_HANDLER,
71 new Handler(TestableLooper.get(this).getLooper()));
Eliot Courtney012fae92018-01-10 18:22:55 +090072 }
73
74 @Test
Alison Cichowlas29c64fb2018-10-25 09:32:16 -040075 @Ignore("b/118400112")
Eliot Courtney012fae92018-01-10 18:22:55 +090076 public void testNotificationManagementCodeHasNoDependencyOnStatusBarWindowManager() {
Jason Monk297c04e2018-08-23 17:16:59 -040077 mDependency.injectMockDependency(ShadeController.class);
Eliot Courtney012fae92018-01-10 18:22:55 +090078 NotificationEntryManager entryManager = Dependency.get(NotificationEntryManager.class);
79 NotificationGutsManager gutsManager = Dependency.get(NotificationGutsManager.class);
80 NotificationListener notificationListener = Dependency.get(NotificationListener.class);
81 NotificationLogger notificationLogger = Dependency.get(NotificationLogger.class);
82 NotificationMediaManager mediaManager = Dependency.get(NotificationMediaManager.class);
83 NotificationRemoteInputManager remoteInputManager =
84 Dependency.get(NotificationRemoteInputManager.class);
85 NotificationLockscreenUserManager lockscreenUserManager =
86 Dependency.get(NotificationLockscreenUserManager.class);
87 NotificationViewHierarchyManager viewHierarchyManager =
88 Dependency.get(NotificationViewHierarchyManager.class);
Jason Monk297c04e2018-08-23 17:16:59 -040089 Dependency.get(InitController.class).executePostInitTasks();
Gus Prevas8621bd22018-12-20 15:04:25 -050090 entryManager.setUpWithPresenter(mPresenter, mListContainer, mHeadsUpManager);
91 entryManager.addNotificationEntryListener(mEntryListener);
Jason Monk297c04e2018-08-23 17:16:59 -040092 gutsManager.setUpWithPresenter(mPresenter, mListContainer,
93 mCheckSaveListener, mOnSettingsClickListener);
94 notificationLogger.setUpWithContainer(mListContainer);
95 mediaManager.setUpWithPresenter(mPresenter);
Gus Prevas21437b32018-12-05 10:36:13 -050096 remoteInputManager.setUpWithCallback(mRemoteInputManagerCallback,
Eliot Courtney012fae92018-01-10 18:22:55 +090097 mDelegate);
Jason Monk297c04e2018-08-23 17:16:59 -040098 lockscreenUserManager.setUpWithPresenter(mPresenter);
99 viewHierarchyManager.setUpWithPresenter(mPresenter, mListContainer);
Eliot Courtney012fae92018-01-10 18:22:55 +0900100
Jason Monk297c04e2018-08-23 17:16:59 -0400101 TestableLooper.get(this).processAllMessages();
Lucas Dupin1a8588d2018-08-21 12:18:47 -0700102 assertFalse(mDependency.hasInstantiatedDependency(StatusBarWindowController.class));
Eliot Courtney012fae92018-01-10 18:22:55 +0900103 }
104}