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

Unified Diff: chrome/browser/chrome_content_browser_client_browsertest.cc

Issue 22945004: InstantExtended: Add new_tab_url to TemplateURL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/search/search.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_content_browser_client_browsertest.cc
diff --git a/chrome/browser/chrome_content_browser_client_browsertest.cc b/chrome/browser/chrome_content_browser_client_browsertest.cc
index 9d4b494613cec8c4c71c011df639fa57c14023a4..46e9072b533297d7d9d9287d633eddf5e391de92 100644
--- a/chrome/browser/chrome_content_browser_client_browsertest.cc
+++ b/chrome/browser/chrome_content_browser_client_browsertest.cc
@@ -3,7 +3,10 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/metrics/field_trial.h"
#include "chrome/browser/search/search.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
@@ -25,6 +28,20 @@ class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest {
return browser()->tab_strip_model()->GetWebContentsAt(0)->
GetController().GetLastCommittedEntry();
}
+
+ void InstallTemplateURLWithNewTabPage(GURL new_tab_page_url) {
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(browser()->profile());
+ ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service);
+
+ TemplateURLData data;
+ data.SetURL("http://foo.com/url?bar={searchTerms}");
+ data.new_tab_url = new_tab_page_url.spec();
+ TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
+ // Takes ownership.
+ template_url_service->Add(template_url);
+ template_url_service->SetDefaultSearchProvider(template_url);
+ }
};
IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
@@ -81,8 +98,9 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
UberURLHandler_InstantExtendedNewTabPage) {
const GURL url_original("chrome://newtab");
const GURL url_rewritten("http://example.com/newtab");
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kInstantNewTabURL, url_rewritten.spec());
+ InstallTemplateURLWithNewTabPage(url_rewritten);
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
+ "Group1 use_cacheable_ntp:1"));
chrome::EnableInstantExtendedAPIForTesting();
ui_test_utils::NavigateToURL(browser(), url_original);
@@ -97,8 +115,10 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
UberURLHandler_InstantExtendedNewTabPageDisabled) {
const GURL url_original("chrome://newtab");
const GURL url_rewritten("http://example.com/newtab");
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kInstantNewTabURL, url_rewritten.spec());
+ InstallTemplateURLWithNewTabPage(url_rewritten);
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
+ "Group1 use_cacheable_ntp:1"));
+ chrome::DisableInstantExtendedAPIForTesting();
ui_test_utils::NavigateToURL(browser(), url_original);
NavigationEntry* entry = GetLastCommittedEntry();
« no previous file with comments | « no previous file | chrome/browser/search/search.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698