Use this as the meta bug.
Seems like I am able to do it as pure junit tests. Robolectric seems more powerful than I thought. Using Mockito in instrumentation tests seems a bit overkill.
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/a98c2132ee5335e39d6d83f70ed37678237637e9 commit a98c2132ee5335e39d6d83f70ed37678237637e9 Author: zqzhang <zqzhang@chromium.org> Date: Thu Apr 13 11:44:49 2017 Adding JUnit tests for MediaNotificationManager This CL adds a number of JUnit tests for testing MediaNotificationManager in the following aspects: * Check if MediaNotificationManager handles the ListenerService correctly. * Check if ListenerService can correctly process Intents. * Check if the Notification presrented to Android NotificationManager is correct. Many MediaNotificationManager members are changed to package scope access to avoid too many "ForTesting" names. BUG= 705919 Review-Url: https://codereview.chromium.org/2816603002 Cr-Commit-Position: refs/heads/master@{#464375} [modify] https://crrev.com/a98c2132ee5335e39d6d83f70ed37678237637e9/chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java [modify] https://crrev.com/a98c2132ee5335e39d6d83f70ed37678237637e9/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java [modify] https://crrev.com/a98c2132ee5335e39d6d83f70ed37678237637e9/chrome/android/java_sources.gni [add] https://crrev.com/a98c2132ee5335e39d6d83f70ed37678237637e9/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationManagerNotificationTest.java [add] https://crrev.com/a98c2132ee5335e39d6d83f70ed37678237637e9/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationManagerServiceActionsTest.java [add] https://crrev.com/a98c2132ee5335e39d6d83f70ed37678237637e9/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationManagerServiceLifecycleTest.java [add] https://crrev.com/a98c2132ee5335e39d6d83f70ed37678237637e9/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationManagerTestBase.java [add] https://crrev.com/a98c2132ee5335e39d6d83f70ed37678237637e9/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationTestShadowNotificationManager.java [add] https://crrev.com/a98c2132ee5335e39d6d83f70ed37678237637e9/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationTestShadowResources.java
Some follow-up tasks we could do: * Fix several bugs which we found when writing the tests. * Move existing instrumentation tests into junit tests.
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a commit 61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a Author: zqzhang <zqzhang@chromium.org> Date: Mon Apr 24 05:30:21 2017 [Media>UI] Migrate media notification tests to JUnit tests BUG= 705919 Review-Url: https://codereview.chromium.org/2831223002 Cr-Commit-Position: refs/heads/master@{#466588} [modify] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java [modify] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaSessionTabHelper.java [modify] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/chrome/android/java_sources.gni [delete] https://crrev.com/eaa6185759c3d8f7230851633c724caa73f544e9/chrome/android/javatests/src/org/chromium/chrome/browser/media/ui/NotificationActionsUpdatedTest.java [delete] https://crrev.com/eaa6185759c3d8f7230851633c724caa73f544e9/chrome/android/javatests/src/org/chromium/chrome/browser/media/ui/NotificationTestUtils.java [delete] https://crrev.com/eaa6185759c3d8f7230851633c724caa73f544e9/chrome/android/javatests/src/org/chromium/chrome/browser/media/ui/NotificationTitleUpdatedTest.java [add] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationActionsUpdatedTest.java [modify] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationManagerServiceLifecycleTest.java [modify] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationManagerTestBase.java [modify] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationTestShadowResources.java [add] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationTestTabHolder.java [add] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationTitleUpdatedTest.java [modify] https://crrev.com/61d006d1ee4c7f53b6bf9cad73a59e761dc37e6a/content/public/android/java/src/org/chromium/content_public/browser/MediaSessionObserver.java
Comment 1 by zqzh...@chromium.org
, Mar 28 2017