From a947a01211d47a73237f98ed37550208a94c6932 Mon Sep 17 00:00:00 2001 From: Alastor Wu Date: Tue, 2 May 2017 18:53:26 +0800 Subject: [PATCH] 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 --- .../mozilla/gecko/tests/MediaPlaybackTest.java | 16 ++++++++++++++-- .../mozilla/gecko/tests/testMediaControl.java | 7 +++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/MediaPlaybackTest.java b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/MediaPlaybackTest.java index 430bc660f453..03d487231256 100644 --- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/MediaPlaybackTest.java +++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/MediaPlaybackTest.java @@ -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."); diff --git a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testMediaControl.java b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testMediaControl.java index 2bfa7f9fe0f5..27b8075e4a43 100644 --- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testMediaControl.java +++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testMediaControl.java @@ -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();