Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.statusbar; |
| 18 | |
| 19 | import static org.junit.Assert.assertFalse; |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 20 | |
| 21 | import android.os.Handler; |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 22 | import android.support.test.filters.SmallTest; |
| 23 | import android.testing.AndroidTestingRunner; |
| 24 | import android.testing.TestableLooper; |
| 25 | |
| 26 | import com.android.systemui.Dependency; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 27 | import com.android.systemui.InitController; |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 28 | import com.android.systemui.SysuiTestCase; |
Gus Prevas | 26bc59b | 2018-12-19 11:26:39 -0500 | [diff] [blame] | 29 | import com.android.systemui.statusbar.notification.NotificationEntryListener; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 30 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
| 31 | import com.android.systemui.statusbar.notification.logging.NotificationLogger; |
| 32 | import com.android.systemui.statusbar.notification.row.NotificationGutsManager; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 33 | import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener; |
| 34 | import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSaveListener; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 35 | import com.android.systemui.statusbar.notification.stack.NotificationListContainer; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 36 | import com.android.systemui.statusbar.phone.ShadeController; |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 37 | import com.android.systemui.statusbar.phone.StatusBarWindowController; |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 38 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
| 39 | |
| 40 | import org.junit.Before; |
Alison Cichowlas | 29c64fb | 2018-10-25 09:32:16 -0400 | [diff] [blame] | 41 | import org.junit.Ignore; |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 42 | import org.junit.Test; |
| 43 | import org.junit.runner.RunWith; |
| 44 | import org.mockito.Mock; |
| 45 | import 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 Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 54 | @TestableLooper.RunWithLooper |
Alison Cichowlas | 29c64fb | 2018-10-25 09:32:16 -0400 | [diff] [blame] | 55 | @Ignore("b/118400112") |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 56 | public class NonPhoneDependencyTest extends SysuiTestCase { |
| 57 | @Mock private NotificationPresenter mPresenter; |
| 58 | @Mock private NotificationListContainer mListContainer; |
Gus Prevas | 26bc59b | 2018-12-19 11:26:39 -0500 | [diff] [blame] | 59 | @Mock |
Gus Prevas | 8621bd2 | 2018-12-20 15:04:25 -0500 | [diff] [blame] | 60 | private NotificationEntryListener mEntryListener; |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 61 | @Mock private HeadsUpManager mHeadsUpManager; |
| 62 | @Mock private RemoteInputController.Delegate mDelegate; |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 63 | @Mock private NotificationRemoteInputManager.Callback mRemoteInputManagerCallback; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 64 | @Mock private CheckSaveListener mCheckSaveListener; |
| 65 | @Mock private OnSettingsClickListener mOnSettingsClickListener; |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 66 | |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 67 | @Before |
| 68 | public void setUp() { |
| 69 | MockitoAnnotations.initMocks(this); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 70 | mDependency.injectTestDependency(Dependency.MAIN_HANDLER, |
| 71 | new Handler(TestableLooper.get(this).getLooper())); |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | @Test |
Alison Cichowlas | 29c64fb | 2018-10-25 09:32:16 -0400 | [diff] [blame] | 75 | @Ignore("b/118400112") |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 76 | public void testNotificationManagementCodeHasNoDependencyOnStatusBarWindowManager() { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 77 | mDependency.injectMockDependency(ShadeController.class); |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 78 | 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 Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 89 | Dependency.get(InitController.class).executePostInitTasks(); |
Gus Prevas | 8621bd2 | 2018-12-20 15:04:25 -0500 | [diff] [blame] | 90 | entryManager.setUpWithPresenter(mPresenter, mListContainer, mHeadsUpManager); |
| 91 | entryManager.addNotificationEntryListener(mEntryListener); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 92 | gutsManager.setUpWithPresenter(mPresenter, mListContainer, |
| 93 | mCheckSaveListener, mOnSettingsClickListener); |
| 94 | notificationLogger.setUpWithContainer(mListContainer); |
| 95 | mediaManager.setUpWithPresenter(mPresenter); |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 96 | remoteInputManager.setUpWithCallback(mRemoteInputManagerCallback, |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 97 | mDelegate); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 98 | lockscreenUserManager.setUpWithPresenter(mPresenter); |
| 99 | viewHierarchyManager.setUpWithPresenter(mPresenter, mListContainer); |
| 100 | notificationListener.setUpWithPresenter(mPresenter); |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 101 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 102 | TestableLooper.get(this).processAllMessages(); |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 103 | assertFalse(mDependency.hasInstantiatedDependency(StatusBarWindowController.class)); |
Eliot Courtney | 012fae9 | 2018-01-10 18:22:55 +0900 | [diff] [blame] | 104 | } |
| 105 | } |