Title: [187588] trunk/Source/WebCore
Revision
187588
Author
mra...@apple.com
Date
2015-07-30 10:02:13 -0700 (Thu, 30 Jul 2015)

Log Message

Media Session: add infrastructure for testing media control events
https://bugs.webkit.org/show_bug.cgi?id=147412

Reviewed by Eric Carlson.

* Modules/mediasession/MediaSessionManager.h:
* testing/Internals.cpp:
(WebCore::Internals::sendMediaControlEvent): Let tests simulate media control events.
* testing/Internals.h:
* testing/Internals.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (187587 => 187588)


--- trunk/Source/WebCore/ChangeLog	2015-07-30 16:25:36 UTC (rev 187587)
+++ trunk/Source/WebCore/ChangeLog	2015-07-30 17:02:13 UTC (rev 187588)
@@ -1,3 +1,16 @@
+2015-07-29  Matt Rajca  <mra...@apple.com>
+
+        Media Session: add infrastructure for testing media control events
+        https://bugs.webkit.org/show_bug.cgi?id=147412
+
+        Reviewed by Eric Carlson.
+
+        * Modules/mediasession/MediaSessionManager.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::sendMediaControlEvent): Let tests simulate media control events.
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2015-07-30  Chris Dumez  <cdu...@apple.com>
 
         Mark more classes as fast allocated

Modified: trunk/Source/WebCore/Modules/mediasession/MediaSessionManager.h (187587 => 187588)


--- trunk/Source/WebCore/Modules/mediasession/MediaSessionManager.h	2015-07-30 16:25:36 UTC (rev 187587)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSessionManager.h	2015-07-30 17:02:13 UTC (rev 187588)
@@ -41,9 +41,9 @@
 public:
     WEBCORE_EXPORT static MediaSessionManager& singleton();
 
-    void togglePlayback();
-    void skipToNextTrack();
-    void skipToPreviousTrack();
+    WEBCORE_EXPORT void togglePlayback();
+    WEBCORE_EXPORT void skipToNextTrack();
+    WEBCORE_EXPORT void skipToPreviousTrack();
 
     WEBCORE_EXPORT void didReceiveStartOfInterruptionNotification(MediaSessionInterruptingCategory) override;
     WEBCORE_EXPORT void didReceiveEndOfInterruptionNotification(MediaSessionInterruptingCategory) override;

Modified: trunk/Source/WebCore/testing/Internals.cpp (187587 => 187588)


--- trunk/Source/WebCore/testing/Internals.cpp	2015-07-30 16:25:36 UTC (rev 187587)
+++ trunk/Source/WebCore/testing/Internals.cpp	2015-07-30 17:02:13 UTC (rev 187588)
@@ -2821,6 +2821,18 @@
     ASSERT_ARG(element, element);
     return element->playerVolume();
 }
+
+void Internals::sendMediaControlEvent(const String& event)
+{
+    if (event == "play-pause")
+        MediaSessionManager::singleton().togglePlayback();
+    else if (event == "next-track")
+        MediaSessionManager::singleton().skipToNextTrack();
+    else if (event == "previous-track")
+        MediaSessionManager::singleton().skipToPreviousTrack();
+    else
+        ASSERT_NOT_REACHED();
+}
 #endif // ENABLE(MEDIA_SESSION)
 
 #if ENABLE(WEB_AUDIO)

Modified: trunk/Source/WebCore/testing/Internals.h (187587 => 187588)


--- trunk/Source/WebCore/testing/Internals.h	2015-07-30 16:25:36 UTC (rev 187587)
+++ trunk/Source/WebCore/testing/Internals.h	2015-07-30 17:02:13 UTC (rev 187588)
@@ -400,6 +400,7 @@
     void sendMediaSessionEndOfInterruptionNotification(const String&);
     String mediaSessionCurrentState(MediaSession*) const;
     double mediaElementPlayerVolume(HTMLMediaElement*) const;
+    void sendMediaControlEvent(const String&);
 #endif
 
 #if ENABLE(WEB_AUDIO)

Modified: trunk/Source/WebCore/testing/Internals.idl (187587 => 187588)


--- trunk/Source/WebCore/testing/Internals.idl	2015-07-30 16:25:36 UTC (rev 187587)
+++ trunk/Source/WebCore/testing/Internals.idl	2015-07-30 17:02:13 UTC (rev 187588)
@@ -51,6 +51,12 @@
     "transient-solo"
 };
 
+enum MediaControlEvent {
+    "play-pause",
+    "next-track",
+    "previous-track"
+};
+
 [
     NoInterfaceObject,
 ] interface Internals {
@@ -363,6 +369,7 @@
     [Conditional=MEDIA_SESSION] void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory category);
     [Conditional=MEDIA_SESSION] DOMString mediaSessionCurrentState(MediaSession session);
     [Conditional=MEDIA_SESSION] double mediaElementPlayerVolume(HTMLMediaElement element);
+    [Conditional=MEDIA_SESSION] void sendMediaControlEvent(MediaControlEvent event);
     [Conditional=VIDEO] void applicationWillEnterForeground();
     [Conditional=VIDEO] void applicationWillEnterBackground();
     [Conditional=VIDEO, RaisesException] void setMediaSessionRestrictions(DOMString mediaType, DOMString restrictions);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to