Bug 1357639 - part7 : add check for notification's content. r=sebastian

Add check for media notification's small icon, title and content text.

MozReview-Commit-ID: AOhag8gQVqs

--HG--
extra : rebase_source : 2be27f95b2bc48b998734d8e702fc084b5b93683
This commit is contained in:
Alastor Wu 2017-05-02 18:53:26 +08:00
parent 310fb8528b
commit a947a01211
2 changed files with 19 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import android.content.Context;
import android.app.Notification;
import android.app.NotificationManager;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.service.notification.StatusBarNotification;
@ -125,11 +126,11 @@ abstract class MediaPlaybackTest extends BaseTest {
if (clearNotification) {
checkIfMediaNotificationBeCleared();
} else {
checkMediaNotificationStates(isTabPlaying);
checkMediaNotificationStates(isTabPlaying, tab);
}
}
protected void checkMediaNotificationStates(boolean isTabPlaying) {
protected void checkMediaNotificationStates(boolean isTabPlaying, Tab tab) {
NotificationManager notificationManager = (NotificationManager)
getContext().getSystemService(Context.NOTIFICATION_SERVICE);
@ -138,6 +139,17 @@ abstract class MediaPlaybackTest extends BaseTest {
"Should only have one notification in system's status bar.");
Notification notification = sbns[0].getNotification();
mAsserter.is(notification.icon,
R.drawable.flat_icon,
"Notification shows correct small icon.");
mAsserter.is(notification.extras.get(Notification.EXTRA_TITLE),
tab.getTitle(),
"Notification shows correct title.");
mAsserter.is(notification.extras.get(Notification.EXTRA_TEXT),
tab.getURL(),
"Notification shows correct text.");
mAsserter.is(notification.actions.length, 1,
"Only has one action in notification.");

View File

@ -4,6 +4,8 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.media.MediaControlService;
import android.media.AudioManager;
@ -112,8 +114,9 @@ public class testMediaControl extends MediaPlaybackTest {
final String BLANK_URL = getAbsoluteUrl(mStringHelper.ROBOCOP_BLANK_PAGE_01_URL);
addTab(BLANK_URL);
info("- the media control shouldn't be changed -");
checkMediaNotificationStates(true /* playing */);
info("- the media control shouldn't be changed and display the info of audible tab -");
final Tab tab = Tabs.getInstance().getFirstTabForUrl(MEDIA_URL);
checkMediaNotificationStates(true /* playing */, tab);
info("- close tab -");
closeAllTabs();