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

Side by Side Diff: chrome/browser/chrome_content_browser_client_browsertest.cc

Issue 2913343002: Start removing deprecated Options UI code (Closed)
Patch Set: thestig@ review Created 3 years, 6 months 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/chrome_content_browser_client.cc ('k') | chrome/browser/flag_descriptions.h » ('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 (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 "chrome/browser/chrome_content_browser_client.h"
6
5 #include "base/command_line.h" 7 #include "base/command_line.h"
6 #include "base/macros.h" 8 #include "base/macros.h"
7 #include "base/test/scoped_feature_list.h"
8 #include "build/build_config.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/chrome_features.h"
13 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
18 #include "components/prefs/pref_service.h"
19 #include "content/public/browser/navigation_controller.h" 14 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 15 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/browser_test_utils.h" 17 #include "content/public/test/browser_test_utils.h"
23 #include "net/test/embedded_test_server/embedded_test_server.h" 18 #include "net/test/embedded_test_server/embedded_test_server.h"
24 #include "url/gurl.h" 19 #include "url/gurl.h"
25 20
26 namespace content { 21 namespace content {
27 22
23 // Use a test class with SetUpCommandLine to ensure the flag is sent to the
24 // first renderer process.
28 class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest { 25 class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest {
29 public: 26 public:
30 // Returns the last committed navigation entry of the first tab. May be NULL 27 ChromeContentBrowserClientBrowserTest() {}
31 // if there is no such entry.
32 NavigationEntry* GetLastCommittedEntry() {
33 return browser()->tab_strip_model()->GetWebContentsAt(0)->
34 GetController().GetLastCommittedEntry();
35 }
36
37 void SetUpInProcessBrowserTestFixture() override {
38 disable_md_settings_.InitAndDisableFeature(
39 features::kMaterialDesignSettings);
40 }
41
42 #if defined(OS_CHROMEOS)
43 void SetUpCommandLine(base::CommandLine* command_line) override {
44 command_line->AppendSwitch(switches::kDisableSettingsWindow);
45 }
46 #endif
47
48 private:
49 base::test::ScopedFeatureList disable_md_settings_;
50 };
51
52 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
53 UberURLHandler_SettingsPage) {
54 const GURL url_short("chrome://settings/");
55 const GURL url_long("chrome://chrome/settings/");
56
57 ui_test_utils::NavigateToURL(browser(), url_short);
58 NavigationEntry* entry = GetLastCommittedEntry();
59
60 ASSERT_TRUE(entry != NULL);
61 EXPECT_EQ(url_long, entry->GetURL());
62 EXPECT_EQ(url_short, entry->GetVirtualURL());
63 }
64
65 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
66 UberURLHandler_ContentSettingsPage) {
67 const GURL url_short("chrome://settings/content");
68 const GURL url_long("chrome://chrome/settings/content");
69
70 ui_test_utils::NavigateToURL(browser(), url_short);
71 NavigationEntry* entry = GetLastCommittedEntry();
72
73 ASSERT_TRUE(entry != NULL);
74 EXPECT_EQ(url_long, entry->GetURL());
75 EXPECT_EQ(url_short, entry->GetVirtualURL());
76 }
77
78 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
79 UberURLHandler_AboutPage) {
80 const GURL url("chrome://chrome/");
81
82 ui_test_utils::NavigateToURL(browser(), url);
83 NavigationEntry* entry = GetLastCommittedEntry();
84
85 ASSERT_TRUE(entry != NULL);
86 EXPECT_EQ(url, entry->GetURL());
87 EXPECT_EQ(url, entry->GetVirtualURL());
88 }
89
90 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
91 UberURLHandler_NewTabPageOverride) {
92 PrefService* prefs = browser()->profile()->GetPrefs();
93 static const char kOverrideUrl[] = "http://override.com";
94 prefs->SetString(prefs::kNewTabPageLocationOverride, kOverrideUrl);
95 const GURL ntp_url(chrome::kChromeUINewTabURL);
96
97 ui_test_utils::NavigateToURL(browser(), ntp_url);
98 NavigationEntry* entry = GetLastCommittedEntry();
99
100 ASSERT_TRUE(entry != NULL);
101 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
102 EXPECT_EQ(GURL(kOverrideUrl), entry->GetVirtualURL());
103
104 prefs->SetString(prefs::kNewTabPageLocationOverride, "");
105
106 ui_test_utils::NavigateToURL(browser(), ntp_url);
107 entry = GetLastCommittedEntry();
108
109 ASSERT_TRUE(entry != NULL);
110 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
111 EXPECT_EQ(ntp_url, entry->GetVirtualURL());
112 }
113
114 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
115 UberURLHandler_EmptyHost) {
116 const GURL url("chrome://chrome//foo");
117
118 ui_test_utils::NavigateToURL(browser(), url);
119 NavigationEntry* entry = GetLastCommittedEntry();
120
121 ASSERT_TRUE(entry != NULL);
122 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
123 EXPECT_EQ(url, entry->GetVirtualURL());
124 }
125
126 // Use a test class with SetUpCommandLine to ensure the flag is sent to the
127 // first renderer process.
128 class ChromeContentBrowserClientSitePerProcessTest
129 : public ChromeContentBrowserClientBrowserTest {
130 public:
131 ChromeContentBrowserClientSitePerProcessTest() {}
132 28
133 void SetUpCommandLine(base::CommandLine* command_line) override { 29 void SetUpCommandLine(base::CommandLine* command_line) override {
134 content::IsolateAllSitesForTesting(command_line); 30 IsolateAllSitesForTesting(command_line);
135 } 31 }
136 32
137 private: 33 private:
138 DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClientSitePerProcessTest); 34 DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClientBrowserTest);
139 }; 35 };
140 36
141 // Test that a basic navigation works in --site-per-process mode. This prevents 37 // Test that a basic navigation works in --site-per-process mode. This prevents
142 // regressions when that mode calls out into the ChromeContentBrowserClient, 38 // regressions when that mode calls out into the ChromeContentBrowserClient,
143 // such as http://crbug.com/164223. 39 // such as http://crbug.com/164223.
144 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientSitePerProcessTest, 40 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
145 SitePerProcessNavigation) { 41 SitePerProcessNavigation) {
146 ASSERT_TRUE(embedded_test_server()->Start()); 42 ASSERT_TRUE(embedded_test_server()->Start());
147 const GURL url(embedded_test_server()->GetURL("/title1.html")); 43 const GURL url(embedded_test_server()->GetURL("/title1.html"));
148 44
149 ui_test_utils::NavigateToURL(browser(), url); 45 ui_test_utils::NavigateToURL(browser(), url);
150 NavigationEntry* entry = GetLastCommittedEntry(); 46 NavigationEntry* entry = browser()
47 ->tab_strip_model()
48 ->GetWebContentsAt(0)
49 ->GetController()
50 .GetLastCommittedEntry();
151 51
152 ASSERT_TRUE(entry != NULL); 52 ASSERT_TRUE(entry != NULL);
153 EXPECT_EQ(url, entry->GetURL()); 53 EXPECT_EQ(url, entry->GetURL());
154 EXPECT_EQ(url, entry->GetVirtualURL()); 54 EXPECT_EQ(url, entry->GetVirtualURL());
155 } 55 }
156 56
157 } // namespace content 57 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/flag_descriptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698