Skip to content
Permalink
Browse files
[Mac] Add a mock AppleTV device for testing
https://bugs.webkit.org/show_bug.cgi?id=148912
<rdar://problem/22596272>

Reviewed by Tim Horton.

Source/WebCore:

No new tests, updated media/controls/airplay-picker.html.

* Modules/mediasession/WebMediaSessionManager.cpp:
(WebCore::WebMediaSessionManager::setMockMediaPlaybackTargetPickerEnabled): New, enable or disable
  the mock picker.
(WebCore::WebMediaSessionManager::setMockMediaPlaybackTargetPickerState): New, set mock picker state.
(WebCore::WebMediaSessionManager::mockPicker): New.
(WebCore::WebMediaSessionManager::targetPicker): Return the platform or mock picker, as per settings.
(WebCore::webMediaSessionManagerOverride): Deleted.
(WebCore::WebMediaSessionManager::shared): Deleted.
(WebCore::WebMediaSessionManager::setWebMediaSessionManagerOverride): Deleted.
* Modules/mediasession/WebMediaSessionManager.h:

* WebCore.xcodeproj/project.pbxproj: Add MediaPlaybackTargetPickerMock.* and MediaPlaybackTargetMock.*.

* page/ChromeClient.h: add setMockMediaPlaybackTargetPickerEnabled and setMockMediaPlaybackTargetPickerState.

* page/Page.cpp:
(WebCore::Page::playbackTargetPickerClientStateDidChange):
(WebCore::Page::setMockMediaPlaybackTargetPickerEnabled): New.
(WebCore::Page::setMockMediaPlaybackTargetPickerState): New.
(WebCore::Page::setPlaybackTarget):
* page/Page.h:

* platform/graphics/MediaPlaybackTarget.h:
(WebCore::noMediaPlaybackTargetContext):
(WebCore::MediaPlaybackTarget::~MediaPlaybackTarget):
(WebCore::MediaPlaybackTarget::deviceName):
(WebCore::MediaPlaybackTarget::MediaPlaybackTarget):

* platform/graphics/MediaPlaybackTargetContext.h: Make a class instead of a struct.
(WebCore::MediaPlaybackTargetContext::MediaPlaybackTargetContext):
(WebCore::MediaPlaybackTargetContext::type):
(WebCore::MediaPlaybackTargetContext::mockDeviceName):
(WebCore::MediaPlaybackTargetContext::mockState):
(WebCore::MediaPlaybackTargetContext::avOutputContext):
(WebCore::MediaPlaybackTargetContext::encodingRequiresPlatformData):

* platform/graphics/MediaPlaybackTargetPicker.cpp: Move much of the code from MediaPlaybackTargetMac.mm
  here so it can be the base class.
(WebCore::MediaPlaybackTargetPicker::MediaPlaybackTargetPicker):
(WebCore::MediaPlaybackTargetPicker::~MediaPlaybackTargetPicker):
(WebCore::MediaPlaybackTargetPicker::pendingActionTimerFired):
(WebCore::MediaPlaybackTargetPicker::addPendingAction):
(WebCore::MediaPlaybackTargetPicker::showPlaybackTargetPicker):
* platform/graphics/MediaPlaybackTargetPicker.h:
(WebCore::MediaPlaybackTargetPicker::availableDevicesDidChange):
(WebCore::MediaPlaybackTargetPicker::currentDeviceDidChange):
(WebCore::MediaPlaybackTargetPicker::client):
(WebCore::MediaPlaybackTargetPicker::setClient):

* platform/graphics/avfoundation/MediaPlaybackTargetMac.h:
(WebCore::MediaPlaybackTargetMac::outputContext):
(WebCore::MediaPlaybackTargetMac::targetType): Deleted.
* platform/graphics/avfoundation/MediaPlaybackTargetMac.mm:
(WebCore::MediaPlaybackTargetMac::targetContext):
(WebCore::MediaPlaybackTargetMac::hasActiveRoute):
(WebCore::MediaPlaybackTargetMac::deviceName):

