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

Unified Diff: chrome/browser/search_engines/template_url_service_unittest.cc

Issue 9968016: Move the URL string from TemplateURLRef onto the owning TemplateURL. This will make it easier to m… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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/search_engines/template_url_service_unittest.cc
===================================================================
--- chrome/browser/search_engines/template_url_service_unittest.cc (revision 129864)
+++ chrome/browser/search_engines/template_url_service_unittest.cc (working copy)
@@ -258,19 +258,17 @@
void TemplateURLServiceTest::AssertEquals(const TemplateURL& expected,
const TemplateURL& actual) {
- ASSERT_TRUE(TemplateURLRef::SameUrlRefs(expected.url(), actual.url()));
- ASSERT_TRUE(TemplateURLRef::SameUrlRefs(expected.suggestions_url(),
- actual.suggestions_url()));
+ ASSERT_EQ(expected.short_name(), actual.short_name());
+ ASSERT_EQ(expected.url(), actual.url());
+ ASSERT_EQ(expected.suggestions_url(), actual.suggestions_url());
ASSERT_EQ(expected.keyword(), actual.keyword());
- ASSERT_EQ(expected.short_name(), actual.short_name());
- ASSERT_EQ(JoinString(expected.input_encodings(), ';'),
- JoinString(actual.input_encodings(), ';'));
+ ASSERT_EQ(expected.show_in_default_list(), actual.show_in_default_list());
+ ASSERT_EQ(expected.safe_for_autoreplace(), actual.safe_for_autoreplace());
ASSERT_EQ(expected.favicon_url(), actual.favicon_url());
- ASSERT_EQ(expected.id(), actual.id());
- ASSERT_EQ(expected.safe_for_autoreplace(), actual.safe_for_autoreplace());
- ASSERT_EQ(expected.show_in_default_list(), actual.show_in_default_list());
ASSERT_EQ(expected.date_created(), actual.date_created());
ASSERT_EQ(expected.last_modified(), actual.last_modified());
+ ASSERT_EQ(expected.input_encodings(), actual.input_encodings());
+ ASSERT_EQ(expected.id(), actual.id());
ASSERT_EQ(expected.sync_guid(), actual.sync_guid());
}
@@ -278,16 +276,14 @@
const TemplateURL* actual) {
ASSERT_TRUE(expected != NULL);
ASSERT_TRUE(actual != NULL);
- EXPECT_TRUE(TemplateURLRef::SameUrlRefs(expected->url(), actual->url()));
- EXPECT_TRUE(TemplateURLRef::SameUrlRefs(expected->suggestions_url(),
- actual->suggestions_url()));
+ EXPECT_EQ(expected->short_name(), actual->short_name());
+ EXPECT_EQ(expected->url(), actual->url());
+ EXPECT_EQ(expected->suggestions_url(), actual->suggestions_url());
EXPECT_EQ(expected->keyword(), actual->keyword());
- EXPECT_EQ(expected->short_name(), actual->short_name());
- EXPECT_EQ(JoinString(expected->input_encodings(), ';'),
- JoinString(actual->input_encodings(), ';'));
+ EXPECT_EQ(expected->show_in_default_list(), actual->show_in_default_list());
+ EXPECT_EQ(expected->safe_for_autoreplace(), actual->safe_for_autoreplace());
EXPECT_EQ(expected->favicon_url(), actual->favicon_url());
- EXPECT_EQ(expected->safe_for_autoreplace(), actual->safe_for_autoreplace());
- EXPECT_EQ(expected->show_in_default_list(), actual->show_in_default_list());
+ EXPECT_EQ(expected->input_encodings(), actual->input_encodings());
}
void TemplateURLServiceTest::SetManagedDefaultSearchPreferences(
@@ -343,7 +339,7 @@
TemplateURL* t_url = CreatePreloadedTemplateURL(safe_for_autoreplace,
prepopulated_urls[prepopulated_index]->prepopulate_id());
*prepopulated_display_url =
- prepopulated_urls[prepopulated_index]->url()->DisplayURL();
+ prepopulated_urls[prepopulated_index]->url_ref().DisplayURL();
return t_url;
}
@@ -353,7 +349,7 @@
TemplateURL* t_url = CreateReplaceablePreloadedTemplateURL(false,
index_offset_from_default, &prepopulated_url);
- string16 original_url = t_url->url()->DisplayURL();
+ string16 original_url = t_url->url_ref().DisplayURL();
ASSERT_NE(prepopulated_url, original_url);
// Then add it to the model and save it all.
@@ -362,14 +358,14 @@
const TemplateURL* keyword_url =
model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest"));
ASSERT_EQ(t_url, keyword_url);
- ASSERT_EQ(original_url, keyword_url->url()->DisplayURL());
+ ASSERT_EQ(original_url, keyword_url->url_ref().DisplayURL());
test_util_.BlockTillServiceProcessesRequests();
// Now reload the model and verify that the merge updates the url.
test_util_.ResetModel(true);
keyword_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest"));
ASSERT_TRUE(keyword_url != NULL);
- ASSERT_EQ(prepopulated_url, keyword_url->url()->DisplayURL());
+ ASSERT_EQ(prepopulated_url, keyword_url->url_ref().DisplayURL());
// Wait for any saves to finish.
test_util_.BlockTillServiceProcessesRequests();
@@ -378,7 +374,7 @@
test_util_.ResetModel(true);
keyword_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest"));
ASSERT_TRUE(keyword_url != NULL);
- ASSERT_EQ(prepopulated_url, keyword_url->url()->DisplayURL());
+ ASSERT_EQ(prepopulated_url, keyword_url->url_ref().DisplayURL());
}
void TemplateURLServiceTest::VerifyObserverCount(int expected_changed_count) {
@@ -446,7 +442,7 @@
"c");
ASSERT_EQ(ASCIIToUTF16("a"), loaded_url->short_name());
ASSERT_EQ(ASCIIToUTF16("b"), loaded_url->keyword());
- ASSERT_EQ("c", loaded_url->url()->url());
+ ASSERT_EQ("c", loaded_url->url());
ASSERT_FALSE(loaded_url->safe_for_autoreplace());
ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("keyword"), GURL(),
NULL));
@@ -653,7 +649,7 @@
model()->ResetTemplateURL(t_url, new_short_name, new_keyword, new_url);
ASSERT_EQ(new_short_name, t_url->short_name());
ASSERT_EQ(new_keyword, t_url->keyword());
- ASSERT_EQ(new_url, t_url->url()->url());
+ ASSERT_EQ(new_url, t_url->url());
// Make sure the mappings in the model were updated.
ASSERT_EQ(t_url, model()->GetTemplateURLForKeyword(new_keyword));
@@ -738,7 +734,7 @@
// ResetTemplateURL marks the TemplateURL as unsafe to replace, so it should
// no longer be replaceable.
model()->ResetTemplateURL(t_url, t_url->short_name(), t_url->keyword(),
- t_url->url()->url());
+ t_url->url());
ASSERT_FALSE(model()->CanReplaceKeyword(ASCIIToUTF16("foo"),
GURL("http://foo2"), NULL));
@@ -759,7 +755,7 @@
// ResetTemplateURL marks the TemplateURL as unsafe to replace, so it should
// no longer be replaceable.
model()->ResetTemplateURL(t_url, t_url->short_name(), t_url->keyword(),
- t_url->url()->url());
+ t_url->url());
ASSERT_FALSE(model()->CanReplaceKeyword(ASCIIToUTF16("bar"),
GURL("http://foo.com"), NULL));
@@ -801,12 +797,9 @@
// value are persisted to prefs.
const TemplateURL* default_turl = model()->GetDefaultSearchProvider();
ASSERT_TRUE(default_turl);
- ASSERT_TRUE(default_turl->url());
- ASSERT_EQ("http://url", default_turl->url()->url());
- ASSERT_TRUE(default_turl->suggestions_url());
- ASSERT_EQ("http://url2", default_turl->suggestions_url()->url());
- ASSERT_TRUE(default_turl->instant_url());
- EXPECT_EQ("http://instant", default_turl->instant_url()->url());
+ ASSERT_EQ("http://url", default_turl->url());
+ ASSERT_EQ("http://url2", default_turl->suggestions_url());
+ EXPECT_EQ("http://instant", default_turl->instant_url());
ASSERT_EQ(ASCIIToUTF16("a"), default_turl->short_name());
ASSERT_EQ(id, default_turl->id());
@@ -924,7 +917,7 @@
"{google:baseURL}?q={searchTerms}", "http://sugg1", "http://icon1",
"UTF-8;UTF-16", "name", false, Time(), Time());
ASSERT_EQ(t_url, model()->GetTemplateURLForHost("google.com"));
- EXPECT_EQ("google.com", t_url->url()->GetHost());
+ EXPECT_EQ("google.com", t_url->url_ref().GetHost());
EXPECT_EQ(ASCIIToUTF16("google.com"), t_url->keyword());
// Change the Google base url.
@@ -935,9 +928,9 @@
// Make sure the host->TemplateURL map was updated appropriately.
ASSERT_EQ(t_url, model()->GetTemplateURLForHost("google.co.uk"));
EXPECT_TRUE(model()->GetTemplateURLForHost("google.com") == NULL);
- EXPECT_EQ("google.co.uk", t_url->url()->GetHost());
+ EXPECT_EQ("google.co.uk", t_url->url_ref().GetHost());
EXPECT_EQ(ASCIIToUTF16("google.co.uk"), t_url->keyword());
- EXPECT_EQ("http://google.co.uk/?q=x", t_url->url()->ReplaceSearchTerms(
+ EXPECT_EQ("http://google.co.uk/?q=x", t_url->url_ref().ReplaceSearchTerms(
ASCIIToUTF16("x"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
}
@@ -976,7 +969,7 @@
HistoryService* history =
test_util_.profile()->GetHistoryService(Profile::EXPLICIT_ACCESS);
history->AddPage(
- GURL(t_url->url()->ReplaceSearchTerms(ASCIIToUTF16("blah"),
+ GURL(t_url->url_ref().ReplaceSearchTerms(ASCIIToUTF16("blah"),
TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())),
NULL, 0, GURL(), content::PAGE_TRANSITION_KEYWORD,
history::RedirectList(), history::SOURCE_BROWSED, false);

Powered by Google App Engine
This is Rietveld 408576698