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

Side by Side Diff: chrome/browser/autocomplete/history_url_provider_unittest.cc

Issue 7618028: Tweak typed-count Usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
11 #include "chrome/browser/autocomplete/history_quick_provider.h"
11 #include "chrome/browser/autocomplete/history_url_provider.h" 12 #include "chrome/browser/autocomplete/history_url_provider.h"
12 #include "chrome/browser/history/history.h" 13 #include "chrome/browser/history/history.h"
13 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_browser_process_test.h" 15 #include "chrome/test/base/testing_browser_process_test.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 using base::Time; 20 using base::Time;
20 using base::TimeDelta; 21 using base::TimeDelta;
21 22
22 struct TestURLInfo { 23 struct TestURLInfo {
23 std::string url; 24 std::string url;
24 std::string title; 25 std::string title;
25 int visit_count; 26 int visit_count;
26 int typed_count; 27 int typed_count;
27 } test_db[] = { 28 } test_db[] = {
28 {"http://www.google.com/", "Google", 3, 3}, 29 {"http://www.google.com/", "Google", 3, 3},
29 30
30 // High-quality pages should get a host synthesized as a lower-quality match. 31 // High-quality pages should get a host synthesized as a lower-quality match.
31 {"http://slashdot.org/favorite_page.html", "Favorite page", 200, 100}, 32 {"http://slashdot.org/favorite_page.html", "Favorite page", 200, 100},
32 33
33 // Less popular pages should have hosts synthesized as higher-quality 34 // Less popular pages should have hosts synthesized as higher-quality
34 // matches. 35 // matches.
35 {"http://kerneltrap.org/not_very_popular.html", "Less popular", 4, 0}, 36 {"http://kerneltrap.org/not_very_popular.html", "Less popular", 4, 0},
36 37
37 // Unpopular pages should not appear in the results at all. 38 // Unpopular pages should not appear in the results at all.
38 {"http://freshmeat.net/unpopular.html", "Unpopular", 1, 1}, 39 {"http://freshmeat.net/unpopular.html", "Unpopular", 1, 0},
39 40
40 // If a host has a match, we should pick it up during host synthesis. 41 // If a host has a match, we should pick it up during host synthesis.
41 {"http://news.google.com/?ned=us&topic=n", "Google News - U.S.", 2, 2}, 42 {"http://news.google.com/?ned=us&topic=n", "Google News - U.S.", 2, 2},
42 {"http://news.google.com/", "Google News", 1, 1}, 43 {"http://news.google.com/", "Google News", 1, 1},
43 44
44 // Suggested short URLs must be "good enough" and must match user input. 45 // Suggested short URLs must be "good enough" and must match user input.
45 {"http://foo.com/", "Dir", 5, 5}, 46 {"http://foo.com/", "Dir", 5, 5},
46 {"http://foo.com/dir/", "Dir", 2, 2}, 47 {"http://foo.com/dir/", "Dir", 2, 2},
47 {"http://foo.com/dir/another/", "Dir", 5, 1}, 48 {"http://foo.com/dir/another/", "Dir", 5, 1},
48 {"http://foo.com/dir/another/again/", "Dir", 10, 0}, 49 {"http://foo.com/dir/another/again/", "Dir", 10, 0},
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 SetUpImpl(true); 145 SetUpImpl(true);
145 } 146 }
146 }; 147 };
147 148
148 void HistoryURLProviderTest::OnProviderUpdate(bool updated_matches) { 149 void HistoryURLProviderTest::OnProviderUpdate(bool updated_matches) {
149 if (autocomplete_->done()) 150 if (autocomplete_->done())
150 MessageLoop::current()->Quit(); 151 MessageLoop::current()->Quit();
151 } 152 }
152 153
153 void HistoryURLProviderTest::SetUpImpl(bool no_db) { 154 void HistoryURLProviderTest::SetUpImpl(bool no_db) {
155 HistoryQuickProvider::set_disabled();
GeorgeY 2011/08/18 21:34:37 That is a problem. HistoryQuickProvider's unit-tes
154 profile_.reset(new TestingProfile()); 156 profile_.reset(new TestingProfile());
155 profile_->CreateHistoryService(true, no_db); 157 profile_->CreateHistoryService(true, no_db);
156 history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 158 history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
157 159
158 autocomplete_ = new HistoryURLProvider(this, profile_.get(), "en-US,en,ko"); 160 autocomplete_ = new HistoryURLProvider(this, profile_.get(), "en-US,en,ko");
159 161
160 FillData(); 162 FillData();
161 } 163 }
162 164
163 void HistoryURLProviderTest::TearDown() { 165 void HistoryURLProviderTest::TearDown() {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 "http://foo.com/dir/another/again/", 292 "http://foo.com/dir/another/again/",
291 }; 293 };
292 RunTest(ASCIIToUTF16("foo.com/dir/another/a"), string16(), true, short_4, 294 RunTest(ASCIIToUTF16("foo.com/dir/another/a"), string16(), true, short_4,
293 arraysize(short_4)); 295 arraysize(short_4));
294 296
295 // Exact matches should always be best no matter how much more another match 297 // Exact matches should always be best no matter how much more another match
296 // has been typed. 298 // has been typed.
297 const std::string short_5a[] = { 299 const std::string short_5a[] = {
298 "http://gooey/", 300 "http://gooey/",
299 "http://www.google.com/", 301 "http://www.google.com/",
302 "http://go/",
300 }; 303 };
301 const std::string short_5b[] = { 304 const std::string short_5b[] = {
302 "http://go/", 305 "http://go/",
303 "http://gooey/", 306 "http://gooey/",
304 "http://www.google.com/", 307 "http://www.google.com/",
305 }; 308 };
306 RunTest(ASCIIToUTF16("g"), string16(), false, short_5a, arraysize(short_5a)); 309 RunTest(ASCIIToUTF16("g"), string16(), false, short_5a, arraysize(short_5a));
307 RunTest(ASCIIToUTF16("go"), string16(), false, short_5b, arraysize(short_5b)); 310 RunTest(ASCIIToUTF16("go"), string16(), false, short_5b, arraysize(short_5b));
308 } 311 }
309 312
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 false, true, AutocompleteInput::ALL_MATCHES); 502 false, true, AutocompleteInput::ALL_MATCHES);
500 autocomplete_->Start(input, false); 503 autocomplete_->Start(input, false);
501 if (!autocomplete_->done()) 504 if (!autocomplete_->done())
502 MessageLoop::current()->Run(); 505 MessageLoop::current()->Run();
503 506
504 // None of the matches should attempt to autocomplete. 507 // None of the matches should attempt to autocomplete.
505 matches_ = autocomplete_->matches(); 508 matches_ = autocomplete_->matches();
506 for (size_t i = 0; i < matches_.size(); ++i) 509 for (size_t i = 0; i < matches_.size(); ++i)
507 EXPECT_EQ(string16::npos, matches_[i].inline_autocomplete_offset); 510 EXPECT_EQ(string16::npos, matches_[i].inline_autocomplete_offset);
508 } 511 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_quick_provider.cc ('k') | chrome/browser/history/history_types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698