Index: chrome/browser/ui/cocoa/location_bar/zoom_decoration_unittest.mm |
diff --git a/chrome/browser/ui/cocoa/location_bar/zoom_decoration_unittest.mm b/chrome/browser/ui/cocoa/location_bar/zoom_decoration_unittest.mm |
index 7742df1a125aa3e31c6dc9985431804b57b32f37..d310a9040b887b6ff976f4aaa3612d5483939e87 100644 |
--- a/chrome/browser/ui/cocoa/location_bar/zoom_decoration_unittest.mm |
+++ b/chrome/browser/ui/cocoa/location_bar/zoom_decoration_unittest.mm |
@@ -2,14 +2,57 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "base/macros.h" |
#import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" |
+ |
+#include "base/command_line.h" |
+#include "base/macros.h" |
#include "chrome/test/base/chrome_render_view_host_test_harness.h" |
#include "components/zoom/zoom_controller.h" |
+#include "ui/base/ui_base_switches.h" |
namespace { |
-class ZoomDecorationTest : public ChromeRenderViewHostTestHarness {}; |
+// An enum to parameterize the tests so that the tests can be run with and |
msw
2017/04/24 18:53:39
Yikes, ditto. Maybe use a test utils file and/or t
varkha
2017/04/26 04:52:59
Done.
|
+// without the secondary-ui-md flag. |
+enum class SecondaryUiMd { |
+ ENABLED, |
+ DISABLED, |
+}; |
+ |
+// Generates the test name suffix depending on the value of the SecondaryUiMd |
+// param. |
+std::string SecondaryUiMdStatusToString( |
+ const ::testing::TestParamInfo<SecondaryUiMd>& info) { |
+ switch (info.param) { |
+ case SecondaryUiMd::ENABLED: |
+ return "SecondaryUiMdEnabled"; |
+ case SecondaryUiMd::DISABLED: |
+ return "SecondaryUiMdDisabled"; |
+ } |
+ NOTREACHED(); |
+ return std::string(); |
+} |
+ |
+class ZoomDecorationTest : public ChromeRenderViewHostTestHarness, |
+ public ::testing::WithParamInterface<SecondaryUiMd> { |
+ public: |
+ ZoomDecorationTest() {} |
+ ~ZoomDecorationTest() override {} |
+ |
+ protected: |
+ // testing::Test: |
+ void SetUp() override { |
+ // TODO(crbug.com/630357): Remove parameterized testing for this class when |
+ // secondary-ui-md is enabled by default on all platforms. |
+ if (GetParam() == SecondaryUiMd::ENABLED) { |
+ base::CommandLine::ForCurrentProcess()->AppendSwitch( |
+ switches::kExtendMdToSecondaryUi); |
+ } |
+ ChromeRenderViewHostTestHarness::SetUp(); |
+ } |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ZoomDecorationTest); |
+}; |
class MockZoomDecoration : public ZoomDecoration { |
public: |
@@ -45,7 +88,7 @@ class MockZoomController : public zoom::ZoomController { |
// Test that UpdateIfNecessary performs redraws only when the zoom percent |
// changes. |
-TEST_F(ZoomDecorationTest, ChangeZoomPercent) { |
+TEST_P(ZoomDecorationTest, ChangeZoomPercent) { |
MockZoomDecoration decoration(NULL); |
MockZoomController controller(web_contents()); |
@@ -73,4 +116,12 @@ TEST_F(ZoomDecorationTest, ChangeZoomPercent) { |
EXPECT_EQ(3, decoration.update_ui_count_); |
} |
+// Prefix for test instantiations intentionally left blank since the test |
+// fixture class has a single parameterization. |
+INSTANTIATE_TEST_CASE_P(, |
+ ZoomDecorationTest, |
+ ::testing::Values(SecondaryUiMd::ENABLED, |
+ SecondaryUiMd::DISABLED), |
+ &SecondaryUiMdStatusToString); |
+ |
} // namespace |