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

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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // URLs used by EmptyVisits. 95 // URLs used by EmptyVisits.
95 {"http://pandora.com/", "Pandora", 2, 2}, 96 {"http://pandora.com/", "Pandora", 2, 2},
96 {"http://p/", "p", 0, 0}, 97 {"http://p/", "p", 0, 0},
97 }; 98 };
98 99
99 class HistoryURLProviderTest : public TestingBrowserProcessTest, 100 class HistoryURLProviderTest : public TestingBrowserProcessTest,
100 public ACProviderListener { 101 public ACProviderListener {
101 public: 102 public:
102 HistoryURLProviderTest() 103 HistoryURLProviderTest()
103 : ui_thread_(BrowserThread::UI, &message_loop_), 104 : ui_thread_(BrowserThread::UI, &message_loop_),
104 file_thread_(BrowserThread::FILE, &message_loop_) {} 105 file_thread_(BrowserThread::FILE, &message_loop_) {
106 HistoryQuickProvider::set_disabled(true);
107 }
108
109 virtual ~HistoryURLProviderTest() {
110 HistoryQuickProvider::set_disabled(false);
111 }
105 112
106 // ACProviderListener 113 // ACProviderListener
107 virtual void OnProviderUpdate(bool updated_matches); 114 virtual void OnProviderUpdate(bool updated_matches);
108 115
109 protected: 116 protected:
110 // testing::Test 117 // testing::Test
111 virtual void SetUp() { 118 virtual void SetUp() {
112 SetUpImpl(false); 119 SetUpImpl(false);
113 } 120 }
114 virtual void TearDown(); 121 virtual void TearDown();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 "http://foo.com/dir/another/again/", 297 "http://foo.com/dir/another/again/",
291 }; 298 };
292 RunTest(ASCIIToUTF16("foo.com/dir/another/a"), string16(), true, short_4, 299 RunTest(ASCIIToUTF16("foo.com/dir/another/a"), string16(), true, short_4,
293 arraysize(short_4)); 300 arraysize(short_4));
294 301
295 // Exact matches should always be best no matter how much more another match 302 // Exact matches should always be best no matter how much more another match
296 // has been typed. 303 // has been typed.
297 const std::string short_5a[] = { 304 const std::string short_5a[] = {
298 "http://gooey/", 305 "http://gooey/",
299 "http://www.google.com/", 306 "http://www.google.com/",
307 "http://go/",
300 }; 308 };
301 const std::string short_5b[] = { 309 const std::string short_5b[] = {
302 "http://go/", 310 "http://go/",
303 "http://gooey/", 311 "http://gooey/",
304 "http://www.google.com/", 312 "http://www.google.com/",
305 }; 313 };
306 RunTest(ASCIIToUTF16("g"), string16(), false, short_5a, arraysize(short_5a)); 314 RunTest(ASCIIToUTF16("g"), string16(), false, short_5a, arraysize(short_5a));
307 RunTest(ASCIIToUTF16("go"), string16(), false, short_5b, arraysize(short_5b)); 315 RunTest(ASCIIToUTF16("go"), string16(), false, short_5b, arraysize(short_5b));
308 } 316 }
309 317
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 false, true, AutocompleteInput::ALL_MATCHES); 507 false, true, AutocompleteInput::ALL_MATCHES);
500 autocomplete_->Start(input, false); 508 autocomplete_->Start(input, false);
501 if (!autocomplete_->done()) 509 if (!autocomplete_->done())
502 MessageLoop::current()->Run(); 510 MessageLoop::current()->Run();
503 511
504 // None of the matches should attempt to autocomplete. 512 // None of the matches should attempt to autocomplete.
505 matches_ = autocomplete_->matches(); 513 matches_ = autocomplete_->matches();
506 for (size_t i = 0; i < matches_.size(); ++i) 514 for (size_t i = 0; i < matches_.size(); ++i)
507 EXPECT_EQ(string16::npos, matches_[i].inline_autocomplete_offset); 515 EXPECT_EQ(string16::npos, matches_[i].inline_autocomplete_offset);
508 } 516 }
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