* platform/graphics/avfoundation/WebMediaSessionManagerMac.cpp:
(WebCore::WebMediaSessionManager::shared): Renamed from platformManager.
(WebCore::WebMediaSessionManagerMac::platformPicker): Renamed from targetPicker.
(WebCore::WebMediaSessionManager::platformManager): Deleted.
(WebCore::WebMediaSessionManagerMac::targetPicker): Deleted.
* platform/graphics/avfoundation/WebMediaSessionManagerMac.h:

* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h:
* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
(WebCore::MediaPlaybackTargetPickerMac::MediaPlaybackTargetPickerMac):
(WebCore::MediaPlaybackTargetPickerMac::~MediaPlaybackTargetPickerMac):
(WebCore::MediaPlaybackTargetPickerMac::externalOutputDeviceAvailable):
(WebCore::MediaPlaybackTargetPickerMac::playbackTarget):
(WebCore::MediaPlaybackTargetPickerMac::devicePicker):
(WebCore::MediaPlaybackTargetPickerMac::showPlaybackTargetPicker):
(WebCore::MediaPlaybackTargetPickerMac::startingMonitoringPlaybackTargets):
(WebCore::MediaPlaybackTargetPickerMac::pendingActionTimerFired): Deleted.
(WebCore::MediaPlaybackTargetPickerMac::availableDevicesDidChange): Deleted.
(WebCore::MediaPlaybackTargetPickerMac::addPendingAction): Deleted.
(WebCore::MediaPlaybackTargetPickerMac::currentDeviceDidChange): Deleted.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::isCurrentPlaybackTargetWireless): Add support for
  mock target.
(WebCore::MediaPlayerPrivateAVFoundationObjC::wirelessPlaybackTargetName): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget): Ditto.

* platform/mock/MediaPlaybackTargetMock.cpp: Added.
(WebCore::MediaPlaybackTargetMock::create):
(WebCore::MediaPlaybackTargetMock::MediaPlaybackTargetMock):
(WebCore::MediaPlaybackTargetMock::~MediaPlaybackTargetMock):
(WebCore::MediaPlaybackTargetMock::targetContext):
(WebCore::toMediaPlaybackTargetMock):
* platform/mock/MediaPlaybackTargetMock.h: Added.

* platform/mock/MediaPlaybackTargetPickerMock.cpp: Added.
(WebCore::MediaPlaybackTargetPickerMock::create):
(WebCore::MediaPlaybackTargetPickerMock::MediaPlaybackTargetPickerMock):
(WebCore::MediaPlaybackTargetPickerMock::~MediaPlaybackTargetPickerMock):
(WebCore::MediaPlaybackTargetPickerMock::externalOutputDeviceAvailable):
(WebCore::MediaPlaybackTargetPickerMock::playbackTarget):
(WebCore::MediaPlaybackTargetPickerMock::timerFired):
(WebCore::MediaPlaybackTargetPickerMock::showPlaybackTargetPicker):
(WebCore::MediaPlaybackTargetPickerMock::startingMonitoringPlaybackTargets):
(WebCore::MediaPlaybackTargetPickerMock::stopMonitoringPlaybackTargets):
(WebCore::MediaPlaybackTargetPickerMock::invalidatePlaybackTargets):
(WebCore::MediaPlaybackTargetPickerMock::setState):
* platform/mock/MediaPlaybackTargetPickerMock.h: Added.

* testing/Internals.cpp:
(WebCore::Internals::Internals):
(WebCore::Internals::setMockMediaPlaybackTargetPickerEnabled):
(WebCore::Internals::setMockMediaPlaybackTargetPickerState):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit/mac:

* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::setMockMediaPlaybackTargetPickerEnabled): New.
(WebChromeClient::setMockMediaPlaybackTargetPickerState): Ditto.

* WebView/WebMediaPlaybackTargetPicker.h:
* WebView/WebMediaPlaybackTargetPicker.mm:
(WebMediaPlaybackTargetPicker::setMockMediaPlaybackTargetPickerEnabled): New.
(WebMediaPlaybackTargetPicker::setMockMediaPlaybackTargetPickerState): Ditto.

