OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 if (*it != browser) | 82 if (*it != browser) |
83 other_browser = *it; | 83 other_browser = *it; |
84 } | 84 } |
85 return other_browser; | 85 return other_browser; |
86 } | 86 } |
87 | 87 |
88 } // namespace | 88 } // namespace |
89 | 89 |
90 class StartupBrowserCreatorTest : public ExtensionBrowserTest { | 90 class StartupBrowserCreatorTest : public ExtensionBrowserTest { |
91 protected: | 91 protected: |
92 virtual bool SetUpUserDataDirectory() override { | 92 bool SetUpUserDataDirectory() override { |
93 return ExtensionBrowserTest::SetUpUserDataDirectory(); | 93 return ExtensionBrowserTest::SetUpUserDataDirectory(); |
94 } | 94 } |
95 | 95 |
96 virtual void SetUpCommandLine(CommandLine* command_line) override { | 96 void SetUpCommandLine(CommandLine* command_line) override { |
97 ExtensionBrowserTest::SetUpCommandLine(command_line); | 97 ExtensionBrowserTest::SetUpCommandLine(command_line); |
98 command_line->AppendSwitch(switches::kEnablePanels); | 98 command_line->AppendSwitch(switches::kEnablePanels); |
99 command_line->AppendSwitchASCII(switches::kHomePage, url::kAboutBlankURL); | 99 command_line->AppendSwitchASCII(switches::kHomePage, url::kAboutBlankURL); |
100 #if defined(OS_CHROMEOS) | 100 #if defined(OS_CHROMEOS) |
101 // TODO(nkostylev): Investigate if we can remove this switch. | 101 // TODO(nkostylev): Investigate if we can remove this switch. |
102 command_line->AppendSwitch(switches::kCreateBrowserOnStartupForTests); | 102 command_line->AppendSwitch(switches::kCreateBrowserOnStartupForTests); |
103 #endif | 103 #endif |
104 } | 104 } |
105 | 105 |
106 // Helper functions return void so that we can ASSERT*(). | 106 // Helper functions return void so that we can ASSERT*(). |
(...skipping 28 matching lines...) Expand all Loading... |
135 return *it; | 135 return *it; |
136 } | 136 } |
137 return NULL; | 137 return NULL; |
138 } | 138 } |
139 }; | 139 }; |
140 | 140 |
141 class OpenURLsPopupObserver : public chrome::BrowserListObserver { | 141 class OpenURLsPopupObserver : public chrome::BrowserListObserver { |
142 public: | 142 public: |
143 OpenURLsPopupObserver() : added_browser_(NULL) { } | 143 OpenURLsPopupObserver() : added_browser_(NULL) { } |
144 | 144 |
145 virtual void OnBrowserAdded(Browser* browser) override { | 145 void OnBrowserAdded(Browser* browser) override { added_browser_ = browser; } |
146 added_browser_ = browser; | |
147 } | |
148 | 146 |
149 virtual void OnBrowserRemoved(Browser* browser) override { } | 147 void OnBrowserRemoved(Browser* browser) override {} |
150 | 148 |
151 Browser* added_browser_; | 149 Browser* added_browser_; |
152 }; | 150 }; |
153 | 151 |
154 // Test that when there is a popup as the active browser any requests to | 152 // Test that when there is a popup as the active browser any requests to |
155 // StartupBrowserCreatorImpl::OpenURLsInBrowser don't crash because there's no | 153 // StartupBrowserCreatorImpl::OpenURLsInBrowser don't crash because there's no |
156 // explicit profile given. | 154 // explicit profile given. |
157 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenURLsPopup) { | 155 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenURLsPopup) { |
158 std::vector<GURL> urls; | 156 std::vector<GURL> urls; |
159 urls.push_back(GURL("http://localhost")); | 157 urls.push_back(GURL("http://localhost")); |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 tab_strip = new_browser->tab_strip_model(); | 994 tab_strip = new_browser->tab_strip_model(); |
997 ASSERT_EQ(1, tab_strip->count()); | 995 ASSERT_EQ(1, tab_strip->count()); |
998 web_contents = tab_strip->GetWebContentsAt(0); | 996 web_contents = tab_strip->GetWebContentsAt(0); |
999 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); | 997 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); |
1000 infobar_service = InfoBarService::FromWebContents(web_contents); | 998 infobar_service = InfoBarService::FromWebContents(web_contents); |
1001 EXPECT_EQ(1U, infobar_service->infobar_count()); | 999 EXPECT_EQ(1U, infobar_service->infobar_count()); |
1002 } | 1000 } |
1003 | 1001 |
1004 class SupervisedUserBrowserCreatorTest : public InProcessBrowserTest { | 1002 class SupervisedUserBrowserCreatorTest : public InProcessBrowserTest { |
1005 protected: | 1003 protected: |
1006 virtual void SetUpCommandLine(CommandLine* command_line) override { | 1004 void SetUpCommandLine(CommandLine* command_line) override { |
1007 InProcessBrowserTest::SetUpCommandLine(command_line); | 1005 InProcessBrowserTest::SetUpCommandLine(command_line); |
1008 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf"); | 1006 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf"); |
1009 } | 1007 } |
1010 }; | 1008 }; |
1011 | 1009 |
1012 IN_PROC_BROWSER_TEST_F(SupervisedUserBrowserCreatorTest, | 1010 IN_PROC_BROWSER_TEST_F(SupervisedUserBrowserCreatorTest, |
1013 StartupSupervisedUserProfile) { | 1011 StartupSupervisedUserProfile) { |
1014 StartupBrowserCreator browser_creator; | 1012 StartupBrowserCreator browser_creator; |
1015 | 1013 |
1016 // Do a simple non-process-startup browser launch. | 1014 // Do a simple non-process-startup browser launch. |
(...skipping 21 matching lines...) Expand all Loading... |
1038 // the sync promo exist there. | 1036 // the sync promo exist there. |
1039 #if !defined(OS_CHROMEOS) | 1037 #if !defined(OS_CHROMEOS) |
1040 | 1038 |
1041 // On a branded Linux build, policy is required to suppress the first-run | 1039 // On a branded Linux build, policy is required to suppress the first-run |
1042 // dialog. | 1040 // dialog. |
1043 #if !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || \ | 1041 #if !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || \ |
1044 defined(ENABLE_CONFIGURATION_POLICY) | 1042 defined(ENABLE_CONFIGURATION_POLICY) |
1045 | 1043 |
1046 class StartupBrowserCreatorFirstRunTest : public InProcessBrowserTest { | 1044 class StartupBrowserCreatorFirstRunTest : public InProcessBrowserTest { |
1047 protected: | 1045 protected: |
1048 virtual void SetUpCommandLine(CommandLine* command_line) override; | 1046 void SetUpCommandLine(CommandLine* command_line) override; |
1049 virtual void SetUpInProcessBrowserTestFixture() override; | 1047 void SetUpInProcessBrowserTestFixture() override; |
1050 | 1048 |
1051 #if defined(ENABLE_CONFIGURATION_POLICY) | 1049 #if defined(ENABLE_CONFIGURATION_POLICY) |
1052 policy::MockConfigurationPolicyProvider provider_; | 1050 policy::MockConfigurationPolicyProvider provider_; |
1053 policy::PolicyMap policy_map_; | 1051 policy::PolicyMap policy_map_; |
1054 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1052 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
1055 }; | 1053 }; |
1056 | 1054 |
1057 void StartupBrowserCreatorFirstRunTest::SetUpCommandLine( | 1055 void StartupBrowserCreatorFirstRunTest::SetUpCommandLine( |
1058 CommandLine* command_line) { | 1056 CommandLine* command_line) { |
1059 command_line->AppendSwitch(switches::kForceFirstRun); | 1057 command_line->AppendSwitch(switches::kForceFirstRun); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 ASSERT_EQ(1, tab_strip->count()); | 1438 ASSERT_EQ(1, tab_strip->count()); |
1441 EXPECT_EQ("title1.html", | 1439 EXPECT_EQ("title1.html", |
1442 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1440 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
1443 } | 1441 } |
1444 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1442 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
1445 | 1443 |
1446 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || | 1444 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || |
1447 // defined(ENABLE_CONFIGURATION_POLICY) | 1445 // defined(ENABLE_CONFIGURATION_POLICY) |
1448 | 1446 |
1449 #endif // !defined(OS_CHROMEOS) | 1447 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |