OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/autocomplete/autocomplete_match.h" | 16 #include "chrome/browser/autocomplete/autocomplete_match.h" |
17 #include "chrome/browser/browser_thread.h" | 17 #include "chrome/browser/browser_thread.h" |
18 #include "chrome/browser/history/history.h" | 18 #include "chrome/browser/history/history.h" |
19 #include "chrome/browser/history/url_database.h" | 19 #include "chrome/browser/history/url_database.h" |
20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
22 #include "chrome/test/testing_browser_process.h" | |
22 #include "chrome/test/testing_profile.h" | 23 #include "chrome/test/testing_profile.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 | 25 |
25 using base::Time; | 26 using base::Time; |
26 using base::TimeDelta; | 27 using base::TimeDelta; |
27 | 28 |
28 struct TestURLInfo { | 29 struct TestURLInfo { |
29 std::string url; | 30 std::string url; |
30 std::string title; | 31 std::string title; |
31 int visit_count; | 32 int visit_count; |
(...skipping 25 matching lines...) Expand all Loading... | |
57 {"http://startest.com/y/l", "L", 1, 1, 6}, | 58 {"http://startest.com/y/l", "L", 1, 1, 6}, |
58 {"http://startest.com/y/m", "M", 1, 1, 6}, | 59 {"http://startest.com/y/m", "M", 1, 1, 6}, |
59 {"http://abcdefghixyzjklmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, | 60 {"http://abcdefghixyzjklmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, |
60 {"http://spaces.com/path%20with%20spaces/foo.html", "Spaces", 2, 2, 0}, | 61 {"http://spaces.com/path%20with%20spaces/foo.html", "Spaces", 2, 2, 0}, |
61 {"http://abcdefghijklxyzmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, | 62 {"http://abcdefghijklxyzmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, |
62 {"http://abcdefxyzghijklmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, | 63 {"http://abcdefxyzghijklmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, |
63 {"http://abcxyzdefghijklmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, | 64 {"http://abcxyzdefghijklmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, |
64 {"http://xyzabcdefghijklmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, | 65 {"http://xyzabcdefghijklmnopqrstuvw.com/a", "An XYZ", 1, 1, 0}, |
65 }; | 66 }; |
66 | 67 |
67 class HistoryQuickProviderTest : public testing::Test, | 68 class HistoryQuickProviderTest : public testing::Test, |
sky
2011/02/14 17:01:19
TestingBrowserProcessTest?
| |
68 public ACProviderListener { | 69 public ACProviderListener { |
69 public: | 70 public: |
70 HistoryQuickProviderTest() | 71 HistoryQuickProviderTest() |
71 : ui_thread_(BrowserThread::UI, &message_loop_), | 72 : ui_thread_(BrowserThread::UI, &message_loop_), |
72 file_thread_(BrowserThread::FILE, &message_loop_) {} | 73 file_thread_(BrowserThread::FILE, &message_loop_) {} |
73 | 74 |
74 // ACProviderListener | 75 // ACProviderListener |
75 virtual void OnProviderUpdate(bool updated_matches); | 76 virtual void OnProviderUpdate(bool updated_matches); |
76 | 77 |
77 protected: | 78 protected: |
(...skipping 15 matching lines...) Expand all Loading... | |
93 // Fills test data into the history system. | 94 // Fills test data into the history system. |
94 void FillData(); | 95 void FillData(); |
95 | 96 |
96 // Runs an autocomplete query on |text| and checks to see that the returned | 97 // Runs an autocomplete query on |text| and checks to see that the returned |
97 // results' destination URLs match those provided. |expected_urls| does not | 98 // results' destination URLs match those provided. |expected_urls| does not |
98 // need to be in sorted order. | 99 // need to be in sorted order. |
99 void RunTest(const string16 text, | 100 void RunTest(const string16 text, |
100 std::vector<std::string> expected_urls, | 101 std::vector<std::string> expected_urls, |
101 std::string expected_top_result); | 102 std::string expected_top_result); |
102 | 103 |
104 ScopedTestingBrowserProcess browser_process_; | |
105 | |
103 MessageLoopForUI message_loop_; | 106 MessageLoopForUI message_loop_; |
104 BrowserThread ui_thread_; | 107 BrowserThread ui_thread_; |
105 BrowserThread file_thread_; | 108 BrowserThread file_thread_; |
106 | 109 |
107 scoped_ptr<TestingProfile> profile_; | 110 scoped_ptr<TestingProfile> profile_; |
108 HistoryService* history_service_; | 111 HistoryService* history_service_; |
109 | 112 |
110 private: | 113 private: |
111 scoped_refptr<HistoryQuickProvider> provider_; | 114 scoped_refptr<HistoryQuickProvider> provider_; |
112 }; | 115 }; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 string16 text(ASCIIToUTF16("startest")); | 231 string16 text(ASCIIToUTF16("startest")); |
229 std::vector<std::string> expected_urls; | 232 std::vector<std::string> expected_urls; |
230 expected_urls.push_back("http://startest.com/y/a"); | 233 expected_urls.push_back("http://startest.com/y/a"); |
231 expected_urls.push_back("http://startest.com/y/b"); | 234 expected_urls.push_back("http://startest.com/y/b"); |
232 expected_urls.push_back("http://startest.com/x/c"); | 235 expected_urls.push_back("http://startest.com/x/c"); |
233 expected_urls.push_back("http://startest.com/x/d"); | 236 expected_urls.push_back("http://startest.com/x/d"); |
234 expected_urls.push_back("http://startest.com/y/e"); | 237 expected_urls.push_back("http://startest.com/y/e"); |
235 expected_urls.push_back("http://startest.com/y/f"); | 238 expected_urls.push_back("http://startest.com/y/f"); |
236 RunTest(text, expected_urls, "http://startest.com/y/a"); | 239 RunTest(text, expected_urls, "http://startest.com/y/a"); |
237 } | 240 } |
OLD | NEW |