Commit 5361fa5f authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Reset runtime flags in color scheme tests.

Change-Id: I48a02036dc1a4898d80eb1d6903c989e0d8f5224
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635679Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665510}
parent ace5017f
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "third_party/blink/renderer/core/html/html_head_element.h" #include "third_party/blink/renderer/core/html/html_head_element.h"
#include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" #include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
namespace blink { namespace blink {
namespace { namespace {
...@@ -60,8 +61,8 @@ TEST_F(ApplyDarkModeCheckTest, BackgroundColorNotDefinedAlwaysFiltered) { ...@@ -60,8 +61,8 @@ TEST_F(ApplyDarkModeCheckTest, BackgroundColorNotDefinedAlwaysFiltered) {
} }
TEST_F(ApplyDarkModeCheckTest, MetaColorSchemeDark) { TEST_F(ApplyDarkModeCheckTest, MetaColorSchemeDark) {
RuntimeEnabledFeatures::SetCSSColorSchemeEnabled(true); ScopedCSSColorSchemeForTest css_feature_scope(true);
RuntimeEnabledFeatures::SetMetaColorSchemeEnabled(true); ScopedMetaColorSchemeForTest meta_feature_scope(true);
GetDocument().GetSettings()->SetForceDarkModeEnabled(true); GetDocument().GetSettings()->SetForceDarkModeEnabled(true);
GetDocument().GetSettings()->SetPreferredColorScheme( GetDocument().GetSettings()->SetPreferredColorScheme(
PreferredColorScheme::kDark); PreferredColorScheme::kDark);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h" #include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/geometry/float_size.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
namespace blink { namespace blink {
...@@ -43,7 +44,6 @@ using namespace css_test_helpers; ...@@ -43,7 +44,6 @@ using namespace css_test_helpers;
class StyleEngineTest : public testing::Test { class StyleEngineTest : public testing::Test {
protected: protected:
void SetUp() override; void SetUp() override;
void TearDown() override;
Document& GetDocument() { return dummy_page_holder_->GetDocument(); } Document& GetDocument() { return dummy_page_holder_->GetDocument(); }
StyleEngine& GetStyleEngine() { return GetDocument().GetStyleEngine(); } StyleEngine& GetStyleEngine() { return GetDocument().GetStyleEngine(); }
...@@ -67,17 +67,12 @@ class StyleEngineTest : public testing::Test { ...@@ -67,17 +67,12 @@ class StyleEngineTest : public testing::Test {
private: private:
std::unique_ptr<DummyPageHolder> dummy_page_holder_; std::unique_ptr<DummyPageHolder> dummy_page_holder_;
RuntimeEnabledFeatures::Backup features_backup_;
}; };
void StyleEngineTest::SetUp() { void StyleEngineTest::SetUp() {
dummy_page_holder_ = std::make_unique<DummyPageHolder>(IntSize(800, 600)); dummy_page_holder_ = std::make_unique<DummyPageHolder>(IntSize(800, 600));
} }
void StyleEngineTest::TearDown() {
features_backup_.Restore();
}
StyleEngineTest::RuleSetInvalidation StyleEngineTest::RuleSetInvalidation
StyleEngineTest::ScheduleInvalidationsForRules(TreeScope& tree_scope, StyleEngineTest::ScheduleInvalidationsForRules(TreeScope& tree_scope,
const String& css_text) { const String& css_text) {
...@@ -1490,7 +1485,7 @@ TEST_F(StyleEngineTest, MediaQueriesChangeDefaultFontSize) { ...@@ -1490,7 +1485,7 @@ TEST_F(StyleEngineTest, MediaQueriesChangeDefaultFontSize) {
} }
TEST_F(StyleEngineTest, MediaQueriesChangeColorScheme) { TEST_F(StyleEngineTest, MediaQueriesChangeColorScheme) {
RuntimeEnabledFeatures::SetMediaQueryPrefersColorSchemeEnabled(true); ScopedMediaQueryPrefersColorSchemeForTest feature_scope(true);
GetDocument().body()->SetInnerHTMLFromString(R"HTML( GetDocument().body()->SetInnerHTMLFromString(R"HTML(
<style> <style>
...@@ -1516,7 +1511,7 @@ TEST_F(StyleEngineTest, MediaQueriesChangeColorScheme) { ...@@ -1516,7 +1511,7 @@ TEST_F(StyleEngineTest, MediaQueriesChangeColorScheme) {
} }
TEST_F(StyleEngineTest, MediaQueriesChangeColorSchemeForcedDarkMode) { TEST_F(StyleEngineTest, MediaQueriesChangeColorSchemeForcedDarkMode) {
RuntimeEnabledFeatures::SetMediaQueryPrefersColorSchemeEnabled(true); ScopedMediaQueryPrefersColorSchemeForTest feature_scope(true);
GetDocument().GetSettings()->SetForceDarkModeEnabled(true); GetDocument().GetSettings()->SetForceDarkModeEnabled(true);
GetDocument().GetSettings()->SetPreferredColorScheme( GetDocument().GetSettings()->SetPreferredColorScheme(
......
...@@ -18,18 +18,23 @@ ...@@ -18,18 +18,23 @@
#include "third_party/blink/renderer/core/testing/page_test_base.h" #include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/heap/heap.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/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
namespace blink { namespace blink {
class HTMLMetaElementTest : public PageTestBase { class HTMLMetaElementTest : public PageTestBase,
private ScopedDisplayCutoutAPIForTest,
private ScopedMetaColorSchemeForTest,
private ScopedMediaQueryPrefersColorSchemeForTest,
private ScopedCSSColorSchemeForTest {
public: public:
HTMLMetaElementTest()
: ScopedDisplayCutoutAPIForTest(true),
ScopedMetaColorSchemeForTest(true),
ScopedMediaQueryPrefersColorSchemeForTest(true),
ScopedCSSColorSchemeForTest(true) {}
void SetUp() override { void SetUp() override {
PageTestBase::SetUp(); PageTestBase::SetUp();
RuntimeEnabledFeatures::SetDisplayCutoutAPIEnabled(true);
RuntimeEnabledFeatures::SetMetaColorSchemeEnabled(true);
RuntimeEnabledFeatures::SetMediaQueryPrefersColorSchemeEnabled(true);
RuntimeEnabledFeatures::SetCSSColorSchemeEnabled(true);
GetDocument().GetSettings()->SetViewportMetaEnabled(true); GetDocument().GetSettings()->SetViewportMetaEnabled(true);
} }
......
...@@ -17,15 +17,14 @@ ...@@ -17,15 +17,14 @@
#include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h" #include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/graphics/color.h" #include "third_party/blink/renderer/platform/graphics/color.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
namespace blink { namespace blink {
class LayoutThemeTest : public PageTestBase { class LayoutThemeTest : public PageTestBase,
private ScopedCSSColorSchemeForTest {
protected: protected:
void SetUp() override { LayoutThemeTest() : ScopedCSSColorSchemeForTest(true) {}
RuntimeEnabledFeatures::SetCSSColorSchemeEnabled(true);
PageTestBase::SetUp();
}
void SetHtmlInnerHTML(const char* html_content); void SetHtmlInnerHTML(const char* html_content);
}; };
......
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