Changeset 187004 in webkit


Ignore:
Timestamp:
Jul 18, 2015 6:30:44 PM (9 years ago)
Author:
mrajca@apple.com
Message:

Media Session: add infrastructure for testing interruptions
https://bugs.webkit.org/show_bug.cgi?id=147060

Reviewed by Eric Carlson.

  • Modules/mediasession/MediaSession.h: Export methods to be used with tests.
  • Modules/mediasession/MediaSessionManager.h: Ditto.
  • bindings/scripts/CodeGeneratorJS.pm: JSMediaSession needs to be marked with WEBCORE_EXPORT so it works with JSInternals.
  • testing/Internals.cpp:

(WebCore::Internals::sendMediaSessionStartOfInterruptionNotification): Let tests send interruptions to MediaSessionManager.
(WebCore::Internals::sendMediaSessionEndOfInterruptionNotification): Ditto.
(WebCore::Internals::mediaSessionCurrentState): Expose the current state of media sessions to tests.

  • testing/Internals.h:
  • testing/Internals.idl: Add interfaces for sending interruptions from JS tests.
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r187002 r187004  
     12015-07-17  Matt Rajca  <mrajca@apple.com>
     2
     3        Media Session: add infrastructure for testing interruptions
     4        https://bugs.webkit.org/show_bug.cgi?id=147060
     5
     6        Reviewed by Eric Carlson.
     7
     8        * Modules/mediasession/MediaSession.h: Export methods to be used with tests.
     9        * Modules/mediasession/MediaSessionManager.h: Ditto.
     10        * bindings/scripts/CodeGeneratorJS.pm: JSMediaSession needs to be marked with WEBCORE_EXPORT so it works with JSInternals.
     11        * testing/Internals.cpp:
     12        (WebCore::Internals::sendMediaSessionStartOfInterruptionNotification): Let tests send interruptions to MediaSessionManager.
     13        (WebCore::Internals::sendMediaSessionEndOfInterruptionNotification): Ditto.
     14        (WebCore::Internals::mediaSessionCurrentState): Expose the current state of media sessions to tests.
     15        * testing/Internals.h:
     16        * testing/Internals.idl: Add interfaces for sending interruptions from JS tests.
     17
    1182015-07-18  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
    219
  • trunk/Source/WebCore/Modules/mediasession/MediaSession.h

    r186918 r187004  
    6767    MediaRemoteControls* controls(bool& isNull);
    6868
    69     State currentState() const { return m_currentState; }
     69    WEBCORE_EXPORT State currentState() const { return m_currentState; }
    7070    bool hasActiveMediaElements() const;
    7171
  • trunk/Source/WebCore/Modules/mediasession/MediaSessionManager.h

    r186918 r187004  
    4040    friend class NeverDestroyed<MediaSessionManager>;
    4141public:
    42     static MediaSessionManager& singleton();
     42    WEBCORE_EXPORT static MediaSessionManager& singleton();
    4343
    4444    void togglePlayback();
     
    4646    void skipToPreviousTrack();
    4747
    48     void didReceiveStartOfInterruptionNotification(MediaSessionInterruptingCategory) override;
    49     void didReceiveEndOfInterruptionNotification(MediaSessionInterruptingCategory) override;
     48    WEBCORE_EXPORT void didReceiveStartOfInterruptionNotification(MediaSessionInterruptingCategory) override;
     49    WEBCORE_EXPORT void didReceiveEndOfInterruptionNotification(MediaSessionInterruptingCategory) override;
    5050
    5151private:
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r186858 r187004  
    247247    "JSHTMLElement" => 1,
    248248    "JSHTMLMediaElement" => 1,
     249    "JSMediaSession" => 1,
    249250    "JSNode" => 1,
    250251    "JSNotification" => 1,
  • trunk/Source/WebCore/testing/Internals.cpp

    r186976 r187004  
    191191#endif
    192192
     193#if ENABLE(MEDIA_SESSION)
     194#include "MediaSession.h"
     195#include "MediaSessionManager.h"
     196#endif
     197
    193198using JSC::CodeBlock;
    194199using JSC::FunctionExecutable;
     
    27592764#endif // ENABLE(VIDEO)
    27602765
     2766#if ENABLE(MEDIA_SESSION)
     2767static MediaSessionInterruptingCategory interruptingCategoryFromString(const String& interruptingCategoryString)
     2768{
     2769    if (interruptingCategoryString == "content")
     2770        return MediaSessionInterruptingCategory::Content;
     2771    if (interruptingCategoryString == "transient")
     2772        return MediaSessionInterruptingCategory::Transient;
     2773    if (interruptingCategoryString == "transient-solo")
     2774        return MediaSessionInterruptingCategory::TransientSolo;
     2775    ASSERT_NOT_REACHED();
     2776}
     2777
     2778void Internals::sendMediaSessionStartOfInterruptionNotification(const String& interruptingCategoryString)
     2779{
     2780    MediaSessionManager::singleton().didReceiveStartOfInterruptionNotification(interruptingCategoryFromString(interruptingCategoryString));
     2781}
     2782
     2783void Internals::sendMediaSessionEndOfInterruptionNotification(const String& interruptingCategoryString)
     2784{
     2785    MediaSessionManager::singleton().didReceiveEndOfInterruptionNotification(interruptingCategoryFromString(interruptingCategoryString));
     2786}
     2787
     2788String Internals::mediaSessionCurrentState(MediaSession* session) const
     2789{
     2790    switch (session->currentState()) {
     2791    case MediaSession::State::Active:
     2792        return "active";
     2793    case MediaSession::State::Interrupted:
     2794        return "interrupted";
     2795    case MediaSession::State::Idle:
     2796        return "idle";
     2797    }
     2798}
     2799#endif // ENABLE(MEDIA_SESSION)
     2800
    27612801#if ENABLE(WEB_AUDIO)
    27622802void Internals::setAudioContextRestrictions(AudioContext* context, const String &restrictionsString, ExceptionCode &ec)
  • trunk/Source/WebCore/testing/Internals.h

    r186976 r187004  
    5757class InternalSettings;
    5858class MallocStatistics;
     59class MediaSession;
    5960class MemoryInfo;
    6061class Node;
     
    393394#endif
    394395
     396#if ENABLE(MEDIA_SESSION)
     397    void sendMediaSessionStartOfInterruptionNotification(const String&);
     398    void sendMediaSessionEndOfInterruptionNotification(const String&);
     399    String mediaSessionCurrentState(MediaSession*) const;
     400#endif
     401
    395402#if ENABLE(WEB_AUDIO)
    396403    void setAudioContextRestrictions(AudioContext*, const String& restrictions, ExceptionCode&);
  • trunk/Source/WebCore/testing/Internals.idl

    r186976 r187004  
    4646};
    4747
     48enum MediaSessionInterruptingCategory {
     49    "content",
     50    "transient",
     51    "transient-solo"
     52};
     53
    4854[
    4955    NoInterfaceObject,
     
    352358    [Conditional=VIDEO] void beginMediaSessionInterruption();
    353359    [Conditional=VIDEO] void endMediaSessionInterruption(DOMString flags);
     360    [Conditional=MEDIA_SESSION] void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory category);
     361    [Conditional=MEDIA_SESSION] void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory category);
     362    [Conditional=MEDIA_SESSION] DOMString mediaSessionCurrentState(MediaSession session);
    354363    [Conditional=VIDEO] void applicationWillEnterForeground();
    355364    [Conditional=VIDEO] void applicationWillEnterBackground();
Note: See TracChangeset for help on using the changeset viewer.