Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_command_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 NOTREACHED(); 349 NOTREACHED();
350 return NULL; 350 return NULL;
351 } 351 }
352 }; 352 };
353 353
354 // Launch the app on a page with no title, check that the app title was set 354 // Launch the app on a page with no title, check that the app title was set
355 // correctly. 355 // correctly.
356 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) { 356 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) {
357 #if defined(OS_WIN) && defined(USE_ASH) 357 #if defined(OS_WIN) && defined(USE_ASH)
358 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 358 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
359 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 359 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
360 switches::kAshBrowserTests))
360 return; 361 return;
361 #endif 362 #endif
362 363
363 ui_test_utils::NavigateToURL( 364 ui_test_utils::NavigateToURL(
364 browser(), ui_test_utils::GetTestUrl( 365 browser(), ui_test_utils::GetTestUrl(
365 base::FilePath(base::FilePath::kCurrentDirectory), 366 base::FilePath(base::FilePath::kCurrentDirectory),
366 base::FilePath(kTitle1File))); 367 base::FilePath(kTitle1File)));
367 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(ASCIIToUTF16("title1.html")), 368 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(ASCIIToUTF16("title1.html")),
368 browser()->GetWindowTitleForCurrentTab()); 369 browser()->GetWindowTitleForCurrentTab());
369 base::string16 tab_title; 370 base::string16 tab_title;
370 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); 371 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title));
371 EXPECT_EQ(ASCIIToUTF16("title1.html"), tab_title); 372 EXPECT_EQ(ASCIIToUTF16("title1.html"), tab_title);
372 } 373 }
373 374
374 // Launch the app, navigate to a page with a title, check that the app title 375 // Launch the app, navigate to a page with a title, check that the app title
375 // was set correctly. 376 // was set correctly.
376 IN_PROC_BROWSER_TEST_F(BrowserTest, Title) { 377 IN_PROC_BROWSER_TEST_F(BrowserTest, Title) {
377 #if defined(OS_WIN) && defined(USE_ASH) 378 #if defined(OS_WIN) && defined(USE_ASH)
378 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 379 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
379 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 380 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
381 switches::kAshBrowserTests))
380 return; 382 return;
381 #endif 383 #endif
382 384
383 ui_test_utils::NavigateToURL( 385 ui_test_utils::NavigateToURL(
384 browser(), ui_test_utils::GetTestUrl( 386 browser(), ui_test_utils::GetTestUrl(
385 base::FilePath(base::FilePath::kCurrentDirectory), 387 base::FilePath(base::FilePath::kCurrentDirectory),
386 base::FilePath(kTitle2File))); 388 base::FilePath(kTitle2File)));
387 const base::string16 test_title(ASCIIToUTF16("Title Of Awesomeness")); 389 const base::string16 test_title(ASCIIToUTF16("Title Of Awesomeness"));
388 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title), 390 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title),
389 browser()->GetWindowTitleForCurrentTab()); 391 browser()->GetWindowTitleForCurrentTab());
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 // browser has not been able to quit correctly, indicating there's a 893 // browser has not been able to quit correctly, indicating there's a
892 // regression of the bug noted above. 894 // regression of the bug noted above.
893 } 895 }
894 896
895 // Test that scripts can fork a new renderer process for a cross-site popup, 897 // Test that scripts can fork a new renderer process for a cross-site popup,
896 // based on http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab. 898 // based on http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab.
897 // The script must open a new tab, set its window.opener to null, and navigate 899 // The script must open a new tab, set its window.opener to null, and navigate
898 // it to a cross-site URL. It should also work for meta-refreshes. 900 // it to a cross-site URL. It should also work for meta-refreshes.
899 // See http://crbug.com/93517. 901 // See http://crbug.com/93517.
900 IN_PROC_BROWSER_TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { 902 IN_PROC_BROWSER_TEST_F(BrowserTest, NullOpenerRedirectForksProcess) {
901 CommandLine::ForCurrentProcess()->AppendSwitch( 903 base::CommandLine::ForCurrentProcess()->AppendSwitch(
902 switches::kDisablePopupBlocking); 904 switches::kDisablePopupBlocking);
903 905
904 // Create http and https servers for a cross-site transition. 906 // Create http and https servers for a cross-site transition.
905 ASSERT_TRUE(test_server()->Start()); 907 ASSERT_TRUE(test_server()->Start());
906 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, 908 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS,
907 net::SpawnedTestServer::kLocalhost, 909 net::SpawnedTestServer::kLocalhost,
908 base::FilePath(kDocRoot)); 910 base::FilePath(kDocRoot));
909 ASSERT_TRUE(https_test_server.Start()); 911 ASSERT_TRUE(https_test_server.Start());
910 GURL http_url(test_server()->GetURL("files/title1.html")); 912 GURL http_url(test_server()->GetURL("files/title1.html"));
911 GURL https_url(https_test_server.GetURL(std::string())); 913 GURL https_url(https_test_server.GetURL(std::string()));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 // This popup window should also not be in the opener's process. 982 // This popup window should also not be in the opener's process.
981 content::RenderProcessHost* popup_process2 = 983 content::RenderProcessHost* popup_process2 =
982 newtab2->GetRenderProcessHost(); 984 newtab2->GetRenderProcessHost();
983 EXPECT_NE(process, popup_process2); 985 EXPECT_NE(process, popup_process2);
984 } 986 }
985 987
986 // Tests that other popup navigations that do not follow the steps at 988 // Tests that other popup navigations that do not follow the steps at
987 // http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab will not 989 // http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab will not
988 // fork a new renderer process. 990 // fork a new renderer process.
989 IN_PROC_BROWSER_TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { 991 IN_PROC_BROWSER_TEST_F(BrowserTest, OtherRedirectsDontForkProcess) {
990 CommandLine::ForCurrentProcess()->AppendSwitch( 992 base::CommandLine::ForCurrentProcess()->AppendSwitch(
991 switches::kDisablePopupBlocking); 993 switches::kDisablePopupBlocking);
992 994
993 // Create http and https servers for a cross-site transition. 995 // Create http and https servers for a cross-site transition.
994 ASSERT_TRUE(test_server()->Start()); 996 ASSERT_TRUE(test_server()->Start());
995 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, 997 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS,
996 net::SpawnedTestServer::kLocalhost, 998 net::SpawnedTestServer::kLocalhost,
997 base::FilePath(kDocRoot)); 999 base::FilePath(kDocRoot));
998 ASSERT_TRUE(https_test_server.Start()); 1000 ASSERT_TRUE(https_test_server.Start());
999 GURL http_url(test_server()->GetURL("files/title1.html")); 1001 GURL http_url(test_server()->GetURL("files/title1.html"));
1000 GURL https_url(https_test_server.GetURL(std::string())); 1002 GURL https_url(https_test_server.GetURL(std::string()));
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 ASSERT_TRUE(test_server()->Start()); 1302 ASSERT_TRUE(test_server()->Start());
1301 1303
1302 // There should be one tab to start with. 1304 // There should be one tab to start with.
1303 ASSERT_EQ(1, browser()->tab_strip_model()->count()); 1305 ASSERT_EQ(1, browser()->tab_strip_model()->count());
1304 1306
1305 // Load an app. 1307 // Load an app.
1306 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 1308 host_resolver()->AddRule("www.example.com", "127.0.0.1");
1307 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 1309 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
1308 const Extension* extension_app = GetExtension(); 1310 const Extension* extension_app = GetExtension();
1309 1311
1310 CommandLine command_line(CommandLine::NO_PROGRAM); 1312 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
1311 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); 1313 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id());
1312 1314
1313 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 1315 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
1314 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 1316 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
1315 StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run); 1317 StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run);
1316 EXPECT_FALSE(launch.OpenApplicationWindow(browser()->profile(), NULL)); 1318 EXPECT_FALSE(launch.OpenApplicationWindow(browser()->profile(), NULL));
1317 EXPECT_TRUE(launch.OpenApplicationTab(browser()->profile())); 1319 EXPECT_TRUE(launch.OpenApplicationTab(browser()->profile()));
1318 1320
1319 // Check that a new browser wasn't opened. 1321 // Check that a new browser wasn't opened.
1320 EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), 1322 EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile(),
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 1536
1535 // Add a pinned non-app tab. 1537 // Add a pinned non-app tab.
1536 chrome::NewTab(browser()); 1538 chrome::NewTab(browser());
1537 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 1539 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1538 model->SetTabPinned(2, true); 1540 model->SetTabPinned(2, true);
1539 1541
1540 // Write out the pinned tabs. 1542 // Write out the pinned tabs.
1541 PinnedTabCodec::WritePinnedTabs(browser()->profile()); 1543 PinnedTabCodec::WritePinnedTabs(browser()->profile());
1542 1544
1543 // Simulate launching again. 1545 // Simulate launching again.
1544 CommandLine dummy(CommandLine::NO_PROGRAM); 1546 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
1545 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 1547 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
1546 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 1548 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
1547 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); 1549 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
1548 launch.profile_ = browser()->profile(); 1550 launch.profile_ = browser()->profile();
1549 launch.ProcessStartupURLs(std::vector<GURL>(), 1551 launch.ProcessStartupURLs(std::vector<GURL>(),
1550 browser()->host_desktop_type()); 1552 browser()->host_desktop_type());
1551 1553
1552 // The launch should have created a new browser. 1554 // The launch should have created a new browser.
1553 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), 1555 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
1554 browser()->host_desktop_type())); 1556 browser()->host_desktop_type()));
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 EXPECT_EQ(4, browser()->tab_strip_model()->count()); 2136 EXPECT_EQ(4, browser()->tab_strip_model()->count());
2135 2137
2136 // Close the additional browsers. 2138 // Close the additional browsers.
2137 popup_browser->tab_strip_model()->CloseAllTabs(); 2139 popup_browser->tab_strip_model()->CloseAllTabs();
2138 app_browser->tab_strip_model()->CloseAllTabs(); 2140 app_browser->tab_strip_model()->CloseAllTabs();
2139 app_popup_browser->tab_strip_model()->CloseAllTabs(); 2141 app_popup_browser->tab_strip_model()->CloseAllTabs();
2140 } 2142 }
2141 #endif 2143 #endif
2142 2144
2143 IN_PROC_BROWSER_TEST_F(BrowserTest, WindowOpenClose) { 2145 IN_PROC_BROWSER_TEST_F(BrowserTest, WindowOpenClose) {
2144 CommandLine::ForCurrentProcess()->AppendSwitch( 2146 base::CommandLine::ForCurrentProcess()->AppendSwitch(
2145 switches::kDisablePopupBlocking); 2147 switches::kDisablePopupBlocking);
2146 GURL url = ui_test_utils::GetTestUrl( 2148 GURL url = ui_test_utils::GetTestUrl(
2147 base::FilePath(), base::FilePath().AppendASCII("window.close.html")); 2149 base::FilePath(), base::FilePath().AppendASCII("window.close.html"));
2148 2150
2149 base::string16 title = ASCIIToUTF16("Title Of Awesomeness"); 2151 base::string16 title = ASCIIToUTF16("Title Of Awesomeness");
2150 content::TitleWatcher title_watcher( 2152 content::TitleWatcher title_watcher(
2151 browser()->tab_strip_model()->GetActiveWebContents(), title); 2153 browser()->tab_strip_model()->GetActiveWebContents(), title);
2152 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2); 2154 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2);
2153 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); 2155 EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
2154 } 2156 }
2155 2157
2156 // TODO(linux_aura) http://crbug.com/163931 2158 // TODO(linux_aura) http://crbug.com/163931
2157 // Mac disabled: http://crbug.com/169820 2159 // Mac disabled: http://crbug.com/169820
2158 #if !defined(OS_MACOSX) && \ 2160 #if !defined(OS_MACOSX) && \
2159 !(defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)) 2161 !(defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA))
2160 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenBookmarkBar) { 2162 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenBookmarkBar) {
2161 #if defined(OS_WIN) && defined(USE_ASH) 2163 #if defined(OS_WIN) && defined(USE_ASH)
2162 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 2164 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
2163 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 2165 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2166 switches::kAshBrowserTests))
2164 return; 2167 return;
2165 #endif 2168 #endif
2166 2169
2167 chrome::ToggleBookmarkBar(browser()); 2170 chrome::ToggleBookmarkBar(browser());
2168 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 2171 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
2169 chrome::ToggleFullscreenMode(browser()); 2172 chrome::ToggleFullscreenMode(browser());
2170 EXPECT_TRUE(browser()->window()->IsFullscreen()); 2173 EXPECT_TRUE(browser()->window()->IsFullscreen());
2171 #if defined(OS_MACOSX) 2174 #if defined(OS_MACOSX)
2172 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 2175 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
2173 #elif defined(OS_CHROMEOS) 2176 #elif defined(OS_CHROMEOS)
(...skipping 16 matching lines...) Expand all
2190 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); 2193 browser()->tab_strip_model()->GetActiveWebContents(), expected_title);
2191 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("Allowed")); 2194 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("Allowed"));
2192 ui_test_utils::NavigateToURL(browser(), url); 2195 ui_test_utils::NavigateToURL(browser(), url);
2193 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 2196 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle());
2194 } 2197 }
2195 2198
2196 class KioskModeTest : public BrowserTest { 2199 class KioskModeTest : public BrowserTest {
2197 public: 2200 public:
2198 KioskModeTest() {} 2201 KioskModeTest() {}
2199 2202
2200 void SetUpCommandLine(CommandLine* command_line) override { 2203 void SetUpCommandLine(base::CommandLine* command_line) override {
2201 command_line->AppendSwitch(switches::kKioskMode); 2204 command_line->AppendSwitch(switches::kKioskMode);
2202 } 2205 }
2203 }; 2206 };
2204 2207
2205 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) 2208 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
2206 // Mac: http://crbug.com/103912 2209 // Mac: http://crbug.com/103912
2207 // Linux: http://crbug.com/163931 2210 // Linux: http://crbug.com/163931
2208 #define MAYBE_EnableKioskModeTest DISABLED_EnableKioskModeTest 2211 #define MAYBE_EnableKioskModeTest DISABLED_EnableKioskModeTest
2209 #else 2212 #else
2210 #define MAYBE_EnableKioskModeTest EnableKioskModeTest 2213 #define MAYBE_EnableKioskModeTest EnableKioskModeTest
2211 #endif 2214 #endif
2212 IN_PROC_BROWSER_TEST_F(KioskModeTest, MAYBE_EnableKioskModeTest) { 2215 IN_PROC_BROWSER_TEST_F(KioskModeTest, MAYBE_EnableKioskModeTest) {
2213 // Check if browser is in fullscreen mode. 2216 // Check if browser is in fullscreen mode.
2214 ASSERT_TRUE(browser()->window()->IsFullscreen()); 2217 ASSERT_TRUE(browser()->window()->IsFullscreen());
2215 ASSERT_FALSE(browser()->window()->IsFullscreenBubbleVisible()); 2218 ASSERT_FALSE(browser()->window()->IsFullscreenBubbleVisible());
2216 } 2219 }
2217 2220
2218 #if defined(OS_WIN) 2221 #if defined(OS_WIN)
2219 // This test verifies that Chrome can be launched with a user-data-dir path 2222 // This test verifies that Chrome can be launched with a user-data-dir path
2220 // which contains non ASCII characters. 2223 // which contains non ASCII characters.
2221 class LaunchBrowserWithNonAsciiUserDatadir : public BrowserTest { 2224 class LaunchBrowserWithNonAsciiUserDatadir : public BrowserTest {
2222 public: 2225 public:
2223 LaunchBrowserWithNonAsciiUserDatadir() {} 2226 LaunchBrowserWithNonAsciiUserDatadir() {}
2224 2227
2225 virtual void SetUpCommandLine(CommandLine* command_line) override { 2228 virtual void SetUpCommandLine(base::CommandLine* command_line) override {
2226 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 2229 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
2227 base::FilePath tmp_profile = temp_dir_.path().AppendASCII("tmp_profile"); 2230 base::FilePath tmp_profile = temp_dir_.path().AppendASCII("tmp_profile");
2228 tmp_profile = tmp_profile.Append(L"Test Chrome G\u00E9raldine"); 2231 tmp_profile = tmp_profile.Append(L"Test Chrome G\u00E9raldine");
2229 2232
2230 ASSERT_TRUE(base::CreateDirectory(tmp_profile)); 2233 ASSERT_TRUE(base::CreateDirectory(tmp_profile));
2231 command_line->AppendSwitchPath(switches::kUserDataDir, tmp_profile); 2234 command_line->AppendSwitchPath(switches::kUserDataDir, tmp_profile);
2232 } 2235 }
2233 2236
2234 base::ScopedTempDir temp_dir_; 2237 base::ScopedTempDir temp_dir_;
2235 }; 2238 };
2236 2239
2237 IN_PROC_BROWSER_TEST_F(LaunchBrowserWithNonAsciiUserDatadir, 2240 IN_PROC_BROWSER_TEST_F(LaunchBrowserWithNonAsciiUserDatadir,
2238 TestNonAsciiUserDataDir) { 2241 TestNonAsciiUserDataDir) {
2239 // Verify that the window is present. 2242 // Verify that the window is present.
2240 ASSERT_TRUE(browser()); 2243 ASSERT_TRUE(browser());
2241 } 2244 }
2242 #endif // defined(OS_WIN) 2245 #endif // defined(OS_WIN)
2243 2246
2244 // Tests to ensure that the browser continues running in the background after 2247 // Tests to ensure that the browser continues running in the background after
2245 // the last window closes. 2248 // the last window closes.
2246 class RunInBackgroundTest : public BrowserTest { 2249 class RunInBackgroundTest : public BrowserTest {
2247 public: 2250 public:
2248 RunInBackgroundTest() {} 2251 RunInBackgroundTest() {}
2249 2252
2250 void SetUpCommandLine(CommandLine* command_line) override { 2253 void SetUpCommandLine(base::CommandLine* command_line) override {
2251 command_line->AppendSwitch(switches::kKeepAliveForTest); 2254 command_line->AppendSwitch(switches::kKeepAliveForTest);
2252 } 2255 }
2253 }; 2256 };
2254 2257
2255 IN_PROC_BROWSER_TEST_F(RunInBackgroundTest, RunInBackgroundBasicTest) { 2258 IN_PROC_BROWSER_TEST_F(RunInBackgroundTest, RunInBackgroundBasicTest) {
2256 // Close the browser window, then open a new one - the browser should keep 2259 // Close the browser window, then open a new one - the browser should keep
2257 // running. 2260 // running.
2258 Profile* profile = browser()->profile(); 2261 Profile* profile = browser()->profile();
2259 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 2262 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
2260 content::WindowedNotificationObserver observer( 2263 content::WindowedNotificationObserver observer(
2261 chrome::NOTIFICATION_BROWSER_CLOSED, 2264 chrome::NOTIFICATION_BROWSER_CLOSED,
2262 content::Source<Browser>(browser())); 2265 content::Source<Browser>(browser()));
2263 chrome::CloseWindow(browser()); 2266 chrome::CloseWindow(browser());
2264 observer.Wait(); 2267 observer.Wait();
2265 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); 2268 EXPECT_EQ(0u, chrome::GetTotalBrowserCount());
2266 2269
2267 ui_test_utils::BrowserAddedObserver browser_added_observer; 2270 ui_test_utils::BrowserAddedObserver browser_added_observer;
2268 chrome::NewEmptyWindow(profile, chrome::GetActiveDesktop()); 2271 chrome::NewEmptyWindow(profile, chrome::GetActiveDesktop());
2269 browser_added_observer.WaitForSingleNewBrowser(); 2272 browser_added_observer.WaitForSingleNewBrowser();
2270 2273
2271 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 2274 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
2272 } 2275 }
2273 2276
2274 // Tests to ensure that the browser continues running in the background after 2277 // Tests to ensure that the browser continues running in the background after
2275 // the last window closes. 2278 // the last window closes.
2276 class NoStartupWindowTest : public BrowserTest { 2279 class NoStartupWindowTest : public BrowserTest {
2277 public: 2280 public:
2278 NoStartupWindowTest() {} 2281 NoStartupWindowTest() {}
2279 2282
2280 void SetUpCommandLine(CommandLine* command_line) override { 2283 void SetUpCommandLine(base::CommandLine* command_line) override {
2281 command_line->AppendSwitch(switches::kNoStartupWindow); 2284 command_line->AppendSwitch(switches::kNoStartupWindow);
2282 command_line->AppendSwitch(switches::kKeepAliveForTest); 2285 command_line->AppendSwitch(switches::kKeepAliveForTest);
2283 } 2286 }
2284 2287
2285 // Returns true if any commands were processed. 2288 // Returns true if any commands were processed.
2286 bool ProcessedAnyCommands( 2289 bool ProcessedAnyCommands(
2287 sessions::BaseSessionService* base_session_service) { 2290 sessions::BaseSessionService* base_session_service) {
2288 sessions::BaseSessionServiceTestHelper test_helper(base_session_service); 2291 sessions::BaseSessionServiceTestHelper test_helper(base_session_service);
2289 return test_helper.ProcessedAnyCommands(); 2292 return test_helper.ProcessedAnyCommands();
2290 } 2293 }
2291 }; 2294 };
2292 2295
2293 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, NoStartupWindowBasicTest) { 2296 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, NoStartupWindowBasicTest) {
2294 #if defined(OS_WIN) && defined(USE_ASH) 2297 #if defined(OS_WIN) && defined(USE_ASH)
2295 // kNoStartupWindow doesn't make sense in Metro+Ash. 2298 // kNoStartupWindow doesn't make sense in Metro+Ash.
2296 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 2299 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2300 switches::kAshBrowserTests))
2297 return; 2301 return;
2298 #endif 2302 #endif
2299 2303
2300 // No browser window should be started by default. 2304 // No browser window should be started by default.
2301 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); 2305 EXPECT_EQ(0u, chrome::GetTotalBrowserCount());
2302 2306
2303 // Starting a browser window should work just fine. 2307 // Starting a browser window should work just fine.
2304 ui_test_utils::BrowserAddedObserver browser_added_observer; 2308 ui_test_utils::BrowserAddedObserver browser_added_observer;
2305 CreateBrowser(ProfileManager::GetActiveUserProfile()); 2309 CreateBrowser(ProfileManager::GetActiveUserProfile());
2306 browser_added_observer.WaitForSingleNewBrowser(); 2310 browser_added_observer.WaitForSingleNewBrowser();
2307 2311
2308 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 2312 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
2309 } 2313 }
2310 2314
2311 // Chromeos needs to track app windows because it considers them to be part of 2315 // Chromeos needs to track app windows because it considers them to be part of
2312 // session state. 2316 // session state.
2313 #if !defined(OS_CHROMEOS) 2317 #if !defined(OS_CHROMEOS)
2314 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, DontInitSessionServiceForApps) { 2318 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, DontInitSessionServiceForApps) {
2315 #if defined(OS_WIN) && defined(USE_ASH) 2319 #if defined(OS_WIN) && defined(USE_ASH)
2316 // kNoStartupWindow doesn't make sense in Metro+Ash. 2320 // kNoStartupWindow doesn't make sense in Metro+Ash.
2317 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 2321 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2322 switches::kAshBrowserTests))
2318 return; 2323 return;
2319 #endif 2324 #endif
2320 2325
2321 Profile* profile = ProfileManager::GetActiveUserProfile(); 2326 Profile* profile = ProfileManager::GetActiveUserProfile();
2322 2327
2323 SessionService* session_service = 2328 SessionService* session_service =
2324 SessionServiceFactory::GetForProfile(profile); 2329 SessionServiceFactory::GetForProfile(profile);
2325 sessions::BaseSessionService* base_session_service = 2330 sessions::BaseSessionService* base_session_service =
2326 session_service->GetBaseSessionServiceForTest(); 2331 session_service->GetBaseSessionServiceForTest();
2327 ASSERT_FALSE(ProcessedAnyCommands(base_session_service)); 2332 ASSERT_FALSE(ProcessedAnyCommands(base_session_service));
2328 2333
2329 ui_test_utils::BrowserAddedObserver browser_added_observer; 2334 ui_test_utils::BrowserAddedObserver browser_added_observer;
2330 CreateBrowserForApp("blah", profile); 2335 CreateBrowserForApp("blah", profile);
2331 browser_added_observer.WaitForSingleNewBrowser(); 2336 browser_added_observer.WaitForSingleNewBrowser();
2332 2337
2333 ASSERT_FALSE(ProcessedAnyCommands(base_session_service)); 2338 ASSERT_FALSE(ProcessedAnyCommands(base_session_service));
2334 } 2339 }
2335 #endif // !defined(OS_CHROMEOS) 2340 #endif // !defined(OS_CHROMEOS)
2336 2341
2337 // This test needs to be placed outside the anonymous namespace because we 2342 // This test needs to be placed outside the anonymous namespace because we
2338 // need to access private type of Browser. 2343 // need to access private type of Browser.
2339 class AppModeTest : public BrowserTest { 2344 class AppModeTest : public BrowserTest {
2340 public: 2345 public:
2341 AppModeTest() {} 2346 AppModeTest() {}
2342 2347
2343 void SetUpCommandLine(CommandLine* command_line) override { 2348 void SetUpCommandLine(base::CommandLine* command_line) override {
2344 GURL url = ui_test_utils::GetTestUrl( 2349 GURL url = ui_test_utils::GetTestUrl(
2345 base::FilePath(), base::FilePath().AppendASCII("title1.html")); 2350 base::FilePath(), base::FilePath().AppendASCII("title1.html"));
2346 command_line->AppendSwitchASCII(switches::kApp, url.spec()); 2351 command_line->AppendSwitchASCII(switches::kApp, url.spec());
2347 } 2352 }
2348 }; 2353 };
2349 2354
2350 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { 2355 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) {
2351 #if defined(OS_WIN) && defined(USE_ASH) 2356 #if defined(OS_WIN) && defined(USE_ASH)
2352 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 2357 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
2353 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 2358 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2359 switches::kAshBrowserTests))
2354 return; 2360 return;
2355 #endif 2361 #endif
2356 2362
2357 // Test that an application browser window loads correctly. 2363 // Test that an application browser window loads correctly.
2358 2364
2359 // Verify the browser is in application mode. 2365 // Verify the browser is in application mode.
2360 EXPECT_TRUE(browser()->is_app()); 2366 EXPECT_TRUE(browser()->is_app());
2361 } 2367 }
2362 2368
2363 // Confirm chrome://version contains some expected content. 2369 // Confirm chrome://version contains some expected content.
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2725 #endif 2731 #endif
2726 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2732 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2727 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2733 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2728 gfx::Size exp_final_size(initial_wcv_size); 2734 gfx::Size exp_final_size(initial_wcv_size);
2729 exp_final_size.Enlarge(wcv_resize_insets.width(), 2735 exp_final_size.Enlarge(wcv_resize_insets.width(),
2730 wcv_resize_insets.height() + height_inset); 2736 wcv_resize_insets.height() + height_inset);
2731 EXPECT_EQ(exp_final_size, 2737 EXPECT_EQ(exp_final_size,
2732 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2738 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2733 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); 2739 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size());
2734 } 2740 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_command_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698