• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 android.platform.helpers;
18 
19 import android.app.Notification;
20 import android.support.test.uiautomator.BySelector;
21 import android.support.test.uiautomator.Direction;
22 import android.support.test.uiautomator.UiObject2;
23 
24 import androidx.annotation.Nullable;
25 
26 /** An App Helper interface for the Notification. */
27 public interface INotificationHelper extends IAppHelper {
28 
29     String UI_PACKAGE_NAME_SYSUI = "com.android.systemui";
30     String UI_PACKAGE_NAME_ANDROID = "android";
31     String UI_NOTIFICATION_ID = "status_bar_latest_event_content";
32     String NOTIFICATION_TITLE_TEXT = "TEST NOTIFICATION";
33     String NOTIFICATION_CONTENT_TEXT = "Test notification content";
34     String NOTIFICATION_BIG_TEXT = "lorem ipsum dolor sit amet\n"
35             + "lorem ipsum dolor sit amet\n"
36             + "lorem ipsum dolor sit amet\n"
37             + "lorem ipsum dolor sit amet";
38     String NOTIFICATION_CHANNEL_NAME = "Test Channel";
39     String EXPAND_BUTTON_ID = "expand_button";
40     String APP_ICON_ID = "icon";
41 
42     /**
43      * Setup expectations: Notification shade opened.
44      *
45      * <p>Opens a notification from notification shade.
46      *
47      * @param index The index of the notification to open.
48      */
openNotificationbyIndex(int index)49     default void openNotificationbyIndex(int index) {
50         throw new UnsupportedOperationException("Not yet implemented.");
51     }
52 
53     /**
54      * Setup Expectations: None
55      *
56      * <p>Posts a number of notifications to the device. Successive calls to this should post
57      * new notifications to those previously posted. Note that this may fail if the helper has
58      * surpassed the system-defined limit for per-package notifications.
59      *
60      * @param count The number of notifications to post.
61      */
postNotifications(int count)62     default void postNotifications(int count) {
63         throw new UnsupportedOperationException("Not yet implemented.");
64     }
65 
66     /**
67      * Setup Expectations: Shade is open
68      *
69      * <p>Posts a notification using {@link android.app.Notification.BigTextStyle}.
70      *
71      * @param pkg App to launch, when clicking on notification.
72      */
postBigTextNotification(@ullable String pkg)73     default UiObject2 postBigTextNotification(@Nullable String pkg) {
74         throw new UnsupportedOperationException("Not yet implemented.");
75     }
76 
77     /**
78      * Setup Expectations: Shade is open
79      *
80      * <p>Posts a notification using {@link android.app.Notification.BigPictureStyle}.
81      *
82      * @param pkg App to launch, when clicking on notification.
83      */
postBigPictureNotification(String pkg)84     default UiObject2 postBigPictureNotification(String pkg) {
85         throw new UnsupportedOperationException("Not yet implemented.");
86     }
87 
88     /**
89      * Setup Expectations: Shade is open
90      *
91      * <p>Posts a notification using {@link android.app.Notification.MessagingStyle}.
92      *
93      * @param pkg App to launch, when clicking on notification.
94      */
postMessagingStyleNotification(String pkg)95     default UiObject2 postMessagingStyleNotification(String pkg) {
96         throw new UnsupportedOperationException("Not yet implemented.");
97     }
98 
99     /**
100      * Setup Expectations: Shade is open
101      *
102      * <p>Posts a conversation notification. This notification is associated with a conversation
103      * shortcut and in {@link android.app.Notification.MessagingStyle}.
104      *
105      * @param pkg App to launch, when clicking on notification.
106      */
postConversationNotification(String pkg)107     default UiObject2 postConversationNotification(String pkg) {
108         throw new UnsupportedOperationException("Not yet implemented.");
109     }
110 
111     /**
112      * Setup Expectations: None
113      *
114      * <p>Posts a number of notifications to the device with a package to launch. Successive calls
115      * to this should post new notifications in addition to those previously posted. Note that this
116      * may fail if the helper has surpassed the system-defined limit for per-package notifications.
117      *
118      * @param count The number of notifications to post.
119      * @param pkg The application that will be launched by notifications.
120      */
postNotifications(int count, String pkg)121     default void postNotifications(int count, String pkg) {
122         throw new UnsupportedOperationException("Not yet implemented.");
123     }
124 
125     /**
126      * Setup Expectations: None
127      *
128      * <p>Posts a number of notifications to the device with a package to launch. Successive calls
129      * to this should post new notifications in addition to those previously posted. Note that this
130      * may fail if the helper has surpassed the system-defined limit for per-package notifications.
131      *
132      * @param count The number of notifications to post.
133      * @param pkg The application that will be launched by notifications.
134      * @param interrupting If notification should make sounds and be on top section of the shade.
135      */
postNotifications(int count, String pkg, boolean interrupting)136     default void postNotifications(int count, String pkg, boolean interrupting) {
137         throw new UnsupportedOperationException("Not yet implemented.");
138     }
139 
140     /**
141      * Setup Expectations: None
142      *
143      * <p>Posts notification.
144      *
145      * @param builder Builder for notification to post.
146      */
postNotification(Notification.Builder builder)147     default void postNotification(Notification.Builder builder) {
148         throw new UnsupportedOperationException("Not yet implemented.");
149     }
150 
151     /**
152      * Setup Expectations: None
153      *
154      * <p>Cancel any notifications posted by this helper.
155      */
cancelNotifications()156     default void cancelNotifications() {
157         throw new UnsupportedOperationException("Not yet implemented.");
158     }
159 
160     /**
161      * Setup expectations: Notification shade opened.
162      *
163      * <p>Opens the first notification by the specified title and checks if the expected application
164      * is in foreground or not
165      *
166      * @param title The title of the notification to open.
167      * @param expectedPkg The foreground application after opening a notification. Won't check the
168      *     foreground application if the application is null
169      */
openNotificationByTitle(String title, String expectedPkg)170     default void openNotificationByTitle(String title, String expectedPkg) {
171         throw new UnsupportedOperationException("Not yet implemented.");
172     }
173 
174     /**
175      * Setup expectations: Notification shade opened.
176      *
177      * <p>Taps the chevron or swipes down on the specified notification and checks if the
178      * expanded view contains the expected text.
179      *
180      * @param notification Notification that should be expanded.
181      * @param dragging By swiping down when {@code true}, by tapping the chevron otherwise.
182      */
expandNotification(UiObject2 notification, boolean dragging)183     default void expandNotification(UiObject2 notification, boolean dragging) {
184         throw new UnsupportedOperationException("Not yet implemented.");
185     }
186 
187     /**
188      * Long press on notification to show its hidden menu (a.k.a. guts)
189      *
190      * @param notification Notification.
191      */
showGuts(UiObject2 notification)192     default void showGuts(UiObject2 notification) {
193         throw new UnsupportedOperationException("Not yet implemented.");
194     }
195 
196     /**
197      * Taps the "Done" button on the notification guts.
198      *
199      * @param notification Notification.
200      */
hideGuts(UiObject2 notification)201     default void hideGuts(UiObject2 notification) {
202         throw new UnsupportedOperationException("Not yet implemented.");
203     }
204 
205     /**
206      * Setup expectations: Notification shade opened.
207      *
208      * <p>Find the screenshot notification; expand the notification if it's collapsed and click on
209      * the "share" button.
210      */
shareScreenshotFromNotification(BySelector pageSelector)211     default void shareScreenshotFromNotification(BySelector pageSelector) {
212         throw new UnsupportedOperationException("Not yet implemented.");
213     }
214 
215     /**
216      * Setup expectation: On the expanding notification screen.
217      *
218      * <p>Get the UiObject2 of expanding notification screen.
219      */
getNotificationShadeScrollContainer()220     default UiObject2 getNotificationShadeScrollContainer() {
221         throw new UnsupportedOperationException("Not yet implemented.");
222     }
223 
224     /**
225      * Scroll feeds on Notifications screen
226      *
227      * <p>Setup expectations: Notification is open with lots of notifications.
228      *
229      * @param container The container with scrollable elements.
230      * @param dir The direction of the fling, must be UP or DOWN.
231      */
flingFeed(UiObject2 container, Direction dir)232     default void flingFeed(UiObject2 container, Direction dir) {
233         throw new UnsupportedOperationException("Not yet implemented.");
234     }
235 
236     /**
237      * Scroll feeds on Notifications screen
238      *
239      * <p>Setup expectations: Notification is open with lots of notifications.
240      *
241      * @param container The container with scrollable elements.
242      * @param dir The direction of the scroll, must be UP or DOWN.
243      * @param speed The speed of fling.
244      */
flingFeed(UiObject2 container, Direction dir, int speed)245     default void flingFeed(UiObject2 container, Direction dir, int speed) {
246         throw new UnsupportedOperationException("Not yet implemented.");
247     }
248 }
249