OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/bookmarks/bookmark_index.h" | 13 #include "chrome/browser/bookmarks/bookmark_index.h" |
14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
15 #include "chrome/browser/bookmarks/bookmark_utils.h" | 16 #include "chrome/browser/bookmarks/bookmark_utils.h" |
16 #include "chrome/browser/history/history_database.h" | 17 #include "chrome/browser/history/history_database.h" |
17 #include "chrome/browser/history/history_service_factory.h" | 18 #include "chrome/browser/history/history_service_factory.h" |
18 #include "chrome/browser/history/in_memory_database.h" | 19 #include "chrome/browser/history/in_memory_database.h" |
19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
20 #include "content/public/test/test_browser_thread.h" | 21 #include "content/public/test/test_browser_thread.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 using content::BrowserThread; | 24 using content::BrowserThread; |
24 | 25 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 MessageLoop loop(MessageLoop::TYPE_DEFAULT); | 227 MessageLoop loop(MessageLoop::TYPE_DEFAULT); |
227 content::TestBrowserThread ui_thread(BrowserThread::UI, &loop); | 228 content::TestBrowserThread ui_thread(BrowserThread::UI, &loop); |
228 content::TestBrowserThread file_thread(BrowserThread::FILE, &loop); | 229 content::TestBrowserThread file_thread(BrowserThread::FILE, &loop); |
229 | 230 |
230 TestingProfile profile; | 231 TestingProfile profile; |
231 profile.CreateHistoryService(true, false); | 232 profile.CreateHistoryService(true, false); |
232 profile.BlockUntilHistoryProcessesPendingRequests(); | 233 profile.BlockUntilHistoryProcessesPendingRequests(); |
233 profile.CreateBookmarkModel(true); | 234 profile.CreateBookmarkModel(true); |
234 profile.BlockUntilBookmarkModelLoaded(); | 235 profile.BlockUntilBookmarkModelLoaded(); |
235 | 236 |
236 BookmarkModel* model = profile.GetBookmarkModel(); | 237 BookmarkModel* model = BookmarkModelFactory::GetForProfile(&profile); |
237 | 238 |
238 HistoryService* const history_service = | 239 HistoryService* const history_service = |
239 HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS); | 240 HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS); |
240 | 241 |
241 history::URLDatabase* url_db = history_service->InMemoryDatabase(); | 242 history::URLDatabase* url_db = history_service->InMemoryDatabase(); |
242 | 243 |
243 struct TestData { | 244 struct TestData { |
244 const GURL url; | 245 const GURL url; |
245 const char* title; | 246 const char* title; |
246 const int typed_count; | 247 const int typed_count; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 EXPECT_EQ(data[1].url, matches[3].node->url()); | 296 EXPECT_EQ(data[1].url, matches[3].node->url()); |
296 | 297 |
297 matches.clear(); | 298 matches.clear(); |
298 // Select top two matches. | 299 // Select top two matches. |
299 model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 2, &matches); | 300 model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 2, &matches); |
300 | 301 |
301 EXPECT_EQ(2, static_cast<int>(matches.size())); | 302 EXPECT_EQ(2, static_cast<int>(matches.size())); |
302 EXPECT_EQ(data[0].url, matches[0].node->url()); | 303 EXPECT_EQ(data[0].url, matches[0].node->url()); |
303 EXPECT_EQ(data[3].url, matches[1].node->url()); | 304 EXPECT_EQ(data[3].url, matches[1].node->url()); |
304 } | 305 } |
OLD | NEW |