@Mock private NotificationPresenter mPresenter;
@Mock private ExpandableNotificationRow mRow;
+ @Mock private NotificationListContainer mListContainer;
+ @Mock private NotificationEntryManager.Callback mCallback;
+ @Mock private HeadsUpManager mHeadsUpManager;
+ @Mock private NotificationListenerService.RankingMap mRankingMap;
+ @Mock private RemoteInputController mRemoteInputController;
+ @Mock private IStatusBarService mBarService;
+
+ // Dependency mocks:
+ @Mock private ForegroundServiceController mForegroundServiceController;
@Mock private NotificationLockscreenUserManager mLockscreenUserManager;
@Mock private NotificationGroupManager mGroupManager;
@Mock private NotificationGutsManager mGutsManager;
@Mock private NotificationRemoteInputManager mRemoteInputManager;
@Mock private NotificationMediaManager mMediaManager;
- @Mock private ForegroundServiceController mForegroundServiceController;
@Mock private NotificationListener mNotificationListener;
- @Mock private MetricsLogger mMetricsLogger;
@Mock private DeviceProvisionedController mDeviceProvisionedController;
@Mock private VisualStabilityManager mVisualStabilityManager;
- @Mock private NotificationListContainer mListContainer;
- @Mock private NotificationEntryManager.Callback mCallback;
- @Mock private HeadsUpManager mHeadsUpManager;
- @Mock private NotificationListenerService.RankingMap mRankingMap;
- @Mock private RemoteInputController mRemoteInputController;
- @Mock private IStatusBarService mBarService;
+ @Mock private MetricsLogger mMetricsLogger;
private NotificationData.Entry mEntry;
private StatusBarNotification mSbn;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mDependency.injectTestDependency(ForegroundServiceController.class,
+ mForegroundServiceController);
+ mDependency.injectTestDependency(NotificationLockscreenUserManager.class,
+ mLockscreenUserManager);
+ mDependency.injectTestDependency(NotificationGroupManager.class, mGroupManager);
+ mDependency.injectTestDependency(NotificationGutsManager.class, mGutsManager);
+ mDependency.injectTestDependency(NotificationRemoteInputManager.class, mRemoteInputManager);
+ mDependency.injectTestDependency(NotificationMediaManager.class, mMediaManager);
+ mDependency.injectTestDependency(NotificationListener.class, mNotificationListener);
+ mDependency.injectTestDependency(DeviceProvisionedController.class,
+ mDeviceProvisionedController);
+ mDependency.injectTestDependency(VisualStabilityManager.class, mVisualStabilityManager);
+ mDependency.injectTestDependency(MetricsLogger.class, mMetricsLogger);
+
mHandler = new Handler(Looper.getMainLooper());
mCountDownLatch = new CountDownLatch(1);
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import java.util.HashSet;
import java.util.Set;
private static final String TEST_PACKAGE_NAME = "test";
private static final int TEST_UID = 0;
- private NotificationPresenter mPresenter;
- private Handler mHandler;
+ @Mock private NotificationPresenter mPresenter;
+ @Mock private NotificationListenerService.RankingMap mRanking;
+ @Mock private NotificationData mNotificationData;
+
+ // Dependency mocks:
+ @Mock private NotificationEntryManager mEntryManager;
+ @Mock private NotificationRemoteInputManager mRemoteInputManager;
+
private NotificationListener mListener;
+ private Handler mHandler;
private StatusBarNotification mSbn;
- private NotificationListenerService.RankingMap mRanking;
private Set<String> mKeysKeptForRemoteInput;
- private NotificationData mNotificationData;
- private NotificationRemoteInputManager mRemoteInputManager;
- private NotificationEntryManager mEntryManager;
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
+ mDependency.injectTestDependency(NotificationRemoteInputManager.class,
+ mRemoteInputManager);
+
mHandler = new Handler(Looper.getMainLooper());
- mPresenter = mock(NotificationPresenter.class);
- mNotificationData = mock(NotificationData.class);
- mRanking = mock(NotificationListenerService.RankingMap.class);
- mRemoteInputManager = mock(NotificationRemoteInputManager.class);
- mEntryManager = mock(NotificationEntryManager.class);
mKeysKeptForRemoteInput = new HashSet<>();
when(mPresenter.getHandler()).thenReturn(mHandler);
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
- private NotificationPresenter mPresenter;
- private NotificationEntryManager mEntryManager;
- private TestNotificationLockscreenUserManager mLockscreenUserManager;
- private DeviceProvisionedController mDeviceProvisionedController;
+ @Mock private NotificationPresenter mPresenter;
+ @Mock private UserManager mUserManager;
+
+ // Dependency mocks:
+ @Mock private NotificationEntryManager mEntryManager;
+ @Mock private DeviceProvisionedController mDeviceProvisionedController;
+
private int mCurrentUserId;
private Handler mHandler;
- private UserManager mUserManager;
+ private TestNotificationLockscreenUserManager mLockscreenUserManager;
@Before
public void setUp() {
- mUserManager = mock(UserManager.class);
- mPresenter = mock(NotificationPresenter.class);
- mEntryManager = mock(NotificationEntryManager.class);
- mDependency.injectMockDependency(DeviceProvisionedController.class);
- mDeviceProvisionedController = mDependency.get(DeviceProvisionedController.class);
+ MockitoAnnotations.initMocks(this);
+ mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
+ mDependency.injectTestDependency(DeviceProvisionedController.class,
+ mDeviceProvisionedController);
mHandler = new Handler(Looper.getMainLooper());
mContext.addMockSystemService(UserManager.class, mUserManager);
when(mPresenter.getEntryManager()).thenReturn(mEntryManager);
mLockscreenUserManager = new TestNotificationLockscreenUserManager(mContext);
- mDependency.injectTestDependency(NotificationLockscreenUserManager.class,
- mLockscreenUserManager);
mLockscreenUserManager.setUpWithPresenter(mPresenter);
}
private static final int TEST_UID = 0;
@Mock private NotificationPresenter mPresenter;
- @Mock private NotificationEntryManager mEntryManager;
- @Mock private NotificationListener mListener;
@Mock private NotificationListContainer mListContainer;
@Mock private IStatusBarService mBarService;
@Mock private NotificationData mNotificationData;
@Mock private ExpandableNotificationRow mRow;
+ // Dependency mocks:
+ @Mock private NotificationEntryManager mEntryManager;
+ @Mock private NotificationListener mListener;
+
private NotificationData.Entry mEntry;
private StatusBarNotification mSbn;
private TestableNotificationLogger mLogger;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
+ mDependency.injectTestDependency(NotificationListener.class, mListener);
when(mPresenter.getEntryManager()).thenReturn(mEntryManager);
when(mEntryManager.getNotificationData()).thenReturn(mNotificationData);
private static final String TEST_PACKAGE_NAME = "test";
private static final int TEST_UID = 0;
- private Handler mHandler;
- private TestableNotificationRemoteInputManager mRemoteInputManager;
- private StatusBarNotification mSbn;
- private NotificationData.Entry mEntry;
-
@Mock private NotificationPresenter mPresenter;
- @Mock private NotificationEntryManager mEntryManager;
@Mock private RemoteInputController.Delegate mDelegate;
- @Mock private NotificationLockscreenUserManager mLockscreenUserManager;
@Mock private NotificationRemoteInputManager.Callback mCallback;
@Mock private RemoteInputController mController;
@Mock private NotificationListenerService.RankingMap mRanking;
@Mock private ExpandableNotificationRow mRow;
+ // Dependency mocks:
+ @Mock private NotificationEntryManager mEntryManager;
+ @Mock private NotificationLockscreenUserManager mLockscreenUserManager;
+
+ private Handler mHandler;
+ private TestableNotificationRemoteInputManager mRemoteInputManager;
+ private StatusBarNotification mSbn;
+ private NotificationData.Entry mEntry;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
+ mDependency.injectTestDependency(NotificationLockscreenUserManager.class,
+ mLockscreenUserManager);
mHandler = new Handler(Looper.getMainLooper());
when(mPresenter.getHandler()).thenReturn(mHandler);
@TestableLooper.RunWithLooper
public class NotificationViewHierarchyManagerTest extends SysuiTestCase {
@Mock private NotificationPresenter mPresenter;
+ @Mock private NotificationData mNotificationData;
+ @Spy private FakeListContainer mListContainer = new FakeListContainer();
+
+ // Dependency mocks:
@Mock private NotificationEntryManager mEntryManager;
@Mock private NotificationLockscreenUserManager mLockscreenUserManager;
@Mock private NotificationGroupManager mGroupManager;
@Mock private VisualStabilityManager mVisualStabilityManager;
- @Mock private NotificationData mNotificationData;
- @Spy private FakeListContainer mListContainer = new FakeListContainer();
private NotificationViewHierarchyManager mViewHierarchyManager;
- private NotificationTestHelper mHelper;
+ private NotificationTestHelper mHelper = new NotificationTestHelper(mContext);;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mHelper = new NotificationTestHelper(mContext);
+ mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
+ mDependency.injectTestDependency(NotificationLockscreenUserManager.class,
+ mLockscreenUserManager);
+ mDependency.injectTestDependency(NotificationGroupManager.class, mGroupManager);
+ mDependency.injectTestDependency(VisualStabilityManager.class, mVisualStabilityManager);
when(mPresenter.getEntryManager()).thenReturn(mEntryManager);
when(mEntryManager.getNotificationData()).thenReturn(mNotificationData);
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
@RunWith(AndroidTestingRunner.class)
@RunWithLooper
public class StatusBarTest extends SysuiTestCase {
+ @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
+ @Mock private UnlockMethodCache mUnlockMethodCache;
+ @Mock private KeyguardIndicationController mKeyguardIndicationController;
+ @Mock private NotificationStackScrollLayout mStackScroller;
+ @Mock private HeadsUpManager mHeadsUpManager;
+ @Mock private SystemServicesProxy mSystemServicesProxy;
+ @Mock private NotificationPanelView mNotificationPanelView;
+ @Mock private IStatusBarService mBarService;
+ @Mock private ScrimController mScrimController;
+ @Mock private ArrayList<Entry> mNotificationList;
+ @Mock private FingerprintUnlockController mFingerprintUnlockController;
+ @Mock private NotificationData mNotificationData;
+
+ // Mock dependencies:
+ @Mock private NotificationViewHierarchyManager mViewHierarchyManager;
+ @Mock private VisualStabilityManager mVisualStabilityManager;
+ @Mock private NotificationListener mNotificationListener;
- private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
- private UnlockMethodCache mUnlockMethodCache;
- private KeyguardIndicationController mKeyguardIndicationController;
- private NotificationStackScrollLayout mStackScroller;
private TestableStatusBar mStatusBar;
private FakeMetricsLogger mMetricsLogger;
- private HeadsUpManager mHeadsUpManager;
- private NotificationData mNotificationData;
private PowerManager mPowerManager;
- private SystemServicesProxy mSystemServicesProxy;
- private NotificationPanelView mNotificationPanelView;
- private ScrimController mScrimController;
- private IStatusBarService mBarService;
- private NotificationListener mNotificationListener;
- private NotificationLogger mNotificationLogger;
- private ArrayList<Entry> mNotificationList;
- private FingerprintUnlockController mFingerprintUnlockController;
- private DisplayMetrics mDisplayMetrics = new DisplayMetrics();
private TestableNotificationEntryManager mEntryManager;
- private NotificationViewHierarchyManager mViewHierarchyManager;
- private VisualStabilityManager mVisualStabilityManager;
+ private NotificationLogger mNotificationLogger;
@Before
public void setup() throws Exception {
- mContext.setTheme(R.style.Theme_SystemUI_Light);
+ MockitoAnnotations.initMocks(this);
mDependency.injectMockDependency(AssistManager.class);
mDependency.injectMockDependency(DeviceProvisionedController.class);
mDependency.injectMockDependency(NotificationGroupManager.class);
mDependency.injectMockDependency(NotificationRemoteInputManager.class);
mDependency.injectMockDependency(NotificationMediaManager.class);
mDependency.injectMockDependency(ForegroundServiceController.class);
- mNotificationListener = mDependency.injectMockDependency(NotificationListener.class);
- mViewHierarchyManager = mDependency.injectMockDependency(
- NotificationViewHierarchyManager.class);
- mVisualStabilityManager = mDependency.injectMockDependency(VisualStabilityManager.class);
+ mDependency.injectTestDependency(NotificationViewHierarchyManager.class,
+ mViewHierarchyManager);
+ mDependency.injectTestDependency(VisualStabilityManager.class, mVisualStabilityManager);
+ mDependency.injectTestDependency(NotificationListener.class, mNotificationListener);
mDependency.injectTestDependency(KeyguardMonitor.class, mock(KeyguardMonitorImpl.class));
- CommandQueue commandQueue = mock(CommandQueue.class);
- when(commandQueue.asBinder()).thenReturn(new Binder());
- mContext.putComponent(CommandQueue.class, commandQueue);
+
mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class));
mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class));
- mStatusBarKeyguardViewManager = mock(StatusBarKeyguardViewManager.class);
- mUnlockMethodCache = mock(UnlockMethodCache.class);
- mKeyguardIndicationController = mock(KeyguardIndicationController.class);
- mStackScroller = mock(NotificationStackScrollLayout.class);
- when(mStackScroller.generateLayoutParams(any())).thenReturn(new LayoutParams(0, 0));
+
mMetricsLogger = new FakeMetricsLogger();
- mHeadsUpManager = mock(HeadsUpManager.class);
- mNotificationData = mock(NotificationData.class);
- mSystemServicesProxy = mock(SystemServicesProxy.class);
- mNotificationPanelView = mock(NotificationPanelView.class);
- when(mNotificationPanelView.getLayoutParams()).thenReturn(new LayoutParams(0, 0));
- mNotificationList = mock(ArrayList.class);
- mScrimController = mock(ScrimController.class);
- mFingerprintUnlockController = mock(FingerprintUnlockController.class);
+ mDependency.injectTestDependency(MetricsLogger.class, mMetricsLogger);
+ mNotificationLogger = new NotificationLogger(mNotificationListener,
+ mDependency.get(UiOffloadThread.class));
+ mDependency.injectTestDependency(NotificationLogger.class, mNotificationLogger);
+
IPowerManager powerManagerService = mock(IPowerManager.class);
HandlerThread handlerThread = new HandlerThread("TestThread");
handlerThread.start();
mPowerManager = new PowerManager(mContext, powerManagerService,
new Handler(handlerThread.getLooper()));
- when(powerManagerService.isInteractive()).thenReturn(true);
- mBarService = mock(IStatusBarService.class);
- mNotificationLogger = new NotificationLogger(mNotificationListener, mDependency.get(
- UiOffloadThread.class));
- mDependency.injectTestDependency(MetricsLogger.class, mMetricsLogger);
+ CommandQueue commandQueue = mock(CommandQueue.class);
+ when(commandQueue.asBinder()).thenReturn(new Binder());
+ mContext.putComponent(CommandQueue.class, commandQueue);
- mNotificationListener = mDependency.get(NotificationListener.class);
- mNotificationLogger = mDependency.get(NotificationLogger.class);
- mEntryManager = new TestableNotificationEntryManager(mMetricsLogger,
- mSystemServicesProxy, mPowerManager, mContext);
+ mContext.setTheme(R.style.Theme_SystemUI_Light);
+
+ when(mStackScroller.generateLayoutParams(any())).thenReturn(new LayoutParams(0, 0));
+ when(mNotificationPanelView.getLayoutParams()).thenReturn(new LayoutParams(0, 0));
+ when(powerManagerService.isInteractive()).thenReturn(true);
+ when(mStackScroller.getActivatedChild()).thenReturn(null);
- mStatusBar = new TestableStatusBar(mStatusBarKeyguardViewManager, mUnlockMethodCache,
- mKeyguardIndicationController, mStackScroller, mHeadsUpManager,
- mPowerManager, mNotificationPanelView, mBarService, mNotificationListener,
- mNotificationLogger, mVisualStabilityManager, mViewHierarchyManager,
- mEntryManager, mScrimController, mFingerprintUnlockController);
- mStatusBar.mContext = mContext;
- mStatusBar.mComponents = mContext.getComponents();
doAnswer(invocation -> {
OnDismissAction onDismissAction = (OnDismissAction) invocation.getArguments()[0];
onDismissAction.onDismiss();
return null;
}).when(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(any());
+ mEntryManager = new TestableNotificationEntryManager(mMetricsLogger,
+ mSystemServicesProxy, mPowerManager, mContext);
+ mStatusBar = new TestableStatusBar(mStatusBarKeyguardViewManager, mUnlockMethodCache,
+ mKeyguardIndicationController, mStackScroller, mHeadsUpManager,
+ mPowerManager, mNotificationPanelView, mBarService, mNotificationListener,
+ mNotificationLogger, mVisualStabilityManager, mViewHierarchyManager,
+ mEntryManager, mScrimController, mFingerprintUnlockController);
+ mStatusBar.mContext = mContext;
+ mStatusBar.mComponents = mContext.getComponents();
mEntryManager.setUpForTest(mStatusBar, mStackScroller, mStatusBar, mHeadsUpManager,
mNotificationData);
mNotificationLogger.setUpWithPresenter(mStatusBar, mStackScroller);
- when(mStackScroller.getActivatedChild()).thenReturn(null);
TestableLooper.get(this).setMessageHandler(m -> {
if (m.getCallback() == mStatusBar.mNotificationLogger.getVisibilityReporter()) {
return false;