Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/history/android/android_history_provider_service_unittest.cc

Issue 2216713002: Use BookmarkModelFactory::GetForBrowserContext everywhere (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarks
Patch Set: Replace in .mm files Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/history/android/android_history_provider_service.h" 5 #include "chrome/browser/history/android/android_history_provider_service.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Setup the testing profile, so the bookmark_model_sql_handler could 51 // Setup the testing profile, so the bookmark_model_sql_handler could
52 // get the bookmark model from it. 52 // get the bookmark model from it.
53 ASSERT_TRUE(profile_manager_.SetUp()); 53 ASSERT_TRUE(profile_manager_.SetUp());
54 // It seems that the name has to be chrome::kInitialProfile, so it 54 // It seems that the name has to be chrome::kInitialProfile, so it
55 // could be found by ProfileManager::GetLastUsedProfile(). 55 // could be found by ProfileManager::GetLastUsedProfile().
56 testing_profile_ = profile_manager_.CreateTestingProfile( 56 testing_profile_ = profile_manager_.CreateTestingProfile(
57 chrome::kInitialProfile); 57 chrome::kInitialProfile);
58 58
59 testing_profile_->CreateBookmarkModel(true); 59 testing_profile_->CreateBookmarkModel(true);
60 bookmarks::test::WaitForBookmarkModelToLoad( 60 bookmarks::test::WaitForBookmarkModelToLoad(
61 BookmarkModelFactory::GetForProfile(testing_profile_)); 61 BookmarkModelFactory::GetForBrowserContext(testing_profile_));
62 ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false)); 62 ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false));
63 service_.reset(new AndroidHistoryProviderService(testing_profile_)); 63 service_.reset(new AndroidHistoryProviderService(testing_profile_));
64 } 64 }
65 65
66 void TearDown() override { 66 void TearDown() override {
67 testing_profile_->DestroyHistoryService(); 67 testing_profile_->DestroyHistoryService();
68 profile_manager_.DeleteTestingProfile(chrome::kInitialProfile); 68 profile_manager_.DeleteTestingProfile(chrome::kInitialProfile);
69 testing_profile_=NULL; 69 testing_profile_ = nullptr;
70 } 70 }
71 71
72 protected: 72 protected:
73 TestingProfileManager profile_manager_; 73 TestingProfileManager profile_manager_;
74 base::MessageLoop message_loop_; 74 base::MessageLoop message_loop_;
75 content::TestBrowserThread ui_thread_; 75 content::TestBrowserThread ui_thread_;
76 content::TestBrowserThread file_thread_; 76 content::TestBrowserThread file_thread_;
77 std::unique_ptr<AndroidHistoryProviderService> service_; 77 std::unique_ptr<AndroidHistoryProviderService> service_;
78 base::CancelableTaskTracker cancelable_tracker_; 78 base::CancelableTaskTracker cancelable_tracker_;
79 TestingProfile* testing_profile_; 79 TestingProfile* testing_profile_;
80 80
81 private: 81 private:
82 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderServiceTest); 82 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderServiceTest);
83 }; 83 };
84 84
85 class CallbackHelper : public base::RefCountedThreadSafe<CallbackHelper> { 85 class CallbackHelper : public base::RefCountedThreadSafe<CallbackHelper> {
86 public: 86 public:
87 CallbackHelper() 87 CallbackHelper()
88 : success_(false), 88 : success_(false), statement_(nullptr), cursor_position_(0), count_(0) {}
89 statement_(NULL),
90 cursor_position_(0),
91 count_(0) {
92 }
93 89
94 bool success() const { 90 bool success() const {
95 return success_; 91 return success_;
96 } 92 }
97 93
98 AndroidStatement* statement() const { 94 AndroidStatement* statement() const {
99 return statement_; 95 return statement_;
100 } 96 }
101 97
102 int cursor_position() const { 98 int cursor_position() const {
103 return cursor_position_; 99 return cursor_position_;
104 } 100 }
105 101
106 int count() const { 102 int count() const {
107 return count_; 103 return count_;
108 } 104 }
109 105
110 void OnInserted(int64_t id) { 106 void OnInserted(int64_t id) {
111 success_ = id != 0; 107 success_ = id != 0;
112 base::MessageLoop::current()->QuitWhenIdle(); 108 base::MessageLoop::current()->QuitWhenIdle();
113 } 109 }
114 110
115 void OnQueryResult(AndroidStatement* statement) { 111 void OnQueryResult(AndroidStatement* statement) {
116 success_ = statement != NULL; 112 success_ = statement != nullptr;
117 statement_ = statement; 113 statement_ = statement;
118 base::MessageLoop::current()->QuitWhenIdle(); 114 base::MessageLoop::current()->QuitWhenIdle();
119 } 115 }
120 116
121 void OnUpdated(int count) { 117 void OnUpdated(int count) {
122 success_ = count != 0; 118 success_ = count != 0;
123 count_ = count; 119 count_ = count;
124 base::MessageLoop::current()->QuitWhenIdle(); 120 base::MessageLoop::current()->QuitWhenIdle();
125 } 121 }
126 122
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 service_->DeleteSearchTerms(std::string(), 275 service_->DeleteSearchTerms(std::string(),
280 std::vector<base::string16>(), 276 std::vector<base::string16>(),
281 Bind(&CallbackHelper::OnDeleted, callback.get()), 277 Bind(&CallbackHelper::OnDeleted, callback.get()),
282 &cancelable_tracker_); 278 &cancelable_tracker_);
283 base::MessageLoop::current()->Run(); 279 base::MessageLoop::current()->Run();
284 EXPECT_TRUE(callback->success()); 280 EXPECT_TRUE(callback->success());
285 EXPECT_EQ(1, callback->count()); 281 EXPECT_EQ(1, callback->count());
286 } 282 }
287 283
288 } // namespace 284 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_utils.cc ('k') | chrome/browser/history/android/android_provider_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698