* WebView/WebView.mm:
(-[WebView _setMockMediaPlaybackTargetPickerEnabled:]): New.
(-[WebView _setMockMediaPlaybackTargetPickerName:state:]): Ditto.
* WebView/WebViewInternal.h:

Source/WebKit2:

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<MediaPlaybackTargetContext>::encode): Update for MediaPlaybackTargetContext changes.
(IPC::ArgumentCoder<MediaPlaybackTargetContext>::decode): Ditto.
* Shared/WebCoreArgumentCoders.h:

* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::ArgumentCoder<MediaPlaybackTargetContext>::encodePlatformData): Ditto.
(IPC::ArgumentCoder<MediaPlaybackTargetContext>::decodePlatformData): Ditto.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setMockMediaPlaybackTargetPickerEnabled): New.
(WebKit::WebPageProxy::setMockMediaPlaybackTargetPickerState): Ditto.
* UIProcess/WebPageProxy.h:

* UIProcess/WebPageProxy.messages.in: Add SetMockMediaPlaybackTargetPickerEnabled and
  SetMockMediaPlaybackTargetPickerState.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::setMockMediaPlaybackTargetPickerEnabled): New.
(WebKit::WebChromeClient::setMockMediaPlaybackTargetPickerState): Ditto.
* WebProcess/WebCoreSupport/WebChromeClient.h:

* WebProcess/WebPage/WebPage.h: MediaPlaybackTargetContext is a class, not a struct.

* WebProcess/WebPage/WebPage.messages.in: Ditto.

* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::playbackTargetSelected): Support mock target.

LayoutTests:

* media/controls/airplay-picker-expected.txt: Updated.
* media/controls/airplay-picker.html: Test button state when there is a device available.

* media/controls/controls-test-helpers.js:
(ControlsTest.prototype.stateForControlsElement): Add an optional parameter to force the flushed
  state to be flushed.
(ControlsTest.prototype.contains): New.
(ControlsTest.prototype.doesNotContain): Ditto.

* platform/mac/TestExpectations: Skipped new tests on older versions of OS X.


Canonical link: https://commits.webkit.org/169277@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192200 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eric-carlson committed Nov 10, 2015
1 parent 4f9f629 commit 2b72cb62bcc817c561430404631d3382b36f961f
Showing 50 changed files with 1,030 additions and 147 deletions.
@@ -1,3 +1,22 @@
2015-11-09 Eric Carlson <eric.carlson@apple.com>

[Mac] Add a mock AppleTV device for testing
https://bugs.webkit.org/show_bug.cgi?id=148912
<rdar://problem/22596272>

Reviewed by Tim Horton.

* media/controls/airplay-picker-expected.txt: Updated.
* media/controls/airplay-picker.html: Test button state when there is a device available.

* media/controls/controls-test-helpers.js:
(ControlsTest.prototype.stateForControlsElement): Add an optional parameter to force the flushed
state to be flushed.
(ControlsTest.prototype.contains): New.
(ControlsTest.prototype.doesNotContain): Ditto.

* platform/mac/TestExpectations: Skipped new tests on older versions of OS X.

2015-11-09 Wenson Hsieh <wenson_hsieh@apple.com>

Sometimes unable to scroll fixed div when the body is scrollable
@@ -1,17 +1,23 @@
This tests for the wireless device picker icon.
This tests the wireless device picker icon.

This test only runs in DRT!


EVENT: canplaythrough
PASS: We are using the apple idiom

Get the wireless device picker button
Test the AppleTV picker button

PASS: Name is 'AppleTV Device Picker'
PASS: Has hidden class
PASS: CSS display: none
PASS: Aria label is 'Choose Wireless Display'

Simulate an available AppleTV

PASS: Name is 'AppleTV Device Picker'
PASS: Does not have hidden class
PASS: CSS display: block

