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

Unified Diff: chrome/browser/ui/toolbar/toolbar_model_unittest.cc

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More test fixes. Created 7 years, 3 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
Index: chrome/browser/ui/toolbar/toolbar_model_unittest.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc
index 8680fe440ddc5f57cc15496f409d08a1bd8184bb..f173e3ebd41e9aec8d9f92d6b31b5482fb42cf26 100644
--- a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc
@@ -33,6 +33,7 @@ namespace {
struct TestItem {
GURL url;
+ std::string template_search_url;
Peter Kasting 2013/10/01 00:41:30 How many cases below will pass if we use "{google:
samarth 2013/10/02 00:18:00 Actually this override is only really needed for t
string16 expected_text;
// The expected text to display when query extraction is inactive.
string16 expected_replace_text_inactive;
@@ -43,6 +44,7 @@ struct TestItem {
} test_items[] = {
{
GURL("view-source:http://www.google.com"),
+ "view-source:http://www.google.com",
ASCIIToUTF16("view-source:www.google.com"),
ASCIIToUTF16("view-source:www.google.com"),
ASCIIToUTF16("view-source:www.google.com"),
@@ -51,6 +53,7 @@ struct TestItem {
},
{
GURL("view-source:chrome://newtab/"),
+ "view-source:chrome://newtab/",
ASCIIToUTF16("view-source:chrome://newtab"),
ASCIIToUTF16("view-source:chrome://newtab"),
ASCIIToUTF16("view-source:chrome://newtab"),
@@ -59,6 +62,7 @@ struct TestItem {
},
{
GURL("chrome-extension://monkey/balls.html"),
+ "chrome-extension://monkey/balls.html",
ASCIIToUTF16("chrome-extension://monkey/balls.html"),
ASCIIToUTF16("chrome-extension://monkey/balls.html"),
ASCIIToUTF16("chrome-extension://monkey/balls.html"),
@@ -67,6 +71,7 @@ struct TestItem {
},
{
GURL("chrome://newtab/"),
+ "chrome://newtab/",
string16(),
string16(),
string16(),
@@ -75,6 +80,7 @@ struct TestItem {
},
{
GURL(content::kAboutBlankURL),
+ content::kAboutBlankURL,
ASCIIToUTF16(content::kAboutBlankURL),
ASCIIToUTF16(content::kAboutBlankURL),
ASCIIToUTF16(content::kAboutBlankURL),
@@ -83,6 +89,7 @@ struct TestItem {
},
{
GURL("http://searchurl/?q=tractor+supply"),
+ "http://searchurl/?q={searchTerms}",
ASCIIToUTF16("searchurl/?q=tractor+supply"),
ASCIIToUTF16("searchurl/?q=tractor+supply"),
ASCIIToUTF16("searchurl/?q=tractor+supply"),
@@ -91,6 +98,7 @@ struct TestItem {
},
{
GURL("http://google.com/search?q=tractor+supply&espv=1"),
+ "http://google.com/search?q={searchTerms}&espv=1",
ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
@@ -99,6 +107,7 @@ struct TestItem {
},
{
GURL("https://google.ca/search?q=tractor+supply"),
+ "https://google.ca/search?q={searchTerms}",
ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
@@ -107,6 +116,7 @@ struct TestItem {
},
{
GURL("https://google.com/search?q=tractor+supply"),
+ "https://google.com/search?q={searchTerms}",
ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
@@ -115,6 +125,7 @@ struct TestItem {
},
{
GURL("https://google.com/search?q=tractor+supply&espv=1"),
+ "https://google.com/search?q={searchTerms}&espv=1",
ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"),
ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"),
ASCIIToUTF16("tractor supply"),
@@ -123,6 +134,7 @@ struct TestItem {
},
{
GURL("https://google.com/search?q=tractorsupply.com&espv=1"),
+ "https://google.com/search?q={searchTerms}&espv=1",
ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"),
ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"),
ASCIIToUTF16("tractorsupply.com"),
@@ -131,6 +143,7 @@ struct TestItem {
},
{
GURL("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
+ "https://google.com/search?q={searchTerms}&espv=1",
ASCIIToUTF16("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
ASCIIToUTF16("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
ASCIIToUTF16("ftp://tractorsupply.ie"),
@@ -155,14 +168,16 @@ class ToolbarModelTest : public BrowserWithTestWindowTest {
protected:
void ResetDefaultTemplateURL();
void NavigateAndCheckText(const GURL& url,
+ const std::string& template_search_url,
const string16& expected_text,
const string16& expected_replace_text,
bool would_perform_search_term_replacement,
bool should_display_url);
private:
- void ResetTemplateURLForInstant(const GURL& instant_url);
+ void ResetTemplateURLForInstant(const std::string& template_search_url);
void NavigateAndCheckTextImpl(const GURL& url,
+ const std::string& template_search_url,
bool allow_search_term_replacement,
const string16 expected_text,
bool would_perform_search_term_replacement,
@@ -187,28 +202,31 @@ void ToolbarModelTest::SetUp() {
}
void ToolbarModelTest::ResetDefaultTemplateURL() {
- ResetTemplateURLForInstant(GURL("http://does/not/exist"));
+ ResetTemplateURLForInstant("http://does/not/exist");
}
void ToolbarModelTest::NavigateAndCheckText(
const GURL& url,
+ const std::string& template_search_url,
const string16& expected_text,
const string16& expected_replace_text,
bool would_perform_search_term_replacement,
bool should_display_url) {
- NavigateAndCheckTextImpl(url, false, expected_text,
+ NavigateAndCheckTextImpl(url, template_search_url, false, expected_text,
would_perform_search_term_replacement,
should_display_url);
- NavigateAndCheckTextImpl(url, true, expected_replace_text,
+ NavigateAndCheckTextImpl(url, template_search_url, true,
+ expected_replace_text,
would_perform_search_term_replacement,
should_display_url);
}
-void ToolbarModelTest::ResetTemplateURLForInstant(const GURL& instant_url) {
+void ToolbarModelTest::ResetTemplateURLForInstant(
+ const std::string& template_search_url) {
TemplateURLData data;
data.short_name = ASCIIToUTF16("Google");
- data.SetURL("{google:baseURL}search?q={searchTerms}");
- data.instant_url = instant_url.spec();
+ data.SetURL(template_search_url);
+ data.instant_url = "http://www.google.com/instant?strk=1";
data.search_terms_replacement_key = "{google:instantExtendedEnabledKey}";
TemplateURL* search_template_url = new TemplateURL(profile(), data);
TemplateURLService* template_url_service =
@@ -221,13 +239,14 @@ void ToolbarModelTest::ResetTemplateURLForInstant(const GURL& instant_url) {
void ToolbarModelTest::NavigateAndCheckTextImpl(
const GURL& url,
+ const std::string& template_search_url,
bool allow_search_term_replacement,
const string16 expected_text,
bool would_perform_search_term_replacement,
bool should_display_url) {
// The URL being navigated to should be treated as the Instant URL. Else
// there will be no search term extraction.
- ResetTemplateURLForInstant(url);
+ ResetTemplateURLForInstant(template_search_url);
// Check while loading.
content::NavigationController* controller =
@@ -278,19 +297,19 @@ TEST_F(ToolbarModelTest, ShouldDisplayURL) {
AddTab(browser(), GURL(content::kAboutBlankURL));
for (size_t i = 0; i < arraysize(test_items); ++i) {
const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url, test_item.expected_text,
+ NavigateAndCheckText(test_item.url, test_item.template_search_url,
+ test_item.expected_text,
test_item.expected_replace_text_inactive, false,
test_item.should_display_url);
}
- // Once we enable it, query extraction and search term replacement are
- // enabled by default.
- chrome::EnableInstantExtendedAPIForTesting();
+ chrome::EnableQueryExtractionForTesting();
EXPECT_TRUE(chrome::IsQueryExtractionEnabled());
EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled());
for (size_t i = 0; i < arraysize(test_items); ++i) {
const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url, test_item.expected_text,
+ NavigateAndCheckText(test_item.url, test_item.template_search_url,
+ test_item.expected_text,
test_item.expected_replace_text_active,
test_item.would_perform_search_term_replacement,
test_item.should_display_url);
@@ -300,7 +319,8 @@ TEST_F(ToolbarModelTest, ShouldDisplayURL) {
browser()->toolbar_model()->set_search_term_replacement_enabled(false);
for (size_t i = 0; i < arraysize(test_items); ++i) {
const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url, test_item.expected_text,
+ NavigateAndCheckText(test_item.url, test_item.template_search_url,
+ test_item.expected_text,
test_item.expected_replace_text_inactive, false,
test_item.should_display_url);
}
@@ -308,7 +328,7 @@ TEST_F(ToolbarModelTest, ShouldDisplayURL) {
// Verify that search terms are extracted while the page is loading.
TEST_F(ToolbarModelTest, SearchTermsWhileLoading) {
- chrome::EnableInstantExtendedAPIForTesting();
+ chrome::EnableQueryExtractionForTesting();
ResetDefaultTemplateURL();
AddTab(browser(), GURL(content::kAboutBlankURL));
@@ -335,7 +355,7 @@ TEST_F(ToolbarModelTest, SearchTermsWhileLoading) {
// search terms from URLs that start with that base URL even when they're not
// secure.
TEST_F(ToolbarModelTest, GoogleBaseURL) {
- chrome::EnableInstantExtendedAPIForTesting();
+ chrome::EnableQueryExtractionForTesting();
AddTab(browser(), GURL(content::kAboutBlankURL));
// If the Google base URL wasn't specified on the command line, then if it's
@@ -343,6 +363,7 @@ TEST_F(ToolbarModelTest, GoogleBaseURL) {
UIThreadSearchTermsData::SetGoogleBaseURL("http://www.foo.com/");
NavigateAndCheckText(
GURL("http://www.foo.com/search?q=tractor+supply&espv=1"),
+ "http://www.foo.com/search?q={queryTerms}&espv=1",
ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"),
ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"), false,
true);
@@ -354,6 +375,7 @@ TEST_F(ToolbarModelTest, GoogleBaseURL) {
"http://www.foo.com/");
NavigateAndCheckText(
GURL("http://www.foo.com/search?q=tractor+supply&espv=1"),
+ "http://www.foo.com/search?q={searchTerms}&espv=1",
ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"),
ASCIIToUTF16("tractor supply"), true, true);
}

Powered by Google App Engine
This is Rietveld 408576698