summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/settings_window_manager_browsertest.cc
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-02 00:36:14 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-02 00:36:14 +0000
commita59bcc5d3997368fc4c179abf9b62238679d2f37 (patch)
tree5a6efbdd9f87f1633e8441147ae72839f8e29be4 /chrome/browser/ui/settings_window_manager_browsertest.cc
parent71c5602467ce505de6247c83cbb0378dca6e19fd (diff)
downloadchromium_src-a59bcc5d3997368fc4c179abf9b62238679d2f37.zip
chromium_src-a59bcc5d3997368fc4c179abf9b62238679d2f37.tar.gz
chromium_src-a59bcc5d3997368fc4c179abf9b62238679d2f37.tar.bz2
Show History and Extensions in SettingsWindow when enabled
BUG=367900 R=ben@chromium.org Review URL: https://codereview.chromium.org/255043002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267699 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/settings_window_manager_browsertest.cc')
-rw-r--r--chrome/browser/ui/settings_window_manager_browsertest.cc86
1 files changed, 67 insertions, 19 deletions
diff --git a/chrome/browser/ui/settings_window_manager_browsertest.cc b/chrome/browser/ui/settings_window_manager_browsertest.cc
index 50aabfc..83f0cf3 100644
--- a/chrome/browser/ui/settings_window_manager_browsertest.cc
+++ b/chrome/browser/ui/settings_window_manager_browsertest.cc
@@ -11,12 +11,17 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/settings_window_manager_observer.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
+#include "url/gurl.h"
namespace {
@@ -45,14 +50,17 @@ class SettingsWindowTestObserver
class SettingsWindowManagerTest : public InProcessBrowserTest {
public:
- SettingsWindowManagerTest() : test_profile_(NULL) {
- chrome::SettingsWindowManager::GetInstance()->AddObserver(&observer_);
+ SettingsWindowManagerTest()
+ : settings_manager_(chrome::SettingsWindowManager::GetInstance()),
+ test_profile_(NULL) {
+ settings_manager_->AddObserver(&observer_);
}
virtual ~SettingsWindowManagerTest() {
- chrome::SettingsWindowManager::GetInstance()->RemoveObserver(&observer_);
+ settings_manager_->RemoveObserver(&observer_);
}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ command_line->AppendSwitch(::switches::kEnableSettingsWindow);
command_line->AppendSwitch(::switches::kMultiProfiles);
}
@@ -83,6 +91,11 @@ class SettingsWindowManagerTest : public InProcessBrowserTest {
}
}
+ void ShowSettingsForProfile(Profile* profile) {
+ settings_manager_->ShowChromePageForProfile(
+ profile, GURL(chrome::kChromeUISettingsURL));
+ }
+
void CloseBrowserSynchronously(Browser* browser) {
content::WindowedNotificationObserver observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
@@ -91,7 +104,20 @@ class SettingsWindowManagerTest : public InProcessBrowserTest {
observer.Wait();
}
+ void CloseNonDefaultBrowsers() {
+ std::list<Browser*> browsers_to_close;
+ for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ if (*it != browser())
+ browsers_to_close.push_back(*it);
+ }
+ for (std::list<Browser*>::iterator iter = browsers_to_close.begin();
+ iter != browsers_to_close.end(); ++iter) {
+ CloseBrowserSynchronously(*iter);
+ }
+ }
+
protected:
+ chrome::SettingsWindowManager* settings_manager_;
SettingsWindowTestObserver observer_;
base::ScopedTempDir temp_profile_dir_;
Profile* test_profile_; // Owned by g_browser_process->profile_manager()
@@ -101,32 +127,29 @@ class SettingsWindowManagerTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(SettingsWindowManagerTest, OpenSettingsWindow) {
- chrome::SettingsWindowManager* settings_manager =
- chrome::SettingsWindowManager::GetInstance();
-
// Open a settings window.
- settings_manager->ShowForProfile(browser()->profile(), std::string());
+ ShowSettingsForProfile(browser()->profile());
Browser* settings_browser =
- settings_manager->FindBrowserForProfile(browser()->profile());
+ settings_manager_->FindBrowserForProfile(browser()->profile());
ASSERT_TRUE(settings_browser);
// Ensure the observer fired correctly.
EXPECT_EQ(1u, observer_.new_settings_count());
EXPECT_EQ(settings_browser, observer_.browser());
// Open the settings again: no new window.
- settings_manager->ShowForProfile(browser()->profile(), std::string());
+ ShowSettingsForProfile(browser()->profile());
EXPECT_EQ(settings_browser,
- settings_manager->FindBrowserForProfile(browser()->profile()));
+ settings_manager_->FindBrowserForProfile(browser()->profile()));
EXPECT_EQ(1u, observer_.new_settings_count());
// Close the settings window.
CloseBrowserSynchronously(settings_browser);
- EXPECT_FALSE(settings_manager->FindBrowserForProfile(browser()->profile()));
+ EXPECT_FALSE(settings_manager_->FindBrowserForProfile(browser()->profile()));
// Open a new settings window.
- settings_manager->ShowForProfile(browser()->profile(), std::string());
+ ShowSettingsForProfile(browser()->profile());
Browser* settings_browser2 =
- settings_manager->FindBrowserForProfile(browser()->profile());
+ settings_manager_->FindBrowserForProfile(browser()->profile());
ASSERT_TRUE(settings_browser2);
EXPECT_EQ(2u, observer_.new_settings_count());
@@ -135,24 +158,22 @@ IN_PROC_BROWSER_TEST_F(SettingsWindowManagerTest, OpenSettingsWindow) {
#if !defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(SettingsWindowManagerTest, SettingsWindowMultiProfile) {
- chrome::SettingsWindowManager* settings_manager =
- chrome::SettingsWindowManager::GetInstance();
Profile* test_profile = CreateTestProfile();
ASSERT_TRUE(test_profile);
// Open a settings window.
- settings_manager->ShowForProfile(browser()->profile(), std::string());
+ ShowSettingsForProfile(browser()->profile());
Browser* settings_browser =
- settings_manager->FindBrowserForProfile(browser()->profile());
+ settings_manager_->FindBrowserForProfile(browser()->profile());
ASSERT_TRUE(settings_browser);
// Ensure the observer fired correctly.
EXPECT_EQ(1u, observer_.new_settings_count());
EXPECT_EQ(settings_browser, observer_.browser());
// Open a settings window for a new profile.
- settings_manager->ShowForProfile(test_profile, std::string());
+ ShowSettingsForProfile(test_profile);
Browser* settings_browser2 =
- settings_manager->FindBrowserForProfile(test_profile);
+ settings_manager_->FindBrowserForProfile(test_profile);
ASSERT_TRUE(settings_browser2);
// Ensure the observer fired correctly.
EXPECT_EQ(2u, observer_.new_settings_count());
@@ -162,3 +183,30 @@ IN_PROC_BROWSER_TEST_F(SettingsWindowManagerTest, SettingsWindowMultiProfile) {
CloseBrowserSynchronously(settings_browser2);
}
#endif
+
+IN_PROC_BROWSER_TEST_F(SettingsWindowManagerTest, OpenSettingsChromePages) {
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+
+ // Settings should open a new browser window.
+ chrome::ShowSettings(browser());
+ EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
+
+ // History should open a new browser window.
+ CloseNonDefaultBrowsers();
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+ chrome::ShowHistory(browser());
+ EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
+
+ // Extensions should open a new browser window.
+ CloseNonDefaultBrowsers();
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+ std::string extension_to_highlight; // none
+ chrome::ShowExtensions(browser(), extension_to_highlight);
+ EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
+
+ // Downloads should NOT open a new browser window.
+ CloseNonDefaultBrowsers();
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+ chrome::ShowDownloads(browser());
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+}