Bug 1357639 - part7 : add check for notification's content. r=sebastian
☠☠ backed out by 7116303fc869 ☠ ☠
authorAlastor Wu <alwu@mozilla.com>
Tue, 02 May 2017 18:53:26 +0800
changeset 356007 99c71dd11632a4a77c12cec16b8f2561f5b0e35d
parent 356006 4b332b74aba66ae58d917bc913073a9411afa37d
child 356008 d37e0ce6c7c9c28a0b991cc9d2a34390a127d7a0
push id31754
push userkwierso@gmail.com
push dateWed, 03 May 2017 00:28:51 +0000
treeherdermozilla-central@5eaf2d70eded [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1357639
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/MediaPlaybackTest.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testMediaControl.java
--- 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
@@ -12,16 +12,17 @@ import org.mozilla.gecko.media.AudioFocu
 import org.mozilla.gecko.media.AudioFocusAgent.State;
 import org.mozilla.gecko.media.MediaControlService;
 
 import android.content.Intent;
 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;
 
 import com.robotium.solo.Condition;
 
 abstract class MediaPlaybackTest extends BaseTest {
     private Context mContext;
     private int mPrevIcon = 0;
@@ -120,29 +121,40 @@ abstract class MediaPlaybackTest extends
         final Tab tab = Tabs.getInstance().getSelectedTab();
         mAsserter.ok(isTabPlaying == tab.isMediaPlaying(),
                      "Checking the media playing state of tab, isTabPlaying = " + isTabPlaying,
                      "Tab's media playing state is correct.");
 
         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);
 
         StatusBarNotification[] sbns = notificationManager.getActiveNotifications();
         mAsserter.is(sbns.length, 1,
                      "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.");
 
         mAsserter.is(notification.actions[0].title,
                      getContext().getString(isTabPlaying ? R.string.media_pause : R.string.media_play),
                      "Action has correct title.");
         mAsserter.is(notification.actions[0].icon,
                      isTabPlaying ? R.drawable.ic_media_pause : R.drawable.ic_media_play,
--- 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
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 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;
 
 public class testMediaControl extends MediaPlaybackTest {
     public void testMediaControl() {
         info("- ensure the test is running on correct Android version -");
         checkAndroidVersionForMediaControlTest();
@@ -107,18 +109,19 @@ public class testMediaControl extends Me
 
         info("- check whether audio starts playing -");
         checkIfMediaPlayingSuccess(true /* playing */);
 
         info("- switch to the another tab -");
         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();
     }
 
     private void testCloseTab() {
         info("- load URL -");
         final String MEDIA_URL = getAbsoluteUrl(mStringHelper.ROBOCOP_MEDIA_PLAYBACK_LOOP_URL);