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

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

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused. Created 7 years, 1 month 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 | Annotate | Revision Log
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/metrics/field_trial.h"
7 #include "chrome/browser/search/search.h"
8 #include "chrome/browser/search_engines/template_url_service.h"
9 #include "chrome/browser/search_engines/template_url_service_factory.h"
10 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 7 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/chrome_switches.h" 8 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/navigation_controller.h" 11 #include "content/public/browser/navigation_controller.h"
16 #include "content/public/browser/navigation_entry.h" 12 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
19 #include "url/gurl.h" 15 #include "url/gurl.h"
20 16
21 namespace content { 17 namespace content {
22 18
23 class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest { 19 class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest {
24 public: 20 public:
25 // Returns the last committed navigation entry of the first tab. May be NULL 21 // Returns the last committed navigation entry of the first tab. May be NULL
26 // if there is no such entry. 22 // if there is no such entry.
27 NavigationEntry* GetLastCommittedEntry() { 23 NavigationEntry* GetLastCommittedEntry() {
28 return browser()->tab_strip_model()->GetWebContentsAt(0)-> 24 return browser()->tab_strip_model()->GetWebContentsAt(0)->
29 GetController().GetLastCommittedEntry(); 25 GetController().GetLastCommittedEntry();
30 } 26 }
31
32 void InstallTemplateURLWithNewTabPage(GURL new_tab_page_url) {
33 TemplateURLService* template_url_service =
34 TemplateURLServiceFactory::GetForProfile(browser()->profile());
35 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service);
36
37 TemplateURLData data;
38 data.SetURL("http://foo.com/url?bar={searchTerms}");
39 data.new_tab_url = new_tab_page_url.spec();
40 TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
41 // Takes ownership.
42 template_url_service->Add(template_url);
43 template_url_service->SetDefaultSearchProvider(template_url);
44 }
45 }; 27 };
46 28
47 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, 29 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
48 UberURLHandler_SettingsPage) { 30 UberURLHandler_SettingsPage) {
49 const GURL url_short("chrome://settings/"); 31 const GURL url_short("chrome://settings/");
50 const GURL url_long("chrome://chrome/settings/"); 32 const GURL url_long("chrome://chrome/settings/");
51 33
52 ui_test_utils::NavigateToURL(browser(), url_short); 34 ui_test_utils::NavigateToURL(browser(), url_short);
53 NavigationEntry* entry = GetLastCommittedEntry(); 35 NavigationEntry* entry = GetLastCommittedEntry();
54 36
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const GURL url("chrome://chrome//foo"); 69 const GURL url("chrome://chrome//foo");
88 70
89 ui_test_utils::NavigateToURL(browser(), url); 71 ui_test_utils::NavigateToURL(browser(), url);
90 NavigationEntry* entry = GetLastCommittedEntry(); 72 NavigationEntry* entry = GetLastCommittedEntry();
91 73
92 ASSERT_TRUE(entry != NULL); 74 ASSERT_TRUE(entry != NULL);
93 EXPECT_TRUE(entry->GetVirtualURL().is_valid()); 75 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
94 EXPECT_EQ(url, entry->GetVirtualURL()); 76 EXPECT_EQ(url, entry->GetVirtualURL());
95 } 77 }
96 78
97 class InstantNTPURLRewriteTest : public ChromeContentBrowserClientBrowserTest {
98 public:
99 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
100 // browsertest initially spins up a non-Instant renderer for about:blank.
101 // In a real browser, navigating this renderer to the Instant new tab page
102 // forks a new privileged Instant render process, but that warps
103 // browsertest's fragile little mind; it just never navigates. We aren't
104 // trying to test the process model here, so turn it off.
105 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kSingleProcess);
106 }
107 };
108
109 IN_PROC_BROWSER_TEST_F(InstantNTPURLRewriteTest,
110 UberURLHandler_InstantExtendedNewTabPage) {
111 const GURL url_original("chrome://newtab");
112 const GURL url_rewritten("https://example.com/newtab");
113 InstallTemplateURLWithNewTabPage(url_rewritten);
114 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
115 "Group1 use_cacheable_ntp:1"));
116 chrome::EnableInstantExtendedAPIForTesting();
117
118 ui_test_utils::NavigateToURL(browser(), url_original);
119 NavigationEntry* entry = GetLastCommittedEntry();
120
121 ASSERT_TRUE(entry != NULL);
122 EXPECT_EQ(url_rewritten, entry->GetURL());
123 EXPECT_EQ(url_original, entry->GetVirtualURL());
124 }
125
126 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
127 UberURLHandler_InstantExtendedNewTabPageDisabled) {
128 // Don't do the kSingleProcess shenanigans here (see the dual test) because
129 // otherwise RenderViewImpl crashes in a paranoid fit on startup.
130 const GURL url_original("chrome://newtab");
131 const GURL url_rewritten("https://example.com/newtab");
132 InstallTemplateURLWithNewTabPage(url_rewritten);
133 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
134 "Group1 use_cacheable_ntp:1"));
135 chrome::DisableInstantExtendedAPIForTesting();
136
137 ui_test_utils::NavigateToURL(browser(), url_original);
138 NavigationEntry* entry = GetLastCommittedEntry();
139
140 ASSERT_TRUE(entry != NULL);
141 EXPECT_EQ(url_original, entry->GetURL());
142 EXPECT_EQ(url_original, entry->GetVirtualURL());
143 }
144
145 // Test that a basic navigation works in --site-per-process mode. This prevents 79 // Test that a basic navigation works in --site-per-process mode. This prevents
146 // regressions when that mode calls out into the ChromeContentBrowserClient, 80 // regressions when that mode calls out into the ChromeContentBrowserClient,
147 // such as http://crbug.com/164223. 81 // such as http://crbug.com/164223.
148 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, 82 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
149 SitePerProcessNavigation) { 83 SitePerProcessNavigation) {
150 CommandLine::ForCurrentProcess()->AppendSwitch( 84 CommandLine::ForCurrentProcess()->AppendSwitch(
151 switches::kSitePerProcess); 85 switches::kSitePerProcess);
152 ASSERT_TRUE(test_server()->Start()); 86 ASSERT_TRUE(test_server()->Start());
153 const GURL url(test_server()->GetURL("files/title1.html")); 87 const GURL url(test_server()->GetURL("files/title1.html"));
154 88
155 ui_test_utils::NavigateToURL(browser(), url); 89 ui_test_utils::NavigateToURL(browser(), url);
156 NavigationEntry* entry = GetLastCommittedEntry(); 90 NavigationEntry* entry = GetLastCommittedEntry();
157 91
158 ASSERT_TRUE(entry != NULL); 92 ASSERT_TRUE(entry != NULL);
159 EXPECT_EQ(url, entry->GetURL()); 93 EXPECT_EQ(url, entry->GetURL());
160 EXPECT_EQ(url, entry->GetVirtualURL()); 94 EXPECT_EQ(url, entry->GetVirtualURL());
161 } 95 }
162 96
163 } // namespace content 97 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider_unittest.cc ('k') | chrome/browser/chrome_content_browser_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698