• 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 
21 import androidx.annotation.NonNull;
22 import androidx.annotation.Nullable;
23 import androidx.test.uiautomator.BySelector;
24 import androidx.test.uiautomator.Direction;
25 import androidx.test.uiautomator.UiObject2;
26 
27 import java.util.List;
28 
29 /**
30  * An App Helper interface for the Notification.
31  *
32  * @deprecated use classes from the "systemui-tapl" library instead
33  */
34 @Deprecated
35 public interface INotificationHelper extends IAppHelper {
36 
37     String NOTIFICATION_CONTENT_TEXT = "Test notification content";
38     String EXPAND_BUTTON_ID = "expand_button";
39 
40     /**
41      * Setup expectations: Notification shade opened.
42      *
43      * <p>Opens a notification from notification shade.
44      *
45      * @param index The index of the notification to open.
46      */
openNotificationbyIndex(int index)47     default void openNotificationbyIndex(int index) {
48         throw new UnsupportedOperationException("Not yet implemented.");
49     }
50 
51     /**
52      * Wait until pop-up notification dismissed
53      *
54      * @return true if notification is dismissed before internal timeout
55      */
waitPopUpNotificationAutoDismissed()56     default boolean waitPopUpNotificationAutoDismissed() {
57         throw new UnsupportedOperationException("Not yet implemented.");
58     }
59 
60     /**
61      * Setup Expectations: None
62      *
63      * <p>Posts a number of notifications to the device. Successive calls to this should post new
64      * notifications to those previously posted. Note that this may fail if the helper has surpassed
65      * the system-defined limit for per-package notifications.
66      *
67      * @param count The number of notifications to post.
68      */
postNotifications(int count)69     default void postNotifications(int count) {
70         throw new UnsupportedOperationException("Not yet implemented.");
71     }
72 
73     /**
74      * Setup Expectations: Shade is open
75      *
76      * <p>Posts a notification using {@link android.app.Notification.BigTextStyle}.
77      *
78      * @param pkg App to launch, when clicking on notification.
79      */
postBigTextNotification(@ullable String pkg)80     default UiObject2 postBigTextNotification(@Nullable String pkg) {
81         throw new UnsupportedOperationException("Not yet implemented.");
82     }
83 
84     /**
85      * Setup Expectations: Shade is open
86      *
87      * <p>Posts a notification using {@link android.app.Notification.BigPictureStyle}.
88      *
89      * @param pkg App to launch, when clicking on notification.
90      */
postBigPictureNotification(String pkg)91     default UiObject2 postBigPictureNotification(String pkg) {
92         throw new UnsupportedOperationException("Not yet implemented.");
93     }
94 
95     /**
96      * Setup Expectations: Shade is open
97      *
98      * <p>Posts a notification using {@link android.app.Notification.MessagingStyle}.
99      *
100      * @param pkg App to launch, when clicking on notification.
101      */
postMessagingStyleNotification(String pkg)102     default UiObject2 postMessagingStyleNotification(String pkg) {
103         throw new UnsupportedOperationException("Not yet implemented.");
104     }
105 
106     /**
107      * Setup Expectations: None
108      *
109      * <p>Posts a number of notifications to the device with a groupId. Successive calls to this
110      * should post new notifications in addition to those previously posted. Note that this may fail
111      * if the helper has surpassed the system-defined limit for per-package notifications.
112      *
113      * @param count The number of notifications to post.
114      * @param pkg The application that will be launched by notifications.
115      * @param summary Summary text for this group notification
116      */
postGroupNotifications(int count, @Nullable String pkg, @NonNull String summary)117     default void postGroupNotifications(int count, @Nullable String pkg, @NonNull String summary) {
118         throw new UnsupportedOperationException("Not yet implemented.");
119     }
120 
121     /**
122      * Get the default title text used for notification
123      *
124      * @return the default title text
125      */
126     @NonNull
getDefaultNotificationTitleText()127     default String getDefaultNotificationTitleText() {
128         throw new UnsupportedOperationException("Not yet implemented.");
129     }
130 
131     /**
132      * @return the notification shelf, containing overflow notifications that don't fit in the
133      *     screen. If unavailable, returns null.
134      */
135     @Nullable
getNotificationShelf()136     default UiObject2 getNotificationShelf() {
137         throw new UnsupportedOperationException("Not yet implemented.");
138     }
139 
140     /**
141      * Setup Expectations: Shade is open
142      *
143      * <p>Posts multiple bubble notification. These notifications are associated with a conversation
144      * shortcut, a BubbleMetadata, and in {@link android.app.Notification.MessagingStyle}.
145      *
146      * @param senderName Name of notification sender.
147      * @param count How many bubble notifications to send.
148      */
postBubbleNotification(String senderName, int count)149     default void postBubbleNotification(String senderName, int count) {
150         throw new UnsupportedOperationException("Not yet implemented.");
151     }
152 
153     /**
154      * Setup Expectations: Shade is open
155      *
156      * <p>Posts multiple bubble notification. These notifications are associated with a conversation
157      * shortcut, a BubbleMetadata, and in {@link android.app.Notification.MessagingStyle}.
158      *
159      * @param senderName Name of notification sender.
160      * @param count How many bubble notifications to send.
161      * @param id The starting id for the notifications. If the starting id is 1000 and count is 3
162      *     then three notifications will be posted and the id's will be: 1000, 1001, 1002.
163      */
postBubbleNotification(String senderName, int count, int id)164     default void postBubbleNotification(String senderName, int count, int id) {
165         throw new UnsupportedOperationException("Not yet implemented.");
166     }
167 
168     /**
169      * Posts a bubble notification. This notification is associated with a conversation shortcut, a
170      * BubbleMetadata, and in {@link android.app.Notification.MessagingStyle}.
171      *
172      * @param senderName Name of notification sender.
173      * @param id An unique notification identifier.
174      * @param text Notification message content.
175      * @param shortcutId id of the shortcut used in the notification.
176      * @param messageToActivity message to send to bubble test activity.
177      */
postBubbleNotification( String senderName, int id, String text, String shortcutId, String messageToActivity)178     default void postBubbleNotification(
179             String senderName, int id, String text, String shortcutId, String messageToActivity) {
180         throw new UnsupportedOperationException("Not yet implemented.");
181     }
182 
183     /**
184      * Posts a bubble notification. This notification is associated with a conversation shortcut, a
185      * BubbleMetadata, and in {@link android.app.Notification.MessagingStyle}.
186      *
187      * @param senderName Name of notification sender.
188      * @param id An unique notification identifier.
189      * @param text Notification message content.
190      */
postBubbleNotification(String senderName, int id, String text)191     default void postBubbleNotification(String senderName, int id, String text) {
192         throw new UnsupportedOperationException("Not yet implemented.");
193     }
194 
195     /**
196      * Updates an existing notification
197      *
198      * @param senderName Name of notification sender.
199      * @param id An identifier of the notification to be updated.
200      * @param text Update message content.
201      */
updateBubbleNotification(String senderName, int id, String text)202     default void updateBubbleNotification(String senderName, int id, String text) {
203         throw new UnsupportedOperationException("Not yet implemented.");
204     }
205 
206     /**
207      * Return notification if found by text.
208      *
209      * @param text Text that notification contains.
210      */
getNotificationByText(String text)211     default UiObject2 getNotificationByText(String text) {
212         throw new UnsupportedOperationException("Not yet implemented.");
213     }
214 
215     /**
216      * Return expandableNotificationRows if found
217      *
218      * @return List of expandableNotificationRow
219      */
getExpandableNotificationRows()220     default List<UiObject2> getExpandableNotificationRows() {
221         throw new UnsupportedOperationException("Not yet implemented.");
222     }
223 
224     /**
225      * Setup Expectations: Shade is open
226      *
227      * <p>Posts a conversation notification. This notification is associated with a conversation
228      * shortcut and in {@link android.app.Notification.MessagingStyle}.
229      *
230      * @param pkg App to launch, when clicking on notification.
231      */
postConversationNotification(String pkg)232     default UiObject2 postConversationNotification(String pkg) {
233         throw new UnsupportedOperationException("Not yet implemented.");
234     }
235 
236     /**
237      * Setup Expectations: None
238      *
239      * <p>Posts a number of notifications to the device with a package to launch. Successive calls
240      * to this should post new notifications in addition to those previously posted. Note that this
241      * may fail if the helper has surpassed the system-defined limit for per-package notifications.
242      *
243      * @param count The number of notifications to post.
244      * @param pkg The application that will be launched by notifications.
245      */
postNotifications(int count, String pkg)246     default void postNotifications(int count, String pkg) {
247         throw new UnsupportedOperationException("Not yet implemented.");
248     }
249 
250     /**
251      * Setup Expectations: None
252      *
253      * <p>Posts a number of notifications to the device with a package to launch. Successive calls
254      * to this should post new notifications in addition to those previously posted. Note that this
255      * may fail if the helper has surpassed the system-defined limit for per-package notifications.
256      *
257      * @param count The number of notifications to post.
258      * @param pkg The application that will be launched by notifications.
259      * @param interrupting If notification should make sounds and be on top section of the shade.
260      */
postNotifications(int count, String pkg, boolean interrupting)261     default void postNotifications(int count, String pkg, boolean interrupting) {
262         throw new UnsupportedOperationException("Not yet implemented.");
263     }
264 
265     /**
266      * Setup Expectations: None
267      *
268      * <p>Posts notification.
269      *
270      * @param builder Builder for notification to post.
271      */
postNotification(Notification.Builder builder)272     default void postNotification(Notification.Builder builder) {
273         throw new UnsupportedOperationException("Not yet implemented.");
274     }
275 
276     /**
277      * Setup Expectations: None
278      *
279      * <p>Cancel any notifications posted by this helper.
280      */
cancelNotifications()281     default void cancelNotifications() {
282         throw new UnsupportedOperationException("Not yet implemented.");
283     }
284 
285     /**
286      * Setup Expectations: Notification shade opened.
287      *
288      * <p>Determines if the notification shade is showing the "empty shade view"
289      */
isShowingEmptyShade()290     default boolean isShowingEmptyShade() {
291         throw new UnsupportedOperationException("Not yet implemented.");
292     }
293 
294     /**
295      * Setup Expectations: Notification shade opened.
296      *
297      * <p>Determines if the notification shade is showing the "footer view", which indicates that
298      * there are nonzero notifications and that the shade is scrolled to the bottom.
299      */
isShowingFooter()300     default boolean isShowingFooter() {
301         throw new UnsupportedOperationException("Not yet implemented.");
302     }
303 
304     /**
305      * Setup Expectations: Notification shade opened.
306      *
307      * <p>Scrolls to the bottom of the notification shade, as determined by the "manage" button in
308      * the footer being visible.
309      */
scrollToBottom()310     default void scrollToBottom() {
311         throw new UnsupportedOperationException("Not yet implemented.");
312     }
313 
314     /**
315      * Setup Expectations: Notification shade opened, clearable notifications exist.
316      *
317      * <p>Scrolls to the bottom of the notification shade and taps the "clear all" button, which
318      * must be present.
319      */
clearAllNotifications()320     default void clearAllNotifications() {
321         throw new UnsupportedOperationException("Not yet implemented.");
322     }
323 
324     /**
325      * Setup expectations: Notification shade opened.
326      *
327      * <p>Opens the first notification by the specified title and checks if the expected application
328      * is in foreground or not
329      *
330      * @param title The title of the notification to open.
331      * @param expectedPkg The foreground application after opening a notification. Won't check the
332      *     foreground application if the application is null
333      */
openNotificationByTitle(String title, String expectedPkg)334     default void openNotificationByTitle(String title, String expectedPkg) {
335         throw new UnsupportedOperationException("Not yet implemented.");
336     }
337 
338     /**
339      * Setup expectations: Notification shade opened.
340      *
341      * <p>Taps the chevron or swipes down on the specified notification and checks if the expanded
342      * view contains the expected text.
343      *
344      * @param notification Notification that should be expanded.
345      * @param dragging By swiping down when {@code true}, by tapping the chevron otherwise.
346      */
expandNotification(UiObject2 notification, boolean dragging)347     default void expandNotification(UiObject2 notification, boolean dragging) {
348         throw new UnsupportedOperationException("Not yet implemented.");
349     }
350 
351     /**
352      * Sets expected app name for notifications.
353      *
354      * @param appName Package name.
355      */
setAppName(String appName)356     default void setAppName(String appName) {
357         throw new UnsupportedOperationException("Not yet implemented.");
358     }
359 
360     /**
361      * Long press on notification to show its hidden menu (a.k.a. guts)
362      *
363      * @param notification Notification.
364      */
showGuts(UiObject2 notification)365     default void showGuts(UiObject2 notification) {
366         throw new UnsupportedOperationException("Not yet implemented.");
367     }
368 
369     /**
370      * Taps the "Done" button on the notification guts.
371      *
372      * @param notification Notification.
373      */
hideGuts(UiObject2 notification)374     default void hideGuts(UiObject2 notification) {
375         throw new UnsupportedOperationException("Not yet implemented.");
376     }
377 
378     /**
379      * Setup expectations: Notification shade opened.
380      *
381      * <p>Find the screenshot notification; expand the notification if it's collapsed and click on
382      * the "share" button.
383      */
shareScreenshotFromNotification(BySelector pageSelector)384     default void shareScreenshotFromNotification(BySelector pageSelector) {
385         throw new UnsupportedOperationException("Not yet implemented.");
386     }
387 
388     /**
389      * Setup expectation: On the expanding notification screen.
390      *
391      * <p>Get the UiObject2 of expanding notification screen.
392      */
getNotificationShadeScrollContainer()393     default UiObject2 getNotificationShadeScrollContainer() {
394         throw new UnsupportedOperationException("Not yet implemented.");
395     }
396 
397     /**
398      * Setup expectation: On the expanding notification screen.
399      *
400      * <p>Get the UiObject2 of Quick Settings container. Quick settings container works both in
401      * expanded and collapsed state, that is contains both QuickQuickSettings and QuickSettings
402      */
getQuickSettingsContainer()403     default UiObject2 getQuickSettingsContainer() {
404         throw new UnsupportedOperationException("Not yet implemented.");
405     }
406 
407     /**
408      * Scroll feeds on Notifications screen
409      *
410      * <p>Setup expectations: Notification is open with lots of notifications.
411      *
412      * @param container The container with scrollable elements.
413      * @param dir The direction of the fling, must be UP or DOWN.
414      */
flingFeed(UiObject2 container, Direction dir)415     default void flingFeed(UiObject2 container, Direction dir) {
416         throw new UnsupportedOperationException("Not yet implemented.");
417     }
418 
419     /**
420      * Scroll feeds on Notifications screen and implement it via "fling" API.
421      *
422      * <p>Setup expectations: Notification is open with lots of notifications.
423      *
424      * @param container The container with scrollable elements.
425      * @param dir The direction of the scroll, must be UP or DOWN.
426      * @param speed The speed of fling.
427      */
flingFeed(UiObject2 container, Direction dir, int speed)428     default void flingFeed(UiObject2 container, Direction dir, int speed) {
429         throw new UnsupportedOperationException("Not yet implemented.");
430     }
431 
432     /**
433      * Setup expectation: on the launcher home screen.
434      *
435      * <p>Open the notification shade by swiping on the home screen.
436      */
swipeToOpen()437     default void swipeToOpen() {
438         throw new UnsupportedOperationException("Not yet implemented.");
439     }
440 
441     /** Closes the notification shade by swiping up. */
swipeToClose()442     default void swipeToClose() {
443         throw new UnsupportedOperationException("Not yet implemented.");
444     }
445 
446     /**
447      * Scroll feeds on Notifications screen and implement it by "swipe" API to control the distance.
448      *
449      * <p>Setup expectations: Notification drawer is open with lots of notifications.
450      *
451      * @param container the container with scrollable elements.
452      * @param dir the direction to scroll, must be UP or DOWN.
453      * @param percent The distance to scroll as a percentage of the page's visible size.
454      */
scrollFeed(UiObject2 container, Direction dir, float percent)455     default void scrollFeed(UiObject2 container, Direction dir, float percent) {
456         throw new UnsupportedOperationException("Not yet implemented.");
457     }
458 }
459