[cros new GAIA] Update GAIA card size
[chromium-blink-merge.git] / chrome / browser / chrome_content_browser_client_browsertest.cc
blob46bcbd6d12b01f83c2fac5389ee7e58c643fcfd8
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/tabs/tab_strip_model.h"
8 #include "chrome/common/chrome_switches.h"
9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/navigation_entry.h"
13 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/content_switches.h"
15 #include "url/gurl.h"
17 namespace content {
19 class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest {
20 public:
21 // Returns the last committed navigation entry of the first tab. May be NULL
22 // if there is no such entry.
23 NavigationEntry* GetLastCommittedEntry() {
24 return browser()->tab_strip_model()->GetWebContentsAt(0)->
25 GetController().GetLastCommittedEntry();
28 #if defined(OS_CHROMEOS)
29 void SetUpCommandLine(base::CommandLine* command_line) override {
30 command_line->AppendSwitch(switches::kDisableAboutInSettings);
32 #endif
35 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
36 UberURLHandler_SettingsPage) {
37 const GURL url_short("chrome://settings/");
38 const GURL url_long("chrome://chrome/settings/");
40 ui_test_utils::NavigateToURL(browser(), url_short);
41 NavigationEntry* entry = GetLastCommittedEntry();
43 ASSERT_TRUE(entry != NULL);
44 EXPECT_EQ(url_long, entry->GetURL());
45 EXPECT_EQ(url_short, entry->GetVirtualURL());
48 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
49 UberURLHandler_ContentSettingsPage) {
50 const GURL url_short("chrome://settings/content");
51 const GURL url_long("chrome://chrome/settings/content");
53 ui_test_utils::NavigateToURL(browser(), url_short);
54 NavigationEntry* entry = GetLastCommittedEntry();
56 ASSERT_TRUE(entry != NULL);
57 EXPECT_EQ(url_long, entry->GetURL());
58 EXPECT_EQ(url_short, entry->GetVirtualURL());
61 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
62 UberURLHandler_AboutPage) {
63 const GURL url("chrome://chrome/");
65 ui_test_utils::NavigateToURL(browser(), url);
66 NavigationEntry* entry = GetLastCommittedEntry();
68 ASSERT_TRUE(entry != NULL);
69 EXPECT_EQ(url, entry->GetURL());
70 EXPECT_EQ(url, entry->GetVirtualURL());
73 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
74 UberURLHandler_EmptyHost) {
75 const GURL url("chrome://chrome//foo");
77 ui_test_utils::NavigateToURL(browser(), url);
78 NavigationEntry* entry = GetLastCommittedEntry();
80 ASSERT_TRUE(entry != NULL);
81 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
82 EXPECT_EQ(url, entry->GetVirtualURL());
85 // Test that a basic navigation works in --site-per-process mode. This prevents
86 // regressions when that mode calls out into the ChromeContentBrowserClient,
87 // such as http://crbug.com/164223.
88 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
89 SitePerProcessNavigation) {
90 base::CommandLine::ForCurrentProcess()->AppendSwitch(
91 switches::kSitePerProcess);
92 ASSERT_TRUE(test_server()->Start());
93 const GURL url(test_server()->GetURL("files/title1.html"));
95 ui_test_utils::NavigateToURL(browser(), url);
96 NavigationEntry* entry = GetLastCommittedEntry();
98 ASSERT_TRUE(entry != NULL);
99 EXPECT_EQ(url, entry->GetURL());
100 EXPECT_EQ(url, entry->GetVirtualURL());
103 } // namespace content