OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef RuntimeEnabledFeaturesTestHelpers_h |
| 6 #define RuntimeEnabledFeaturesTestHelpers_h |
| 7 |
| 8 #include "platform/RuntimeEnabledFeatures.h" |
| 9 #include "wtf/Assertions.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 template <bool(&getter)(), void(&setter)(bool)> |
| 14 class ScopedRuntimeEnabledFeatureForTest { |
| 15 public: |
| 16 ScopedRuntimeEnabledFeatureForTest(bool enabled) |
| 17 : m_enabled(enabled) |
| 18 , m_original(getter()) |
| 19 { |
| 20 setter(enabled); |
| 21 } |
| 22 |
| 23 ~ScopedRuntimeEnabledFeatureForTest() |
| 24 { |
| 25 CHECK_EQ(m_enabled, getter()); |
| 26 setter(m_original); |
| 27 } |
| 28 |
| 29 private: |
| 30 bool m_enabled; |
| 31 bool m_original; |
| 32 }; |
| 33 |
| 34 typedef ScopedRuntimeEnabledFeatureForTest<RuntimeEnabledFeatures::compositorWor
kerEnabled, RuntimeEnabledFeatures::setCompositorWorkerEnabled> ScopedCompositor
WorkerForTest; |
| 35 typedef ScopedRuntimeEnabledFeatureForTest<RuntimeEnabledFeatures::rootLayerScro
llingEnabled, RuntimeEnabledFeatures::setRootLayerScrollingEnabled> ScopedRootLa
yerScrollingForTest; |
| 36 typedef ScopedRuntimeEnabledFeatureForTest<RuntimeEnabledFeatures::slimmingPaint
V2Enabled, RuntimeEnabledFeatures::setSlimmingPaintV2Enabled> ScopedSlimmingPain
tV2ForTest; |
| 37 |
| 38 } // namespace blink |
| 39 |
| 40 #endif // RuntimeEnabledFeaturesTestHelpers_h |
OLD | NEW |