Testing finished.

@@ -4,18 +4,19 @@
<script src="../media-file.js"></script>
<script src="controls-test-helpers.js"></script>
<script>
internals.setMockMediaPlaybackTargetPickerEnabled(false);
var tester = new ControlsTest()
.whenReady(runTests)
.whenReady(runTestsWithoutDevice)
.start();

function runTests()
function runTestsWithoutDevice()
{
var currentState = tester.currentState;
tester.test("We are using the apple idiom")
.value(currentState.idiom)
.isEqualTo("apple");

tester.startNewSection("Get the wireless device picker button");
tester.startNewSection("Test the AppleTV picker button");
var statusState = tester.stateForControlsElement("AppleTV Device Picker");

tester.test("Name is 'AppleTV Device Picker'")
@@ -34,13 +35,35 @@
.value(statusState.ariaLabel)
.isEqualTo("Choose Wireless Display");

internals.setMockMediaPlaybackTargetPickerEnabled(true);
internals.setMockMediaPlaybackTargetPickerState("Sleepy TV", "DeviceAvailable");
window.setTimeout(runTestsWithDevice, 100);
}

function runTestsWithDevice()
{
tester.startNewSection("Simulate an available AppleTV");
var statusState = tester.stateForControlsElement("AppleTV Device Picker", true);

tester.test("Name is 'AppleTV Device Picker'")
.value(statusState.name)
.isEqualTo("AppleTV Device Picker");

tester.test("Does not have hidden class")
.value(statusState.className)
.doesNotContain("hidden");

tester.test("CSS display: block")
.value(statusState.computedStyle.display)
.isEqualTo("block");

tester.end();
}

</script>
</head>
<body>
<p>This tests for the wireless device picker icon.</p>
<p>This tests the wireless device picker icon.</p>
<p>This test only runs in DRT!</p>
<video controls></video>
</body>
@@ -35,8 +35,11 @@ ControlsTest = class ControlsTest {
return { idiom: "apple", status: "fail" };
}

