Skip to content

Commit

Permalink
Reset runtime flags in media tests.
Browse files Browse the repository at this point in the history
Use Scoped* helpers to make sure the modified flags are reset for other
tests.

Change-Id: I7d03875cf2ab02029ca0807b1337ef3102625ed8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635680
Reviewed-by: Becca Hughes <beccahughes@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665246}
  • Loading branch information
lilles authored and Commit Bot committed May 31, 2019
1 parent 38e0ef7 commit 88c22f2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
#include "third_party/blink/renderer/platform/testing/empty_web_media_player.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"

using ::testing::AnyNumber;
Expand Down Expand Up @@ -315,7 +316,7 @@ TEST_P(HTMLMediaElementTest, AutoplayInitiated_DocumentActivation_Low_Gesture) {
// - Policy: DocumentUserActivation (aka. unified autoplay)
// - MEI: low;
// - Frame received user gesture.
RuntimeEnabledFeatures::SetMediaEngagementBypassAutoplayPoliciesEnabled(true);
ScopedMediaEngagementBypassAutoplayPoliciesForTest scoped_feature(true);
Media()->GetDocument().GetSettings()->SetAutoplayPolicy(
AutoplayPolicy::Type::kDocumentUserActivationRequired);
LocalFrame::NotifyUserActivation(Media()->GetDocument().GetFrame());
Expand All @@ -331,7 +332,7 @@ TEST_P(HTMLMediaElementTest,
// - Policy: DocumentUserActivation (aka. unified autoplay)
// - MEI: high;
// - Frame received user gesture.
RuntimeEnabledFeatures::SetMediaEngagementBypassAutoplayPoliciesEnabled(true);
ScopedMediaEngagementBypassAutoplayPoliciesForTest scoped_feature(true);
Media()->GetDocument().GetSettings()->SetAutoplayPolicy(
AutoplayPolicy::Type::kDocumentUserActivationRequired);
SimulateHighMediaEngagement();
Expand All @@ -348,7 +349,7 @@ TEST_P(HTMLMediaElementTest,
// - Policy: DocumentUserActivation (aka. unified autoplay)
// - MEI: high;
// - Frame did not receive user gesture.
RuntimeEnabledFeatures::SetMediaEngagementBypassAutoplayPoliciesEnabled(true);
ScopedMediaEngagementBypassAutoplayPoliciesForTest scoped_feature(true);
Media()->GetDocument().GetSettings()->SetAutoplayPolicy(
AutoplayPolicy::Type::kDocumentUserActivationRequired);
SimulateHighMediaEngagement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/testing/wait_for_event.h"
#include "third_party/blink/renderer/platform/testing/empty_web_media_player.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"

namespace blink {
Expand Down Expand Up @@ -52,11 +53,11 @@ class VideoAutoFullscreenFrameClient
WebWidget* web_widget_;
};

class VideoAutoFullscreen : public testing::Test {
class VideoAutoFullscreen : public testing::Test,
private ScopedVideoAutoFullscreenForTest {
public:
VideoAutoFullscreen() : ScopedVideoAutoFullscreenForTest(true) {}
void SetUp() override {
RuntimeEnabledFeatures::SetVideoAutoFullscreenEnabled(true);

web_view_helper_.Initialize(&web_frame_client_);
GetWebView()->GetSettings()->SetAutoplayPolicy(
WebSettings::AutoplayPolicy::kUserGestureRequired);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "third_party/blink/renderer/modules/media_controls/media_controls_impl.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/text/platform_locale.h"

Expand All @@ -36,12 +37,15 @@ class MockDisplayCutoutChromeClient : public EmptyChromeClient {
} // namespace

class MediaControlDisplayCutoutFullscreenButtonElementTest
: public PageTestBase {
: public PageTestBase,
private ScopedDisplayCutoutAPIForTest {
public:
static TouchEventInit* GetValidTouchEventInit() {
return TouchEventInit::Create();
}

MediaControlDisplayCutoutFullscreenButtonElementTest()
: ScopedDisplayCutoutAPIForTest(true) {}
void SetUp() override {
chrome_client_ = MakeGarbageCollected<MockDisplayCutoutChromeClient>();

Expand All @@ -50,9 +54,6 @@ class MediaControlDisplayCutoutFullscreenButtonElementTest
clients.chrome_client = chrome_client_.Get();
SetupPageWithClients(&clients,
MakeGarbageCollected<EmptyLocalFrameClient>());

RuntimeEnabledFeatures::SetDisplayCutoutAPIEnabled(true);

video_ = MakeGarbageCollected<HTMLVideoElement>(GetDocument());
GetDocument().body()->AppendChild(video_);
controls_ = MakeGarbageCollected<MediaControlsImpl>(*video_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/modules/media_controls/media_controls_impl.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"

namespace blink {
Expand All @@ -36,8 +37,14 @@ class DisplayCutoutMockChromeClient : public EmptyChromeClient {

} // namespace

class MediaControlsDisplayCutoutDelegateTest : public PageTestBase {
class MediaControlsDisplayCutoutDelegateTest
: public PageTestBase,
private ScopedDisplayCutoutAPIForTest,
private ScopedMediaControlsExpandGestureForTest {
public:
MediaControlsDisplayCutoutDelegateTest()
: ScopedDisplayCutoutAPIForTest(true),
ScopedMediaControlsExpandGestureForTest(true) {}
void SetUp() override {
chrome_client_ = MakeGarbageCollected<DisplayCutoutMockChromeClient>();

Expand All @@ -46,10 +53,6 @@ class MediaControlsDisplayCutoutDelegateTest : public PageTestBase {
clients.chrome_client = chrome_client_.Get();
SetupPageWithClients(&clients,
MakeGarbageCollected<EmptyLocalFrameClient>());

RuntimeEnabledFeatures::SetDisplayCutoutAPIEnabled(true);
RuntimeEnabledFeatures::SetMediaControlsExpandGestureEnabled(true);

GetDocument().write("<body><video id=video></body>");
}

Expand Down

0 comments on commit 88c22f2

Please sign in to comment.