Commit 7997314c authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

Add "test mode" to media controls to make layout tests easier

This CL adds a test mode flag to modern media controls that hides the
loading panel. This will be used for other changes as well, such as
not showing the transition for the overlay play button. This is to be
used for layout testing to prevent mismatch issues arising from the
animations being at a different point.

Bug: 775534
Change-Id: Ie79560f1f012992d50222d31f5a953b30a925916
Reviewed-on: https://chromium-review.googlesource.com/997015
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548820}
parent 92a1603f
...@@ -51,6 +51,9 @@ class CORE_EXPORT MediaControls : public GarbageCollectedMixin { ...@@ -51,6 +51,9 @@ class CORE_EXPORT MediaControls : public GarbageCollectedMixin {
// TODO(mlamouri): required by LayoutVTTCue. // TODO(mlamouri): required by LayoutVTTCue.
virtual LayoutObject* ContainerLayoutObject() = 0; virtual LayoutObject* ContainerLayoutObject() = 0;
// Used for layout tests to disable some animations.
virtual void SetTestMode(bool) = 0;
// TODO: the following are required by other parts of the media controls // TODO: the following are required by other parts of the media controls
// implementation and could be removed when the full implementation has moved // implementation and could be removed when the full implementation has moved
// to modules. // to modules.
......
...@@ -2518,6 +2518,14 @@ bool Internals::isMediaElementSuspended(HTMLMediaElement* media_element) { ...@@ -2518,6 +2518,14 @@ bool Internals::isMediaElementSuspended(HTMLMediaElement* media_element) {
return false; return false;
} }
void Internals::setMediaControlsTestMode(HTMLMediaElement* media_element,
bool enable) {
DCHECK(media_element);
MediaControls* media_controls = media_element->GetMediaControls();
DCHECK(media_controls);
media_controls->SetTestMode(enable);
}
void Internals::registerURLSchemeAsBypassingContentSecurityPolicy( void Internals::registerURLSchemeAsBypassingContentSecurityPolicy(
const String& scheme) { const String& scheme) {
SchemeRegistry::RegisterURLSchemeAsBypassingContentSecurityPolicy(scheme); SchemeRegistry::RegisterURLSchemeAsBypassingContentSecurityPolicy(scheme);
......
...@@ -394,6 +394,7 @@ class Internals final : public ScriptWrappable { ...@@ -394,6 +394,7 @@ class Internals final : public ScriptWrappable {
void setPersistent(HTMLVideoElement*, bool); void setPersistent(HTMLVideoElement*, bool);
void forceStaleStateForMediaElement(HTMLMediaElement*, int target_state); void forceStaleStateForMediaElement(HTMLMediaElement*, int target_state);
bool isMediaElementSuspended(HTMLMediaElement*); bool isMediaElementSuspended(HTMLMediaElement*);
void setMediaControlsTestMode(HTMLMediaElement*, bool);
void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme); void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
void registerURLSchemeAsBypassingContentSecurityPolicy( void registerURLSchemeAsBypassingContentSecurityPolicy(
......
...@@ -240,6 +240,7 @@ enum EffectiveConnectionType { ...@@ -240,6 +240,7 @@ enum EffectiveConnectionType {
void setPersistent(HTMLVideoElement video, boolean persistent); void setPersistent(HTMLVideoElement video, boolean persistent);
void forceStaleStateForMediaElement(HTMLMediaElement mediaElement, long state); void forceStaleStateForMediaElement(HTMLMediaElement mediaElement, long state);
boolean isMediaElementSuspended(HTMLMediaElement mediaElement); boolean isMediaElementSuspended(HTMLMediaElement mediaElement);
void setMediaControlsTestMode(HTMLMediaElement mediaElement, boolean enable);
void registerURLSchemeAsBypassingContentSecurityPolicy(DOMString scheme); void registerURLSchemeAsBypassingContentSecurityPolicy(DOMString scheme);
void registerURLSchemeAsBypassingContentSecurityPolicy(DOMString scheme, sequence<DOMString> policyAreas); void registerURLSchemeAsBypassingContentSecurityPolicy(DOMString scheme, sequence<DOMString> policyAreas);
......
...@@ -808,6 +808,18 @@ LayoutObject* MediaControlsImpl::ContainerLayoutObject() { ...@@ -808,6 +808,18 @@ LayoutObject* MediaControlsImpl::ContainerLayoutObject() {
return GetLayoutObject(); return GetLayoutObject();
} }
void MediaControlsImpl::SetTestMode(bool enable) {
is_test_mode_ = enable;
if (loading_panel_)
loading_panel_->OnTestModeUpdated();
// TODO(steimel): Add other test mode changes, such as stopping the overlay
// play button transition.
}
bool MediaControlsImpl::GetTestMode() const {
return is_test_mode_;
}
void MediaControlsImpl::MaybeShow() { void MediaControlsImpl::MaybeShow() {
panel_->SetIsWanted(true); panel_->SetIsWanted(true);
panel_->SetIsDisplayed(true); panel_->SetIsDisplayed(true);
......
...@@ -100,6 +100,7 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement, ...@@ -100,6 +100,7 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement,
void NetworkStateChanged() override; void NetworkStateChanged() override;
LayoutObject* PanelLayoutObject() override; LayoutObject* PanelLayoutObject() override;
LayoutObject* ContainerLayoutObject() override; LayoutObject* ContainerLayoutObject() override;
void SetTestMode(bool) override;
// Return the internal elements, which is used by registering clicking // Return the internal elements, which is used by registering clicking
// EventHandlers from MediaControlsWindowEventListener. // EventHandlers from MediaControlsWindowEventListener.
HTMLDivElement* PanelElement() override; HTMLDivElement* PanelElement() override;
...@@ -110,6 +111,8 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement, ...@@ -110,6 +111,8 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement,
RefreshCastButtonVisibilityWithoutUpdate(); RefreshCastButtonVisibilityWithoutUpdate();
} }
bool GetTestMode() const;
// Called by the fullscreen buttons to toggle fulllscreen on/off. // Called by the fullscreen buttons to toggle fulllscreen on/off.
void EnterFullscreen(); void EnterFullscreen();
void ExitFullscreen(); void ExitFullscreen();
...@@ -363,6 +366,8 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement, ...@@ -363,6 +366,8 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement,
// certain pointer events. In particular, when the user is interacting via // certain pointer events. In particular, when the user is interacting via
// touch events, we want to ignore pointerover/pointerout/pointermove events. // touch events, we want to ignore pointerover/pointerout/pointermove events.
bool is_touch_interaction_ = false; bool is_touch_interaction_ = false;
bool is_test_mode_ = false;
}; };
DEFINE_ELEMENT_TYPE_CASTS(MediaControlsImpl, IsMediaControls()); DEFINE_ELEMENT_TYPE_CASTS(MediaControlsImpl, IsMediaControls());
......
...@@ -157,6 +157,14 @@ void MediaControlLoadingPanelElement::UpdateDisplayState() { ...@@ -157,6 +157,14 @@ void MediaControlLoadingPanelElement::UpdateDisplayState() {
return; return;
} }
// If the controls are in test mode, we always hide the loading panel. So hide
// if necessary and return.
if (GetMediaControls().GetTestMode()) {
if (state_ != State::kHidden)
HideAnimation();
return;
}
switch (state_) { switch (state_) {
case State::kHidden: case State::kHidden:
// If the media controls are loading metadata then we should show the // If the media controls are loading metadata then we should show the
...@@ -205,6 +213,10 @@ void MediaControlLoadingPanelElement::OnControlsShown() { ...@@ -205,6 +213,10 @@ void MediaControlLoadingPanelElement::OnControlsShown() {
UpdateDisplayState(); UpdateDisplayState();
} }
void MediaControlLoadingPanelElement::OnTestModeUpdated() {
UpdateDisplayState();
}
void MediaControlLoadingPanelElement::OnAnimationEnd() { void MediaControlLoadingPanelElement::OnAnimationEnd() {
// If we have gone back to the loading metadata state (e.g. the source // If we have gone back to the loading metadata state (e.g. the source
// changed). Then we should jump back to playing. // changed). Then we should jump back to playing.
......
...@@ -33,6 +33,8 @@ class MODULES_EXPORT MediaControlLoadingPanelElement final ...@@ -33,6 +33,8 @@ class MODULES_EXPORT MediaControlLoadingPanelElement final
void OnControlsHidden(); void OnControlsHidden();
// Inform the loading panel that the Media Controls have been shown. // Inform the loading panel that the Media Controls have been shown.
void OnControlsShown(); void OnControlsShown();
// Inform the loading panel that the Media Controls are entering test mode.
void OnTestModeUpdated();
void Trace(Visitor*); void Trace(Visitor*);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment