diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-16 11:09:12 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-16 11:09:12 +0000 |
commit | cb0236a6ee8f3c14458915b1036171a2753e39e3 (patch) | |
tree | ec50b66f671c1a7952fbdfd96eb5695f1b2a87e3 /chrome/browser/autocomplete | |
parent | a9c34625781f0db43216cc333e1922cfb6d7958c (diff) | |
download | chromium_src-cb0236a6ee8f3c14458915b1036171a2753e39e3.zip chromium_src-cb0236a6ee8f3c14458915b1036171a2753e39e3.tar.gz chromium_src-cb0236a6ee8f3c14458915b1036171a2753e39e3.tar.bz2 |
Platform cleanup in autocomplete unit tests.
Review URL: http://codereview.chromium.org/21353
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9853 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r-- | chrome/browser/autocomplete/history_contents_provider_unittest.cc | 18 | ||||
-rw-r--r-- | chrome/browser/autocomplete/history_url_provider_unittest.cc | 68 |
2 files changed, 43 insertions, 43 deletions
diff --git a/chrome/browser/autocomplete/history_contents_provider_unittest.cc b/chrome/browser/autocomplete/history_contents_provider_unittest.cc index 4c3009e..459230a 100644 --- a/chrome/browser/autocomplete/history_contents_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_contents_provider_unittest.cc @@ -56,7 +56,7 @@ class HistoryContentsProviderTest : public testing::Test, profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); // Populate history. - for (int i = 0; i < arraysize(test_entries); i++) { + for (size_t i = 0; i < arraysize(test_entries); i++) { // We need the ID scope and page ID so that the visit tracker can find it. // We just use the index for the page ID below. const void* id_scope = reinterpret_cast<void*>(1); @@ -102,7 +102,7 @@ TEST_F(HistoryContentsProviderTest, Body) { // The results should be the first two pages, in decreasing order. const ACMatches& m = matches(); - ASSERT_EQ(2, m.size()); + ASSERT_EQ(2U, m.size()); EXPECT_EQ(test_entries[1].url, m[0].destination_url.spec()); EXPECT_STREQ(test_entries[1].title, m[0].description.c_str()); EXPECT_EQ(test_entries[0].url, m[1].destination_url.spec()); @@ -115,7 +115,7 @@ TEST_F(HistoryContentsProviderTest, Title) { // The results should be the first two pages. const ACMatches& m = matches(); - ASSERT_EQ(2, m.size()); + ASSERT_EQ(2U, m.size()); EXPECT_EQ(test_entries[1].url, m[0].destination_url.spec()); EXPECT_STREQ(test_entries[1].title, m[0].description.c_str()); EXPECT_EQ(test_entries[0].url, m[1].destination_url.spec()); @@ -129,19 +129,19 @@ TEST_F(HistoryContentsProviderTest, MinimalChanges) { AutocompleteInput sync_input(L"PAGEONE", std::wstring(), true, false, true); RunQuery(sync_input, true); const ACMatches& m1 = matches(); - EXPECT_EQ(0, m1.size()); + EXPECT_EQ(0U, m1.size()); // Now do a "regular" query to get the results. AutocompleteInput async_input(L"PAGEONE", std::wstring(), true, false, false); RunQuery(async_input, false); const ACMatches& m2 = matches(); - EXPECT_EQ(2, m2.size()); + EXPECT_EQ(2U, m2.size()); // Now do a minimal one where we want synchronous results, and the results // should still be there. RunQuery(sync_input, true); const ACMatches& m3 = matches(); - EXPECT_EQ(2, m3.size()); + EXPECT_EQ(2U, m3.size()); } // Tests that the BookmarkModel is queried correctly. @@ -157,7 +157,7 @@ TEST_F(HistoryContentsProviderTest, Bookmarks) { AutocompleteInput sync_input(L"bar", std::wstring(), true, false, true); RunQuery(sync_input, false); const ACMatches& m1 = matches(); - ASSERT_EQ(1, m1.size()); + ASSERT_EQ(1U, m1.size()); EXPECT_EQ(bookmark_url, m1[0].destination_url); EXPECT_EQ(L"bar", m1[0].description); EXPECT_TRUE(m1[0].starred); @@ -166,7 +166,7 @@ TEST_F(HistoryContentsProviderTest, Bookmarks) { AutocompleteInput async_input(L"bar", std::wstring(), true, false, false); provider()->Start(async_input, false); const ACMatches& m2 = matches(); - ASSERT_EQ(1, m2.size()); + ASSERT_EQ(1U, m2.size()); EXPECT_EQ(bookmark_url, m2[0].destination_url); // Run the message loop (needed for async history results). @@ -174,7 +174,7 @@ TEST_F(HistoryContentsProviderTest, Bookmarks) { // We should two urls now, bookmark_url and http://www.google.com/3. const ACMatches& m3 = matches(); - ASSERT_EQ(2, m3.size()); + ASSERT_EQ(2U, m3.size()); if (bookmark_url == m3[0].destination_url) { EXPECT_EQ("http://www.google.com/3", m3[1].destination_url.spec()); } else { diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc index 70602ee..6f12cc9 100644 --- a/chrome/browser/autocomplete/history_url_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc @@ -16,7 +16,7 @@ using base::Time; using base::TimeDelta; struct TestURLInfo { - std::wstring url; + std::string url; std::wstring title; int visit_count; int typed_count; @@ -25,60 +25,60 @@ struct TestURLInfo { // Contents of the test database. static TestURLInfo test_db[] = { - {L"http://www.google.com/", L"Google", 3, 3, false}, + {"http://www.google.com/", L"Google", 3, 3, false}, // High-quality pages should get a host synthesized as a lower-quality match. - {L"http://slashdot.org/favorite_page.html", L"Favorite page", 200, 100, + {"http://slashdot.org/favorite_page.html", L"Favorite page", 200, 100, false}, // Less popular pages should have hosts synthesized as higher-quality // matches. - {L"http://kerneltrap.org/not_very_popular.html", L"Less popular", 4, 0, + {"http://kerneltrap.org/not_very_popular.html", L"Less popular", 4, 0, false}, // Unpopular pages should not appear in the results at all. - {L"http://freshmeat.net/unpopular.html", L"Unpopular", 1, 1, false}, + {"http://freshmeat.net/unpopular.html", L"Unpopular", 1, 1, false}, // If a host has a match, we should pick it up during host synthesis. - {L"http://news.google.com/?ned=us&topic=n", L"Google News - U.S.", 2, 2, + {"http://news.google.com/?ned=us&topic=n", L"Google News - U.S.", 2, 2, false}, - {L"http://news.google.com/", L"Google News", 1, 1, false}, + {"http://news.google.com/", L"Google News", 1, 1, false}, // Suggested short URLs must be "good enough" and must match user input. - {L"http://foo.com/", L"Dir", 5, 5, false}, - {L"http://foo.com/dir/", L"Dir", 2, 2, false}, - {L"http://foo.com/dir/another/", L"Dir", 5, 1, false}, - {L"http://foo.com/dir/another/again/", L"Dir", 10, 0, false}, - {L"http://foo.com/dir/another/again/myfile.html", L"File", 10, 2, false}, + {"http://foo.com/", L"Dir", 5, 5, false}, + {"http://foo.com/dir/", L"Dir", 2, 2, false}, + {"http://foo.com/dir/another/", L"Dir", 5, 1, false}, + {"http://foo.com/dir/another/again/", L"Dir", 10, 0, false}, + {"http://foo.com/dir/another/again/myfile.html", L"File", 10, 2, false}, // Starred state is more important than visit count (but less important than // typed count) when sorting URLs. The order in which the URLs were starred // shouldn't matter. // We throw in a lot of extra URLs here to make sure we're testing the // history database's query, not just the autocomplete provider. - {L"http://startest.com/y/a", L"A", 2, 2, true}, - {L"http://startest.com/y/b", L"B", 5, 2, false}, - {L"http://startest.com/x/c", L"C", 5, 2, true}, - {L"http://startest.com/x/d", L"D", 5, 5, false}, - {L"http://startest.com/y/e", L"E", 4, 2, false}, - {L"http://startest.com/y/f", L"F", 3, 2, false}, - {L"http://startest.com/y/g", L"G", 3, 2, false}, - {L"http://startest.com/y/h", L"H", 3, 2, false}, - {L"http://startest.com/y/i", L"I", 3, 2, false}, - {L"http://startest.com/y/j", L"J", 3, 2, false}, - {L"http://startest.com/y/k", L"K", 3, 2, false}, - {L"http://startest.com/y/l", L"L", 3, 2, false}, - {L"http://startest.com/y/m", L"M", 3, 2, false}, + {"http://startest.com/y/a", L"A", 2, 2, true}, + {"http://startest.com/y/b", L"B", 5, 2, false}, + {"http://startest.com/x/c", L"C", 5, 2, true}, + {"http://startest.com/x/d", L"D", 5, 5, false}, + {"http://startest.com/y/e", L"E", 4, 2, false}, + {"http://startest.com/y/f", L"F", 3, 2, false}, + {"http://startest.com/y/g", L"G", 3, 2, false}, + {"http://startest.com/y/h", L"H", 3, 2, false}, + {"http://startest.com/y/i", L"I", 3, 2, false}, + {"http://startest.com/y/j", L"J", 3, 2, false}, + {"http://startest.com/y/k", L"K", 3, 2, false}, + {"http://startest.com/y/l", L"L", 3, 2, false}, + {"http://startest.com/y/m", L"M", 3, 2, false}, // A file: URL is useful for testing that fixup does the right thing w.r.t. // the number of trailing slashes on the user's input. - {L"file:///C:/foo.txt", L"", 2, 2, false}, + {"file:///C:/foo.txt", L"", 2, 2, false}, // Results with absurdly high typed_counts so that very generic queries like // "http" will give consistent results even if more data is added above. - {L"http://bogussite.com/a", L"Bogus A", 10002, 10000, false}, - {L"http://bogussite.com/b", L"Bogus B", 10001, 10000, false}, - {L"http://bogussite.com/c", L"Bogus C", 10000, 10000, false}, + {"http://bogussite.com/a", L"Bogus A", 10002, 10000, false}, + {"http://bogussite.com/b", L"Bogus B", 10001, 10000, false}, + {"http://bogussite.com/c", L"Bogus C", 10000, 10000, false}, }; class HistoryURLProviderTest : public testing::Test, @@ -100,7 +100,7 @@ class HistoryURLProviderTest : public testing::Test, const std::wstring& desired_tld, bool prevent_inline_autocomplete, const std::string* expected_urls, - int num_results); + size_t num_results); MessageLoopForUI message_loop_; ACMatches matches_; @@ -141,7 +141,7 @@ void HistoryURLProviderTest::FillData() { // case the time would be specifed in the test_db structure. Time visit_time = Time::Now() - TimeDelta::FromDays(80); - for (int i = 0; i < arraysize(test_db); ++i) { + for (size_t i = 0; i < arraysize(test_db); ++i) { const TestURLInfo& cur = test_db[i]; const GURL current_url(cur.url); history_service_->AddPageWithDetails(current_url, cur.title, @@ -158,7 +158,7 @@ void HistoryURLProviderTest::RunTest(const std::wstring text, const std::wstring& desired_tld, bool prevent_inline_autocomplete, const std::string* expected_urls, - int num_results) { + size_t num_results) { AutocompleteInput input(text, desired_tld, prevent_inline_autocomplete, false, false); autocomplete_->Start(input, false); @@ -167,7 +167,7 @@ void HistoryURLProviderTest::RunTest(const std::wstring text, matches_ = autocomplete_->matches(); ASSERT_EQ(num_results, matches_.size()); - for (int i = 0; i < num_results; ++i) + for (size_t i = 0; i < num_results; ++i) EXPECT_EQ(expected_urls[i], matches_[i].destination_url.spec()); } @@ -288,7 +288,7 @@ TEST_F(HistoryURLProviderTest, CullRedirects) { {"http://redirects/B", 20}, {"http://redirects/C", 10} }; - for (int i = 0; i < arraysize(redirect); i++) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(redirect); i++) { history_service_->AddPageWithDetails(GURL(redirect[i].url), L"Title", redirect[i].count, redirect[i].count, Time::Now(), false); |