Chromium Code Reviews| Index: chrome/browser/ui/cocoa/location_bar/zoom_decoration_browsertest.mm |
| diff --git a/chrome/browser/ui/cocoa/location_bar/zoom_decoration_browsertest.mm b/chrome/browser/ui/cocoa/location_bar/zoom_decoration_browsertest.mm |
| index 7490a1bb6dd052b284f3de9f87fd2bfad1ba48c7..81b63cc0a0f50bc1fcafc59714254400bcdb3a6d 100644 |
| --- a/chrome/browser/ui/cocoa/location_bar/zoom_decoration_browsertest.mm |
| +++ b/chrome/browser/ui/cocoa/location_bar/zoom_decoration_browsertest.mm |
| @@ -5,6 +5,7 @@ |
| #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" |
| #include "base/auto_reset.h" |
| +#include "base/command_line.h" |
| #include "base/macros.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| #include "chrome/browser/profiles/profile.h" |
| @@ -20,14 +21,51 @@ |
| #include "components/zoom/zoom_controller.h" |
| #include "content/public/browser/host_zoom_map.h" |
| #include "content/public/test/test_utils.h" |
| +#include "ui/base/ui_base_switches.h" |
| -class ZoomDecorationTest : public InProcessBrowserTest { |
| +namespace { |
| + |
| +// An enum to parameterize the tests so that the tests can be run with and |
|
msw
2017/04/24 18:53:38
nit: simplify this to a bool param or extract the
varkha
2017/04/26 04:52:59
Done. Not sure about refactoring this, this is use
|
| +// 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(); |
| +} |
| + |
| +} // namespace |
| + |
| +class ZoomDecorationTest : public InProcessBrowserTest, |
| + public ::testing::WithParamInterface<SecondaryUiMd> { |
| protected: |
| ZoomDecorationTest() |
| : InProcessBrowserTest(), |
| should_quit_on_zoom_(false) { |
| } |
| + 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); |
| + } |
| + InProcessBrowserTest::SetUp(); |
| + } |
| + |
| void SetUpOnMainThread() override { |
| zoom_subscription_ = content::HostZoomMap::GetDefaultForBrowserContext( |
| browser()->profile())->AddZoomLevelChangedCallback( |
| @@ -80,7 +118,7 @@ class ZoomDecorationTest : public InProcessBrowserTest { |
| DISALLOW_COPY_AND_ASSIGN(ZoomDecorationTest); |
| }; |
| -IN_PROC_BROWSER_TEST_F(ZoomDecorationTest, BubbleAtDefaultZoom) { |
| +IN_PROC_BROWSER_TEST_P(ZoomDecorationTest, BubbleAtDefaultZoom) { |
| ZoomDecoration* zoom_decoration = GetZoomDecoration(); |
| // TODO(wjmaclean): This shouldn't be necessary, but at present this test |
| @@ -113,7 +151,7 @@ IN_PROC_BROWSER_TEST_F(ZoomDecorationTest, BubbleAtDefaultZoom) { |
| } |
| // Regression test for https://crbug.com/462482. |
| -IN_PROC_BROWSER_TEST_F(ZoomDecorationTest, IconRemainsVisibleAfterBubble) { |
| +IN_PROC_BROWSER_TEST_P(ZoomDecorationTest, IconRemainsVisibleAfterBubble) { |
| ZoomDecoration* zoom_decoration = GetZoomDecoration(); |
| // See comment in BubbleAtDefaultZoom regarding this next line. |
| @@ -138,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(ZoomDecorationTest, IconRemainsVisibleAfterBubble) { |
| EXPECT_FALSE(zoom_decoration->IsVisible()); |
| } |
| -IN_PROC_BROWSER_TEST_F(ZoomDecorationTest, HideOnInputProgress) { |
| +IN_PROC_BROWSER_TEST_P(ZoomDecorationTest, HideOnInputProgress) { |
| ZoomDecoration* zoom_decoration = GetZoomDecoration(); |
| // Zoom in and reset. |
| @@ -152,7 +190,7 @@ IN_PROC_BROWSER_TEST_F(ZoomDecorationTest, HideOnInputProgress) { |
| EXPECT_FALSE(zoom_decoration->IsVisible()); |
| } |
| -IN_PROC_BROWSER_TEST_F(ZoomDecorationTest, CloseBrowserWithOpenBubble) { |
| +IN_PROC_BROWSER_TEST_P(ZoomDecorationTest, CloseBrowserWithOpenBubble) { |
| chrome::SetZoomBubbleAutoCloseDelayForTesting(0); |
| // Create a new browser so that it can be closed properly. |
| @@ -164,3 +202,11 @@ IN_PROC_BROWSER_TEST_F(ZoomDecorationTest, CloseBrowserWithOpenBubble) { |
| browser2->window()->Close(); |
| content::RunAllPendingInMessageLoop(); |
| } |
| + |
| +// 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); |