| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_index.h" | 10 #include "chrome/browser/bookmarks/bookmark_index.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/browser/chrome_thread.h" |
| 12 #include "chrome/browser/history/history_database.h" | 13 #include "chrome/browser/history/history_database.h" |
| 13 #include "chrome/browser/history/in_memory_database.h" | 14 #include "chrome/browser/history/in_memory_database.h" |
| 14 #include "chrome/browser/history/query_parser.h" | 15 #include "chrome/browser/history/query_parser.h" |
| 15 #include "chrome/test/testing_profile.h" | 16 #include "chrome/test/testing_profile.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 class BookmarkIndexTest : public testing::Test { | 19 class BookmarkIndexTest : public testing::Test { |
| 19 public: | 20 public: |
| 20 BookmarkIndexTest() : model_(new BookmarkModel(NULL)) {} | 21 BookmarkIndexTest() : model_(new BookmarkModel(NULL)) {} |
| 21 | 22 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 model_->GetBookmarksWithTitlesMatching(L"i", 100, &matches); | 206 model_->GetBookmarksWithTitlesMatching(L"i", 100, &matches); |
| 206 ASSERT_EQ(1U, matches.size()); | 207 ASSERT_EQ(1U, matches.size()); |
| 207 EXPECT_TRUE(matches[0].node == n1); | 208 EXPECT_TRUE(matches[0].node == n1); |
| 208 EXPECT_TRUE(matches[0].match_positions.empty()); | 209 EXPECT_TRUE(matches[0].match_positions.empty()); |
| 209 } | 210 } |
| 210 | 211 |
| 211 TEST_F(BookmarkIndexTest, GetResultsSortedByTypedCount) { | 212 TEST_F(BookmarkIndexTest, GetResultsSortedByTypedCount) { |
| 212 // This ensures MessageLoop::current() will exist, which is needed by | 213 // This ensures MessageLoop::current() will exist, which is needed by |
| 213 // TestingProfile::BlockUntilHistoryProcessesPendingRequests(). | 214 // TestingProfile::BlockUntilHistoryProcessesPendingRequests(). |
| 214 MessageLoop loop(MessageLoop::TYPE_DEFAULT); | 215 MessageLoop loop(MessageLoop::TYPE_DEFAULT); |
| 216 ChromeThread ui_thread(ChromeThread::UI, &loop); |
| 217 ChromeThread file_thread(ChromeThread::FILE, &loop); |
| 215 | 218 |
| 216 TestingProfile profile; | 219 TestingProfile profile; |
| 217 profile.CreateHistoryService(true); | 220 profile.CreateHistoryService(true); |
| 218 profile.BlockUntilHistoryProcessesPendingRequests(); | 221 profile.BlockUntilHistoryProcessesPendingRequests(); |
| 219 profile.CreateBookmarkModel(true); | 222 profile.CreateBookmarkModel(true); |
| 220 profile.BlockUntilBookmarkModelLoaded(); | 223 profile.BlockUntilBookmarkModelLoaded(); |
| 221 | 224 |
| 222 BookmarkModel* model = profile.GetBookmarkModel(); | 225 BookmarkModel* model = profile.GetBookmarkModel(); |
| 223 | 226 |
| 224 HistoryService* const history_service = | 227 HistoryService* const history_service = |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 284 |
| 282 matches.clear(); | 285 matches.clear(); |
| 283 // Select top two matches. | 286 // Select top two matches. |
| 284 model->GetBookmarksWithTitlesMatching(L"google", 2, &matches); | 287 model->GetBookmarksWithTitlesMatching(L"google", 2, &matches); |
| 285 | 288 |
| 286 EXPECT_EQ(2, static_cast<int>(matches.size())); | 289 EXPECT_EQ(2, static_cast<int>(matches.size())); |
| 287 EXPECT_EQ(data[0].url, matches[0].node->GetURL()); | 290 EXPECT_EQ(data[0].url, matches[0].node->GetURL()); |
| 288 EXPECT_EQ(data[3].url, matches[1].node->GetURL()); | 291 EXPECT_EQ(data[3].url, matches[1].node->GetURL()); |
| 289 } | 292 } |
| 290 | 293 |
| OLD | NEW |