OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/settings_window_manager.h" | 5 #include "chrome/browser/ui/settings_window_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 class SettingsWindowTestObserver | 28 class SettingsWindowTestObserver |
29 : public chrome::SettingsWindowManagerObserver { | 29 : public chrome::SettingsWindowManagerObserver { |
30 public: | 30 public: |
31 SettingsWindowTestObserver() : browser_(NULL), new_settings_count_(0) {} | 31 SettingsWindowTestObserver() : browser_(NULL), new_settings_count_(0) {} |
32 virtual ~SettingsWindowTestObserver() {} | 32 virtual ~SettingsWindowTestObserver() {} |
33 | 33 |
34 virtual void OnNewSettingsWindow(Browser* settings_browser) OVERRIDE { | 34 virtual void OnNewSettingsWindow(Browser* settings_browser) override { |
35 browser_ = settings_browser; | 35 browser_ = settings_browser; |
36 ++new_settings_count_; | 36 ++new_settings_count_; |
37 } | 37 } |
38 | 38 |
39 Browser* browser() { return browser_; } | 39 Browser* browser() { return browser_; } |
40 size_t new_settings_count() const { return new_settings_count_; } | 40 size_t new_settings_count() const { return new_settings_count_; } |
41 | 41 |
42 private: | 42 private: |
43 Browser* browser_; | 43 Browser* browser_; |
44 size_t new_settings_count_; | 44 size_t new_settings_count_; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(SettingsWindowTestObserver); | 46 DISALLOW_COPY_AND_ASSIGN(SettingsWindowTestObserver); |
47 }; | 47 }; |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 class SettingsWindowManagerTest : public InProcessBrowserTest { | 51 class SettingsWindowManagerTest : public InProcessBrowserTest { |
52 public: | 52 public: |
53 SettingsWindowManagerTest() | 53 SettingsWindowManagerTest() |
54 : settings_manager_(chrome::SettingsWindowManager::GetInstance()), | 54 : settings_manager_(chrome::SettingsWindowManager::GetInstance()), |
55 test_profile_(NULL) { | 55 test_profile_(NULL) { |
56 settings_manager_->AddObserver(&observer_); | 56 settings_manager_->AddObserver(&observer_); |
57 } | 57 } |
58 virtual ~SettingsWindowManagerTest() { | 58 virtual ~SettingsWindowManagerTest() { |
59 settings_manager_->RemoveObserver(&observer_); | 59 settings_manager_->RemoveObserver(&observer_); |
60 } | 60 } |
61 | 61 |
62 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 62 virtual void SetUpCommandLine(CommandLine* command_line) override { |
63 command_line->AppendSwitch(::switches::kEnableSettingsWindow); | 63 command_line->AppendSwitch(::switches::kEnableSettingsWindow); |
64 } | 64 } |
65 | 65 |
66 Profile* CreateTestProfile() { | 66 Profile* CreateTestProfile() { |
67 CHECK(!test_profile_); | 67 CHECK(!test_profile_); |
68 | 68 |
69 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 69 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
70 base::RunLoop run_loop; | 70 base::RunLoop run_loop; |
71 profile_manager->CreateProfileAsync( | 71 profile_manager->CreateProfileAsync( |
72 profile_manager->GenerateNextProfileDirectoryPath(), | 72 profile_manager->GenerateNextProfileDirectoryPath(), |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 206 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
207 | 207 |
208 // Downloads should open in an existing browser window. | 208 // Downloads should open in an existing browser window. |
209 chrome::ShowDownloads(browser()); | 209 chrome::ShowDownloads(browser()); |
210 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 210 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
211 | 211 |
212 // About should open a new browser window. | 212 // About should open a new browser window. |
213 chrome::ShowAboutChrome(browser()); | 213 chrome::ShowAboutChrome(browser()); |
214 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 214 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
215 } | 215 } |
OLD | NEW |