OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/importer/profile_writer.h" | 5 #include "chrome/browser/importer/profile_writer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
13 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" | 13 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" |
14 #include "chrome/browser/bookmarks/bookmark_utils.h" | 14 #include "chrome/browser/bookmarks/bookmark_utils.h" |
15 #include "chrome/browser/history/history_service.h" | 15 #include "chrome/browser/history/history_service.h" |
16 #include "chrome/browser/history/history_service_factory.h" | 16 #include "chrome/browser/history/history_service_factory.h" |
17 #include "chrome/browser/history/history_types.h" | 17 #include "chrome/browser/history/history_types.h" |
18 #include "chrome/browser/importer/importer_unittest_utils.h" | 18 #include "chrome/browser/importer/importer_unittest_utils.h" |
19 #include "chrome/common/importer/imported_bookmark_entry.h" | 19 #include "chrome/common/importer/imported_bookmark_entry.h" |
20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
21 #include "components/bookmarks/core/browser/bookmark_title_match.h" | 21 #include "components/bookmarks/core/browser/bookmark_match.h" |
22 #include "content/public/test/test_browser_thread.h" | 22 #include "content/public/test/test_browser_thread.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 | 24 |
25 using content::BrowserThread; | 25 using content::BrowserThread; |
26 | 26 |
27 class TestProfileWriter : public ProfileWriter { | 27 class TestProfileWriter : public ProfileWriter { |
28 public: | 28 public: |
29 explicit TestProfileWriter(Profile* profile) : ProfileWriter(profile) {} | 29 explicit TestProfileWriter(Profile* profile) : ProfileWriter(profile) {} |
30 protected: | 30 protected: |
31 virtual ~TestProfileWriter() {} | 31 virtual ~TestProfileWriter() {} |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 MakeURLRow("http://www.yahoo.com", base::ASCIIToUTF16("Yahoo"), | 73 MakeURLRow("http://www.yahoo.com", base::ASCIIToUTF16("Yahoo"), |
74 3, 30, 10)); | 74 3, 30, 10)); |
75 pages_.push_back(row1); | 75 pages_.push_back(row1); |
76 pages_.push_back(row2); | 76 pages_.push_back(row2); |
77 } | 77 } |
78 | 78 |
79 void VerifyBookmarksCount( | 79 void VerifyBookmarksCount( |
80 const std::vector<BookmarkService::URLAndTitle>& bookmarks_record, | 80 const std::vector<BookmarkService::URLAndTitle>& bookmarks_record, |
81 BookmarkModel* bookmark_model, | 81 BookmarkModel* bookmark_model, |
82 size_t expected) { | 82 size_t expected) { |
83 std::vector<BookmarkTitleMatch> matches; | 83 std::vector<BookmarkMatch> matches; |
84 for (size_t i = 0; i < bookmarks_record.size(); ++i) { | 84 for (size_t i = 0; i < bookmarks_record.size(); ++i) { |
85 bookmark_model->GetBookmarksWithTitlesMatching(bookmarks_record[i].title, | 85 bookmark_model->GetBookmarksMatching( |
86 10, | 86 bookmarks_record[i].title, 10, &matches); |
87 &matches); | |
88 EXPECT_EQ(expected, matches.size()); | 87 EXPECT_EQ(expected, matches.size()); |
89 matches.clear(); | 88 matches.clear(); |
90 } | 89 } |
91 } | 90 } |
92 | 91 |
93 void VerifyHistoryCount(Profile* profile) { | 92 void VerifyHistoryCount(Profile* profile) { |
94 HistoryService* history_service = | 93 HistoryService* history_service = |
95 HistoryServiceFactory::GetForProfile(profile, | 94 HistoryServiceFactory::GetForProfile(profile, |
96 Profile::EXPLICIT_ACCESS); | 95 Profile::EXPLICIT_ACCESS); |
97 history::QueryOptions options; | 96 history::QueryOptions options; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 new TestProfileWriter(&profile)); | 204 new TestProfileWriter(&profile)); |
206 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); | 205 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); |
207 VerifyHistoryCount(&profile); | 206 VerifyHistoryCount(&profile); |
208 size_t original_history_count = history_count_; | 207 size_t original_history_count = history_count_; |
209 history_count_ = 0; | 208 history_count_ = 0; |
210 | 209 |
211 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); | 210 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); |
212 VerifyHistoryCount(&profile); | 211 VerifyHistoryCount(&profile); |
213 EXPECT_EQ(original_history_count, history_count_); | 212 EXPECT_EQ(original_history_count, history_count_); |
214 } | 213 } |
OLD | NEW |