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.
7 #include "base/command_line.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h"
12 #include "content/public/browser/navigation_controller.h"
13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/content_switches.h"
16 #include "googleurl/src/gurl.h"
20 class ChromeContentBrowserClientBrowserTest
: public InProcessBrowserTest
{
22 // Returns the last committed navigation entry of the first tab. May be NULL
23 // if there is no such entry.
24 NavigationEntry
* GetLastCommittedEntry() {
25 return browser()->tab_strip_model()->GetWebContentsAt(0)->
26 GetController().GetLastCommittedEntry();
30 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest
,
31 UberURLHandler_SettingsPage
) {
32 const GURL
url_short(std::string("chrome://settings/"));
33 const GURL
url_long(std::string("chrome://chrome/settings/"));
35 ui_test_utils::NavigateToURL(browser(), url_short
);
36 NavigationEntry
* entry
= GetLastCommittedEntry();
38 ASSERT_TRUE(entry
!= NULL
);
39 EXPECT_EQ(url_long
, entry
->GetURL());
40 EXPECT_EQ(url_short
, entry
->GetVirtualURL());
43 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest
,
44 UberURLHandler_ContentSettingsPage
) {
45 const GURL
url_short(std::string("chrome://settings/content"));
46 const GURL
url_long(std::string("chrome://chrome/settings/content"));
48 ui_test_utils::NavigateToURL(browser(), url_short
);
49 NavigationEntry
* entry
= GetLastCommittedEntry();
51 ASSERT_TRUE(entry
!= NULL
);
52 EXPECT_EQ(url_long
, entry
->GetURL());
53 EXPECT_EQ(url_short
, entry
->GetVirtualURL());
56 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest
,
57 UberURLHandler_AboutPage
) {
58 const GURL
url(std::string("chrome://chrome/"));
60 ui_test_utils::NavigateToURL(browser(), url
);
61 NavigationEntry
* entry
= GetLastCommittedEntry();
63 ASSERT_TRUE(entry
!= NULL
);
64 EXPECT_EQ(url
, entry
->GetURL());
65 EXPECT_EQ(url
, entry
->GetVirtualURL());
68 // Test that a basic navigation works in --site-per-process mode. This prevents
69 // regressions when that mode calls out into the ChromeContentBrowserClient,
70 // such as http://crbug.com/164223.
71 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest
,
72 SitePerProcessNavigation
) {
73 CommandLine::ForCurrentProcess()->AppendSwitch(
74 switches::kSitePerProcess
);
75 ASSERT_TRUE(test_server()->Start());
76 const GURL
url(test_server()->GetURL("files/title1.html"));
78 ui_test_utils::NavigateToURL(browser(), url
);
79 NavigationEntry
* entry
= GetLastCommittedEntry();
81 ASSERT_TRUE(entry
!= NULL
);
82 EXPECT_EQ(url
, entry
->GetURL());
83 EXPECT_EQ(url
, entry
->GetVirtualURL());
86 } // namespace content