Componentize AccountReconcilor.
[chromium-blink-merge.git] / chrome / browser / chrome_content_browser_client_browsertest.cc
blob31f0981cd38e15548f84cc41fa6c63da4831cd78
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();
29 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
30 UberURLHandler_SettingsPage) {
31 const GURL url_short("chrome://settings/");
32 const GURL url_long("chrome://chrome/settings/");
34 ui_test_utils::NavigateToURL(browser(), url_short);
35 NavigationEntry* entry = GetLastCommittedEntry();
37 ASSERT_TRUE(entry != NULL);
38 EXPECT_EQ(url_long, entry->GetURL());
39 EXPECT_EQ(url_short, entry->GetVirtualURL());
42 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
43 UberURLHandler_ContentSettingsPage) {
44 const GURL url_short("chrome://settings/content");
45 const GURL url_long("chrome://chrome/settings/content");
47 ui_test_utils::NavigateToURL(browser(), url_short);
48 NavigationEntry* entry = GetLastCommittedEntry();
50 ASSERT_TRUE(entry != NULL);
51 EXPECT_EQ(url_long, entry->GetURL());
52 EXPECT_EQ(url_short, entry->GetVirtualURL());
55 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
56 UberURLHandler_AboutPage) {
57 const GURL url("chrome://chrome/");
59 ui_test_utils::NavigateToURL(browser(), url);
60 NavigationEntry* entry = GetLastCommittedEntry();
62 ASSERT_TRUE(entry != NULL);
63 EXPECT_EQ(url, entry->GetURL());
64 EXPECT_EQ(url, entry->GetVirtualURL());
67 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
68 UberURLHandler_EmptyHost) {
69 const GURL url("chrome://chrome//foo");
71 ui_test_utils::NavigateToURL(browser(), url);
72 NavigationEntry* entry = GetLastCommittedEntry();
74 ASSERT_TRUE(entry != NULL);
75 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
76 EXPECT_EQ(url, entry->GetVirtualURL());
79 // Test that a basic navigation works in --site-per-process mode. This prevents
80 // regressions when that mode calls out into the ChromeContentBrowserClient,
81 // such as http://crbug.com/164223.
82 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
83 SitePerProcessNavigation) {
84 CommandLine::ForCurrentProcess()->AppendSwitch(
85 switches::kSitePerProcess);
86 ASSERT_TRUE(test_server()->Start());
87 const GURL url(test_server()->GetURL("files/title1.html"));
89 ui_test_utils::NavigateToURL(browser(), url);
90 NavigationEntry* entry = GetLastCommittedEntry();
92 ASSERT_TRUE(entry != NULL);
93 EXPECT_EQ(url, entry->GetURL());
94 EXPECT_EQ(url, entry->GetVirtualURL());
97 } // namespace content