| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/run_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 14 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
| 15 #include "chrome/browser/importer/importer_unittest_utils.h" | 16 #include "chrome/browser/importer/importer_unittest_utils.h" |
| 16 #include "chrome/common/importer/imported_bookmark_entry.h" | 17 #include "chrome/common/importer/imported_bookmark_entry.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 18 #include "components/bookmarks/browser/bookmark_match.h" | 19 #include "components/bookmarks/browser/bookmark_match.h" |
| 19 #include "components/bookmarks/browser/bookmark_model.h" | 20 #include "components/bookmarks/browser/bookmark_model.h" |
| 20 #include "components/bookmarks/browser/bookmark_utils.h" | 21 #include "components/bookmarks/browser/bookmark_utils.h" |
| 21 #include "components/bookmarks/test/bookmark_test_helpers.h" | 22 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 HistoryServiceFactory::GetForProfile( | 95 HistoryServiceFactory::GetForProfile( |
| 95 profile, ServiceAccessType::EXPLICIT_ACCESS); | 96 profile, ServiceAccessType::EXPLICIT_ACCESS); |
| 96 history::QueryOptions options; | 97 history::QueryOptions options; |
| 97 base::CancelableTaskTracker history_task_tracker; | 98 base::CancelableTaskTracker history_task_tracker; |
| 98 history_service->QueryHistory( | 99 history_service->QueryHistory( |
| 99 base::string16(), | 100 base::string16(), |
| 100 options, | 101 options, |
| 101 base::Bind(&ProfileWriterTest::HistoryQueryComplete, | 102 base::Bind(&ProfileWriterTest::HistoryQueryComplete, |
| 102 base::Unretained(this)), | 103 base::Unretained(this)), |
| 103 &history_task_tracker); | 104 &history_task_tracker); |
| 104 base::MessageLoop::current()->Run(); | 105 base::RunLoop().Run(); |
| 105 } | 106 } |
| 106 | 107 |
| 107 void HistoryQueryComplete(history::QueryResults* results) { | 108 void HistoryQueryComplete(history::QueryResults* results) { |
| 108 base::MessageLoop::current()->QuitWhenIdle(); | 109 base::MessageLoop::current()->QuitWhenIdle(); |
| 109 history_count_ = results->size(); | 110 history_count_ = results->size(); |
| 110 } | 111 } |
| 111 | 112 |
| 112 protected: | 113 protected: |
| 113 std::vector<ImportedBookmarkEntry> bookmarks_; | 114 std::vector<ImportedBookmarkEntry> bookmarks_; |
| 114 history::URLRows pages_; | 115 history::URLRows pages_; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 new TestProfileWriter(&profile)); | 201 new TestProfileWriter(&profile)); |
| 201 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); | 202 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); |
| 202 VerifyHistoryCount(&profile); | 203 VerifyHistoryCount(&profile); |
| 203 size_t original_history_count = history_count_; | 204 size_t original_history_count = history_count_; |
| 204 history_count_ = 0; | 205 history_count_ = 0; |
| 205 | 206 |
| 206 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); | 207 profile_writer->AddHistoryPage(pages_, history::SOURCE_FIREFOX_IMPORTED); |
| 207 VerifyHistoryCount(&profile); | 208 VerifyHistoryCount(&profile); |
| 208 EXPECT_EQ(original_history_count, history_count_); | 209 EXPECT_EQ(original_history_count, history_count_); |
| 209 } | 210 } |
| OLD | NEW |