Chromium Code Reviews| Index: chrome/browser/ui/webui/set_as_default_browser_ui_browsertest.cc |
| diff --git a/chrome/browser/ui/webui/set_as_default_browser_ui_browsertest.cc b/chrome/browser/ui/webui/set_as_default_browser_ui_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6ee01fa4c7919e619a57534718031d252d811a4a |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/set_as_default_browser_ui_browsertest.cc |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/set_as_default_browser_ui.h" |
|
sky
2016/07/06 19:21:19
As this file is win only please name it as such.
zmin
2016/07/06 20:04:31
You mean the name of all three files, not just the
sky
2016/07/06 23:53:16
Good point. I had only thtought this file was win,
zmin
2016/07/18 21:12:14
Done.
|
| + |
| +#include "base/command_line.h" |
| +#include "base/win/windows_version.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "ui/views/widget/widget.h" |
| + |
| +class SetAsDefaultBrowserUIBrowserTest : public InProcessBrowserTest { |
| + protected: |
| + bool IsMainWindowVisible() { |
|
sky
2016/07/06 19:21:19
You shouldn't need a subclass just for this functi
zmin
2016/07/06 20:04:31
Done.
|
| + return views::Widget::GetWidgetForNativeWindow( |
| + browser()->window()->GetNativeWindow()) |
| + ->IsVisible(); |
| + } |
| +}; |
| + |
| +class SetAsDefaultBrowserUIBrowserTestWithFirstRun |
| + : public SetAsDefaultBrowserUIBrowserTest { |
| + void SetUpCommandLine(base::CommandLine* command_line) override { |
| + InProcessBrowserTest::SetUpCommandLine(command_line); |
| + command_line->AppendSwitch(switches::kForceFirstRun); |
| + } |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(SetAsDefaultBrowserUIBrowserTestWithFirstRun, Test) { |
| + // Windows 8 only test case. |
| + if (base::win::GetVersion() <= base::win::VERSION_WIN7 || |
| + base::win::GetVersion() >= base::win::VERSION_WIN10) { |
| + return; |
| + } |
| + ASSERT_FALSE(IsMainWindowVisible()); |
| + views::Widget* dialog_widget = |
| + SetAsDefaultBrowserUI::GetDialogWidgetForTesting(); |
| + EXPECT_NE(nullptr, dialog_widget); |
|
sky
2016/07/06 19:21:19
ASSERT_TRUE(dialog_widget), otherwise if dialog_wi
zmin
2016/07/06 20:04:31
Done.
|
| + dialog_widget->CloseNow(); |
| + ASSERT_TRUE(IsMainWindowVisible()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(SetAsDefaultBrowserUIBrowserTest, TestWithoutFirstRun) { |
| + ASSERT_TRUE(IsMainWindowVisible()); |
| + EXPECT_EQ(nullptr, SetAsDefaultBrowserUI::GetDialogWidgetForTesting()); |
| +} |