OLD | NEW |
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 "chrome/browser/autocomplete/history_quick_provider.h" | 5 #include "chrome/browser/autocomplete/history_quick_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/autocomplete/autocomplete.h" | 16 #include "chrome/browser/autocomplete/autocomplete.h" |
17 #include "chrome/browser/autocomplete/autocomplete_match.h" | 17 #include "chrome/browser/autocomplete/autocomplete_match.h" |
18 #include "chrome/browser/history/history.h" | 18 #include "chrome/browser/history/history.h" |
19 #include "chrome/browser/history/in_memory_url_index.h" | 19 #include "chrome/browser/history/in_memory_url_index.h" |
20 #include "chrome/browser/history/url_database.h" | 20 #include "chrome/browser/history/url_database.h" |
21 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/testing_browser_process.h" | 23 #include "chrome/test/base/testing_browser_process.h" |
24 #include "chrome/test/base/testing_browser_process_test.h" | |
25 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
26 #include "content/browser/browser_thread.h" | 25 #include "content/browser/browser_thread.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
28 | 27 |
29 using base::Time; | 28 using base::Time; |
30 using base::TimeDelta; | 29 using base::TimeDelta; |
31 | 30 |
32 struct TestURLInfo { | 31 struct TestURLInfo { |
33 std::string url; | 32 std::string url; |
34 std::string title; | 33 std::string title; |
(...skipping 30 matching lines...) Expand all Loading... |
65 {"http://abcdefghixyzjklmnopqrstuvw.com/a", "", 3, 1, 0}, | 64 {"http://abcdefghixyzjklmnopqrstuvw.com/a", "", 3, 1, 0}, |
66 {"http://spaces.com/path%20with%20spaces/foo.html", "Spaces", 2, 2, 0}, | 65 {"http://spaces.com/path%20with%20spaces/foo.html", "Spaces", 2, 2, 0}, |
67 {"http://abcdefghijklxyzmnopqrstuvw.com/a", "", 3, 1, 0}, | 66 {"http://abcdefghijklxyzmnopqrstuvw.com/a", "", 3, 1, 0}, |
68 {"http://abcdefxyzghijklmnopqrstuvw.com/a", "", 3, 1, 0}, | 67 {"http://abcdefxyzghijklmnopqrstuvw.com/a", "", 3, 1, 0}, |
69 {"http://abcxyzdefghijklmnopqrstuvw.com/a", "", 3, 1, 0}, | 68 {"http://abcxyzdefghijklmnopqrstuvw.com/a", "", 3, 1, 0}, |
70 {"http://xyzabcdefghijklmnopqrstuvw.com/a", "", 3, 1, 0}, | 69 {"http://xyzabcdefghijklmnopqrstuvw.com/a", "", 3, 1, 0}, |
71 {"http://cda.com/Dogs%20Cats%20Gorillas%20Sea%20Slugs%20and%20Mice", | 70 {"http://cda.com/Dogs%20Cats%20Gorillas%20Sea%20Slugs%20and%20Mice", |
72 "Dogs & Cats & Mice & Other Animals", 1, 1, 0}, | 71 "Dogs & Cats & Mice & Other Animals", 1, 1, 0}, |
73 }; | 72 }; |
74 | 73 |
75 class HistoryQuickProviderTest : public TestingBrowserProcessTest, | 74 class HistoryQuickProviderTest : public testing::Test, |
76 public ACProviderListener { | 75 public ACProviderListener { |
77 public: | 76 public: |
78 HistoryQuickProviderTest() | 77 HistoryQuickProviderTest() |
79 : ui_thread_(BrowserThread::UI, &message_loop_), | 78 : ui_thread_(BrowserThread::UI, &message_loop_), |
80 file_thread_(BrowserThread::FILE, &message_loop_) {} | 79 file_thread_(BrowserThread::FILE, &message_loop_) {} |
81 | 80 |
82 // ACProviderListener | 81 // ACProviderListener |
83 virtual void OnProviderUpdate(bool updated_matches); | 82 virtual void OnProviderUpdate(bool updated_matches); |
84 | 83 |
85 protected: | 84 protected: |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 HistoryQuickProvider::kMaxNonInliningScore - 1); | 421 HistoryQuickProvider::kMaxNonInliningScore - 1); |
423 EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 2); | 422 EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 2); |
424 | 423 |
425 // Low score, can inline, not clamped. | 424 // Low score, can inline, not clamped. |
426 next_score = 1500; | 425 next_score = 1500; |
427 match.raw_score = 500; | 426 match.raw_score = 500; |
428 match.can_inline = true; | 427 match.can_inline = true; |
429 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); | 428 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); |
430 EXPECT_EQ(next_score, 499); | 429 EXPECT_EQ(next_score, 499); |
431 } | 430 } |
OLD | NEW |