blob: e04d25b17c71072494e496f1dbe33abe4702ce30 [file] [log] [blame]
Selim Cinekf8c4add2017-06-08 09:54:58 -07001/*
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.phone;
18
Dave Mankoffaf8163f2020-01-08 14:24:35 -050019import static org.mockito.Mockito.spy;
Selim Cinekf8c4add2017-06-08 09:54:58 -070020import static org.mockito.Mockito.verify;
21import static org.mockito.Mockito.when;
22
Selim Cinekf8c4add2017-06-08 09:54:58 -070023import android.os.SystemClock;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040024import android.testing.AndroidTestingRunner;
Lucas Dupin2a2a2522019-03-08 18:53:34 -080025import android.testing.TestableLooper;
Selim Cinekf8c4add2017-06-08 09:54:58 -070026import android.view.MotionEvent;
Selim Cinekf8c4add2017-06-08 09:54:58 -070027
Brett Chabot84151d92019-02-27 15:37:59 -080028import androidx.test.filters.SmallTest;
Brett Chabot84151d92019-02-27 15:37:59 -080029
Dave Mankoffaf8163f2020-01-08 14:24:35 -050030import com.android.systemui.R;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040031import com.android.systemui.SystemUIFactory;
Selim Cinekf8c4add2017-06-08 09:54:58 -070032import com.android.systemui.SysuiTestCase;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040033import com.android.systemui.classifier.FalsingManagerFake;
Jerry Chang50c5da42019-10-16 17:21:07 +080034import com.android.systemui.dock.DockManager;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040035import com.android.systemui.doze.DozeLog;
36import com.android.systemui.shared.plugins.PluginManager;
Dave Mankoffbcaca8a2019-10-31 18:04:08 -040037import com.android.systemui.statusbar.CommandQueue;
Selim Cinekf8c4add2017-06-08 09:54:58 -070038import com.android.systemui.statusbar.DragDownHelper;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040039import com.android.systemui.statusbar.NotificationLockscreenUserManager;
Lucas Dupin13f4b8a2020-02-19 13:41:52 -080040import com.android.systemui.statusbar.NotificationShadeDepthController;
Beverlyf937f292020-02-20 13:45:36 -050041import com.android.systemui.statusbar.PulseExpansionHandler;
42import com.android.systemui.statusbar.SuperStatusBarViewFactory;
Lucas Dupind236ee32019-10-08 15:33:59 -070043import com.android.systemui.statusbar.SysuiStatusBarStateController;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040044import com.android.systemui.statusbar.notification.DynamicPrivacyController;
45import com.android.systemui.statusbar.notification.NotificationEntryManager;
46import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
Dave Mankoffaf8163f2020-01-08 14:24:35 -050047import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
Lucas Dupind236ee32019-10-08 15:33:59 -070048import com.android.systemui.statusbar.policy.KeyguardStateController;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040049import com.android.systemui.tuner.TunerService;
50import com.android.systemui.util.InjectionInflationController;
Selim Cinekf8c4add2017-06-08 09:54:58 -070051
52import org.junit.Before;
53import org.junit.Test;
54import org.junit.runner.RunWith;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040055import org.mockito.Mock;
56import org.mockito.MockitoAnnotations;
Selim Cinekf8c4add2017-06-08 09:54:58 -070057
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040058@RunWith(AndroidTestingRunner.class)
59@TestableLooper.RunWithLooper(setAsMainLooper = true)
Selim Cinekf8c4add2017-06-08 09:54:58 -070060@SmallTest
wilsonshihe8321942019-10-18 18:39:46 +080061public class NotificationShadeWindowViewTest extends SysuiTestCase {
Selim Cinekf8c4add2017-06-08 09:54:58 -070062
wilsonshihe8321942019-10-18 18:39:46 +080063 private NotificationShadeWindowView mView;
64 private NotificationShadeWindowViewController mController;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040065
66 @Mock private NotificationWakeUpCoordinator mCoordinator;
67 @Mock private PulseExpansionHandler mPulseExpansionHandler;
68 @Mock private DynamicPrivacyController mDynamicPrivacyController;
69 @Mock private KeyguardBypassController mBypassController;
70 @Mock private PluginManager mPluginManager;
71 @Mock private TunerService mTunerService;
72 @Mock private DragDownHelper mDragDownHelper;
Lucas Dupind236ee32019-10-08 15:33:59 -070073 @Mock private KeyguardStateController mKeyguardStateController;
74 @Mock private SysuiStatusBarStateController mStatusBarStateController;
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040075 @Mock private ShadeController mShadeController;
76 @Mock private NotificationLockscreenUserManager mNotificationLockScreenUserManager;
77 @Mock private NotificationEntryManager mNotificationEntryManager;
78 @Mock private StatusBar mStatusBar;
79 @Mock private DozeLog mDozeLog;
Dave Mankoff2aff6c32019-10-14 17:40:37 -040080 @Mock private DozeParameters mDozeParameters;
Jerry Chang50c5da42019-10-16 17:21:07 +080081 @Mock private DockManager mDockManager;
Dave Mankoffaf8163f2020-01-08 14:24:35 -050082 @Mock private NotificationPanelViewController mNotificationPanelViewController;
83 @Mock private NotificationStackScrollLayout mNotificationStackScrollLayout;
Lucas Dupin13f4b8a2020-02-19 13:41:52 -080084 @Mock private NotificationShadeDepthController mNotificationShadeDepthController;
Beverlyf937f292020-02-20 13:45:36 -050085 @Mock private SuperStatusBarViewFactory mStatusBarViewFactory;
wilsonshih2065eb72020-05-06 17:44:37 +080086 @Mock private NotificationShadeWindowController mNotificationShadeWindowController;
Selim Cinekf8c4add2017-06-08 09:54:58 -070087
88 @Before
89 public void setUp() {
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040090 MockitoAnnotations.initMocks(this);
91
wilsonshihe8321942019-10-18 18:39:46 +080092 mView = spy(new NotificationShadeWindowView(getContext(), null));
Dave Mankoffaf8163f2020-01-08 14:24:35 -050093 when(mView.findViewById(R.id.notification_stack_scroller))
94 .thenReturn(mNotificationStackScrollLayout);
wilsonshihe8321942019-10-18 18:39:46 +080095
Heemin Seoge9f4e962019-12-05 11:55:27 -080096 when(mStatusBarStateController.isDozing()).thenReturn(false);
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -040097 mDependency.injectTestDependency(ShadeController.class, mShadeController);
98
Jerry Chang50c5da42019-10-16 17:21:07 +080099 when(mDockManager.isDocked()).thenReturn(false);
Heemin Seogafb3dbc2019-11-04 16:05:19 -0800100
wilsonshihe8321942019-10-18 18:39:46 +0800101 mController = new NotificationShadeWindowViewController(
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -0400102 new InjectionInflationController(
103 SystemUIFactory.getInstance().getRootComponent()),
104 mCoordinator,
105 mPulseExpansionHandler,
106 mDynamicPrivacyController,
107 mBypassController,
108 new FalsingManagerFake(),
109 mPluginManager,
110 mTunerService,
111 mNotificationLockScreenUserManager,
112 mNotificationEntryManager,
Lucas Dupind236ee32019-10-08 15:33:59 -0700113 mKeyguardStateController,
114 mStatusBarStateController,
Dave Mankoff2aff6c32019-10-14 17:40:37 -0400115 mDozeLog,
Dave Mankoffbcaca8a2019-10-31 18:04:08 -0400116 mDozeParameters,
Heemin Seogafb3dbc2019-11-04 16:05:19 -0800117 new CommandQueue(mContext),
Heemin Seogba6337f2019-12-10 15:34:37 -0800118 mShadeController,
Dave Mankoffc1bbce12019-11-25 11:27:36 -0500119 mDockManager,
Lucas Dupin13f4b8a2020-02-19 13:41:52 -0800120 mNotificationShadeDepthController,
Dave Mankoffaf8163f2020-01-08 14:24:35 -0500121 mView,
Beverlyf937f292020-02-20 13:45:36 -0500122 mNotificationPanelViewController,
123 mStatusBarViewFactory);
Heemin Seog82b96cd2019-11-12 16:40:00 -0800124 mController.setupExpandedStatusBar();
wilsonshih2065eb72020-05-06 17:44:37 +0800125 mController.setService(mStatusBar, mNotificationShadeWindowController);
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -0400126 mController.setDragDownHelper(mDragDownHelper);
127
Selim Cinekf8c4add2017-06-08 09:54:58 -0700128 }
129
130 @Test
Dave Mankoff0cf8dfc2019-09-27 12:46:41 -0400131 public void testDragDownHelperCalledWhenDraggingDown() {
Selim Cinekf8c4add2017-06-08 09:54:58 -0700132 when(mDragDownHelper.isDraggingDown()).thenReturn(true);
133 long now = SystemClock.elapsedRealtime();
134 MotionEvent ev = MotionEvent.obtain(now, now, MotionEvent.ACTION_UP, 0 /* x */, 0 /* y */,
135 0 /* meta */);
136 mView.onTouchEvent(ev);
137 verify(mDragDownHelper).onTouchEvent(ev);
138 ev.recycle();
139 }
140}