stateForControlsElement(elementName)
stateForControlsElement(elementName, flushCachedState)
{
if (flushCachedState)
this.cachedCurrentState = null;

var state = this.cachedCurrentState || this.currentState;
if (state.elements && state.elements.length) {
for (var i = 0; i < state.elements.length; i++) {
@@ -146,6 +149,22 @@ ControlsTest = class ControlsTest {
this.logFailure(`${this.currentMessage} Expected: "${value}". Actual: "${this.currentValue}"`);
}

contains(value)
{
if (this.currentValue.indexOf(value) >= 0)
this.logSuccess(this.currentMessage);
else
this.logFailure(`${this.currentMessage} Expected to contain "${value}". Actual: "${this.currentValue}"`);
}

doesNotContain(value)
{
if (this.currentValue.indexOf(value) < 0)
this.logSuccess(this.currentMessage);
else
this.logFailure(`${this.currentMessage} Expected to not contain "${value}". Actual: "${this.currentValue}"`);
}

isEmptyString()
{
if (!this.currentValue && typeof this.currentValue == "string")
@@ -1362,6 +1362,9 @@ webkit.org/b/150823 imported/w3c/web-platform-tests/XMLHttpRequest/getresponsehe
# WOFF2 is only supported on certain Operating Systems.
webkit.org/b/150830 [ Mavericks Yosemite ElCapitan ] fast/text/woff2.html [ ImageOnlyFailure ]

# AppleTV not supported on Mavericks or Yosemite
[ Mavericks Yosemite ] media/controls/airplay-picker.html

webkit.org/b/150956 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_loadeddata.html [ Pass Timeout ]

webkit.org/b/144938 crypto/subtle/rsa-export-generated-keys.html [ Slow ]
@@ -1,3 +1,128 @@
2015-11-09 Eric Carlson <eric.carlson@apple.com>

[Mac] Add a mock AppleTV device for testing
https://bugs.webkit.org/show_bug.cgi?id=148912
<rdar://problem/22596272>

Reviewed by Tim Horton.

No new tests, updated media/controls/airplay-picker.html.

* Modules/mediasession/WebMediaSessionManager.cpp:
(WebCore::WebMediaSessionManager::setMockMediaPlaybackTargetPickerEnabled): New, enable or disable
the mock picker.
(WebCore::WebMediaSessionManager::setMockMediaPlaybackTargetPickerState): New, set mock picker state.
(WebCore::WebMediaSessionManager::mockPicker): New.
(WebCore::WebMediaSessionManager::targetPicker): Return the platform or mock picker, as per settings.
(WebCore::webMediaSessionManagerOverride): Deleted.
(WebCore::WebMediaSessionManager::shared): Deleted.
(WebCore::WebMediaSessionManager::setWebMediaSessionManagerOverride): Deleted.
* Modules/mediasession/WebMediaSessionManager.h:

* WebCore.xcodeproj/project.pbxproj: Add MediaPlaybackTargetPickerMock.* and MediaPlaybackTargetMock.*.

* page/ChromeClient.h: add setMockMediaPlaybackTargetPickerEnabled and setMockMediaPlaybackTargetPickerState.

* page/Page.cpp:
(WebCore::Page::playbackTargetPickerClientStateDidChange):
(WebCore::Page::setMockMediaPlaybackTargetPickerEnabled): New.
(WebCore::Page::setMockMediaPlaybackTargetPickerState): New.
(WebCore::Page::setPlaybackTarget):
* page/Page.h:

* platform/graphics/MediaPlaybackTarget.h:
(WebCore::noMediaPlaybackTargetContext):
(WebCore::MediaPlaybackTarget::~MediaPlaybackTarget):
(WebCore::MediaPlaybackTarget::deviceName):
(WebCore::MediaPlaybackTarget::MediaPlaybackTarget):

* platform/graphics/MediaPlaybackTargetContext.h: Make a class instead of a struct.
(WebCore::MediaPlaybackTargetContext::MediaPlaybackTargetContext):
(WebCore::MediaPlaybackTargetContext::type):
(WebCore::MediaPlaybackTargetContext::mockDeviceName):
(WebCore::MediaPlaybackTargetContext::mockState):
(WebCore::MediaPlaybackTargetContext::avOutputContext):
(WebCore::MediaPlaybackTargetContext::encodingRequiresPlatformData):

* platform/graphics/MediaPlaybackTargetPicker.cpp: Move much of the code from MediaPlaybackTargetMac.mm
here so it can be the base class.
(WebCore::MediaPlaybackTargetPicker::MediaPlaybackTargetPicker):
(WebCore::MediaPlaybackTargetPicker::~MediaPlaybackTargetPicker):
(WebCore::MediaPlaybackTargetPicker::pendingActionTimerFired):
(WebCore::MediaPlaybackTargetPicker::addPendingAction):
(WebCore::MediaPlaybackTargetPicker::showPlaybackTargetPicker):
* platform/graphics/MediaPlaybackTargetPicker.h:
(WebCore::MediaPlaybackTargetPicker::availableDevicesDidChange):
(WebCore::MediaPlaybackTargetPicker::currentDeviceDidChange):
(WebCore::MediaPlaybackTargetPicker::client):
(WebCore::MediaPlaybackTargetPicker::setClient):

* platform/graphics/avfoundation/MediaPlaybackTargetMac.h:
(WebCore::MediaPlaybackTargetMac::outputContext):
(WebCore::MediaPlaybackTargetMac::targetType): Deleted.
* platform/graphics/avfoundation/MediaPlaybackTargetMac.mm:
(WebCore::MediaPlaybackTargetMac::targetContext):
(WebCore::MediaPlaybackTargetMac::hasActiveRoute):
(WebCore::MediaPlaybackTargetMac::deviceName):

* platform/graphics/avfoundation/WebMediaSessionManagerMac.cpp:
(WebCore::WebMediaSessionManager::shared): Renamed from platformManager.
(WebCore::WebMediaSessionManagerMac::platformPicker): Renamed from targetPicker.
(WebCore::WebMediaSessionManager::platformManager): Deleted.
(WebCore::WebMediaSessionManagerMac::targetPicker): Deleted.
* platform/graphics/avfoundation/WebMediaSessionManagerMac.h:

* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h:
* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
(WebCore::MediaPlaybackTargetPickerMac::MediaPlaybackTargetPickerMac):
(WebCore::MediaPlaybackTargetPickerMac::~MediaPlaybackTargetPickerMac):
(WebCore::MediaPlaybackTargetPickerMac::externalOutputDeviceAvailable):
(WebCore::MediaPlaybackTargetPickerMac::playbackTarget):
(WebCore::MediaPlaybackTargetPickerMac::devicePicker):
(WebCore::MediaPlaybackTargetPickerMac::showPlaybackTargetPicker):
(WebCore::MediaPlaybackTargetPickerMac::startingMonitoringPlaybackTargets):
(WebCore::MediaPlaybackTargetPickerMac::pendingActionTimerFired): Deleted.
(WebCore::MediaPlaybackTargetPickerMac::availableDevicesDidChange): Deleted.
(WebCore::MediaPlaybackTargetPickerMac::addPendingAction): Deleted.
(WebCore::MediaPlaybackTargetPickerMac::currentDeviceDidChange): Deleted.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::isCurrentPlaybackTargetWireless): Add support for
mock target.
(WebCore::MediaPlayerPrivateAVFoundationObjC::wirelessPlaybackTargetName): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget): Ditto.

* platform/mock/MediaPlaybackTargetMock.cpp: Added.
(WebCore::MediaPlaybackTargetMock::create):
(WebCore::MediaPlaybackTargetMock::MediaPlaybackTargetMock):
(WebCore::MediaPlaybackTargetMock::~MediaPlaybackTargetMock):
(WebCore::MediaPlaybackTargetMock::targetContext):
(WebCore::toMediaPlaybackTargetMock):
* platform/mock/MediaPlaybackTargetMock.h: Added.

* platform/mock/MediaPlaybackTargetPickerMock.cpp: Added.
(WebCore::MediaPlaybackTargetPickerMock::create):
(WebCore::MediaPlaybackTargetPickerMock::MediaPlaybackTargetPickerMock):
(WebCore::MediaPlaybackTargetPickerMock::~MediaPlaybackTargetPickerMock):
(WebCore::MediaPlaybackTargetPickerMock::externalOutputDeviceAvailable):
(WebCore::MediaPlaybackTargetPickerMock::playbackTarget):
(WebCore::MediaPlaybackTargetPickerMock::timerFired):
(WebCore::MediaPlaybackTargetPickerMock::showPlaybackTargetPicker):
(WebCore::MediaPlaybackTargetPickerMock::startingMonitoringPlaybackTargets):
(WebCore::MediaPlaybackTargetPickerMock::stopMonitoringPlaybackTargets):
(WebCore::MediaPlaybackTargetPickerMock::invalidatePlaybackTargets):
(WebCore::MediaPlaybackTargetPickerMock::setState):
* platform/mock/MediaPlaybackTargetPickerMock.h: Added.

* testing/Internals.cpp:
(WebCore::Internals::Internals):
(WebCore::Internals::setMockMediaPlaybackTargetPickerEnabled):
(WebCore::Internals::setMockMediaPlaybackTargetPickerState):
* testing/Internals.h:
* testing/Internals.idl:

2015-11-09 Wenson Hsieh <wenson_hsieh@apple.com>

Unreviewed, fix the windows build
@@ -30,7 +30,7 @@

#include "FloatRect.h"
#include "Logging.h"
#include "MediaPlaybackTargetPickerMac.h"
#include "MediaPlaybackTargetPickerMock.h"
#include "WebMediaSessionManagerClient.h"
#include <wtf/text/StringBuilder.h>

@@ -89,23 +89,37 @@ static String mediaProducerStateString(MediaProducer::MediaStateFlags flags)
}
#endif

static WebMediaSessionManager*& webMediaSessionManagerOverride()
void WebMediaSessionManager::setMockMediaPlaybackTargetPickerEnabled(bool enabled)
{
static WebMediaSessionManager* override;
return override;
LOG(Media, "WebMediaSessionManager::setMockMediaPlaybackTargetPickerEnabled - enabled = %i", (int)enabled);

if (m_mockPickerEnabled == enabled)
return;

m_mockPickerEnabled = enabled;
}

void WebMediaSessionManager::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
{
LOG(Media, "WebMediaSessionManager::setMockMediaPlaybackTargetPickerState - name = %s, state = %i", name.utf8().data(), (int)state);

mockPicker().setState(name, state);
}

WebMediaSessionManager& WebMediaSessionManager::shared()
MediaPlaybackTargetPickerMock& WebMediaSessionManager::mockPicker()
{
if (WebMediaSessionManager* override = webMediaSessionManagerOverride())
return *override;
if (!m_pickerOverride)
m_pickerOverride = MediaPlaybackTargetPickerMock::create(*this);

return WebMediaSessionManager::platformManager();
return *m_pickerOverride.get();
}

void WebMediaSessionManager::setWebMediaSessionManagerOverride(WebMediaSessionManager* manager)
WebCore::MediaPlaybackTargetPicker& WebMediaSessionManager::targetPicker()
{
webMediaSessionManagerOverride() = manager;
if (m_mockPickerEnabled)
return mockPicker();

return platformPicker();
}

WebMediaSessionManager::WebMediaSessionManager()
@@ -28,7 +28,9 @@

#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)

#include "MediaPlaybackTargetContext.h"
#include "MediaPlaybackTargetPicker.h"
#include "MediaPlaybackTargetPickerMock.h"
#include "MediaProducer.h"
#include "Timer.h"
#include <wtf/Ref.h>
@@ -46,7 +48,9 @@ class WebMediaSessionManager : public MediaPlaybackTargetPicker::Client {
public:

WEBCORE_EXPORT static WebMediaSessionManager& shared();
WEBCORE_EXPORT static void setWebMediaSessionManagerOverride(WebMediaSessionManager*);

WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerEnabled(bool);
WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::State);

WEBCORE_EXPORT uint64_t addPlaybackTargetPickerClient(WebMediaSessionManagerClient&, uint64_t);
WEBCORE_EXPORT void removePlaybackTargetPickerClient(WebMediaSessionManagerClient&, uint64_t);
@@ -58,11 +62,14 @@ class WebMediaSessionManager : public MediaPlaybackTargetPicker::Client {
WebMediaSessionManager();
virtual ~WebMediaSessionManager();

virtual WebCore::MediaPlaybackTargetPicker& targetPicker() = 0;
virtual WebCore::MediaPlaybackTargetPicker& platformPicker() = 0;
static WebMediaSessionManager& platformManager();

private:

WebCore::MediaPlaybackTargetPicker& targetPicker();
WebCore::MediaPlaybackTargetPickerMock& mockPicker();

// MediaPlaybackTargetPicker::Client
virtual void setPlaybackTarget(Ref<WebCore::MediaPlaybackTarget>&&) override;
virtual void externalOutputDeviceAvailableDidChange(bool) override;
@@ -94,10 +101,12 @@ class WebMediaSessionManager : public MediaPlaybackTargetPicker::Client {

Vector<std::unique_ptr<ClientState>> m_clientState;
RefPtr<MediaPlaybackTarget> m_playbackTarget;
std::unique_ptr<WebCore::MediaPlaybackTargetPickerMock> m_pickerOverride;
ConfigurationTasks m_taskFlags { NoTask };
double m_currentWatchdogInterval { 0 };
bool m_externalOutputDeviceAvailable { false };
bool m_targetChanged { false };
bool m_mockPickerEnabled { false };
};

} // namespace WebCore

0 comments on commit 2b72cb6

Please sign in to comment.