Chromium Code Reviews| 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 #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.
| |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/win/windows_version.h" | |
| 9 #include "chrome/browser/ui/browser.h" | |
| 10 #include "chrome/browser/ui/browser_window.h" | |
| 11 #include "chrome/common/chrome_switches.h" | |
| 12 #include "chrome/test/base/in_process_browser_test.h" | |
| 13 #include "ui/views/widget/widget.h" | |
| 14 | |
| 15 class SetAsDefaultBrowserUIBrowserTest : public InProcessBrowserTest { | |
| 16 protected: | |
| 17 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.
| |
| 18 return views::Widget::GetWidgetForNativeWindow( | |
| 19 browser()->window()->GetNativeWindow()) | |
| 20 ->IsVisible(); | |
| 21 } | |
| 22 }; | |
| 23 | |
| 24 class SetAsDefaultBrowserUIBrowserTestWithFirstRun | |
| 25 : public SetAsDefaultBrowserUIBrowserTest { | |
| 26 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 27 InProcessBrowserTest::SetUpCommandLine(command_line); | |
| 28 command_line->AppendSwitch(switches::kForceFirstRun); | |
| 29 } | |
| 30 }; | |
| 31 | |
| 32 IN_PROC_BROWSER_TEST_F(SetAsDefaultBrowserUIBrowserTestWithFirstRun, Test) { | |
| 33 // Windows 8 only test case. | |
| 34 if (base::win::GetVersion() <= base::win::VERSION_WIN7 || | |
| 35 base::win::GetVersion() >= base::win::VERSION_WIN10) { | |
| 36 return; | |
| 37 } | |
| 38 ASSERT_FALSE(IsMainWindowVisible()); | |
| 39 views::Widget* dialog_widget = | |
| 40 SetAsDefaultBrowserUI::GetDialogWidgetForTesting(); | |
| 41 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.
| |
| 42 dialog_widget->CloseNow(); | |
| 43 ASSERT_TRUE(IsMainWindowVisible()); | |
| 44 } | |
| 45 | |
| 46 IN_PROC_BROWSER_TEST_F(SetAsDefaultBrowserUIBrowserTest, TestWithoutFirstRun) { | |
| 47 ASSERT_TRUE(IsMainWindowVisible()); | |
| 48 EXPECT_EQ(nullptr, SetAsDefaultBrowserUI::GetDialogWidgetForTesting()); | |
| 49 } | |
| OLD | NEW |