| 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 "chrome/browser/history/android/android_history_provider_service.h" | 5 #include "chrome/browser/history/android/android_history_provider_service.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/task/cancelable_task_tracker.h" | 8 #include "base/task/cancelable_task_tracker.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 statement_ = statement; | 115 statement_ = statement; |
| 116 base::MessageLoop::current()->Quit(); | 116 base::MessageLoop::current()->Quit(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void OnUpdated(int count) { | 119 void OnUpdated(int count) { |
| 120 success_ = count != 0; | 120 success_ = count != 0; |
| 121 count_ = count; | 121 count_ = count; |
| 122 base::MessageLoop::current()->Quit(); | 122 base::MessageLoop::current()->Quit(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void OnDeleted(AndroidHistoryProviderService::Handle handle, | 125 void OnDeleted(int count) { |
| 126 bool success, | 126 success_ = count != 0; |
| 127 int count) { | |
| 128 success_ = success; | |
| 129 count_ = count; | 127 count_ = count; |
| 130 base::MessageLoop::current()->Quit(); | 128 base::MessageLoop::current()->Quit(); |
| 131 } | 129 } |
| 132 | 130 |
| 133 void OnStatementMoved(int cursor_position) { | 131 void OnStatementMoved(int cursor_position) { |
| 134 cursor_position_ = cursor_position; | 132 cursor_position_ = cursor_position; |
| 135 base::MessageLoop::current()->Quit(); | 133 base::MessageLoop::current()->Quit(); |
| 136 } | 134 } |
| 137 | 135 |
| 138 private: | 136 private: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 update_row, | 198 update_row, |
| 201 std::string(), | 199 std::string(), |
| 202 std::vector<base::string16>(), | 200 std::vector<base::string16>(), |
| 203 Bind(&CallbackHelper::OnUpdated, callback.get()), | 201 Bind(&CallbackHelper::OnUpdated, callback.get()), |
| 204 &cancelable_tracker_); | 202 &cancelable_tracker_); |
| 205 base::MessageLoop::current()->Run(); | 203 base::MessageLoop::current()->Run(); |
| 206 EXPECT_TRUE(callback->success()); | 204 EXPECT_TRUE(callback->success()); |
| 207 EXPECT_EQ(1, callback->count()); | 205 EXPECT_EQ(1, callback->count()); |
| 208 | 206 |
| 209 // Delete the row. | 207 // Delete the row. |
| 210 service_->DeleteHistoryAndBookmarks(std::string(), | 208 service_->DeleteHistoryAndBookmarks( |
| 209 std::string(), |
| 211 std::vector<base::string16>(), | 210 std::vector<base::string16>(), |
| 212 &cancelable_consumer_, Bind(&CallbackHelper::OnDeleted, callback.get())); | 211 Bind(&CallbackHelper::OnDeleted, callback.get()), |
| 212 &cancelable_tracker_); |
| 213 base::MessageLoop::current()->Run(); | 213 base::MessageLoop::current()->Run(); |
| 214 EXPECT_TRUE(callback->success()); | 214 EXPECT_TRUE(callback->success()); |
| 215 EXPECT_EQ(1, callback->count()); | 215 EXPECT_EQ(1, callback->count()); |
| 216 } | 216 } |
| 217 | 217 |
| 218 TEST_F(AndroidHistoryProviderServiceTest, TestSearchTerm) { | 218 TEST_F(AndroidHistoryProviderServiceTest, TestSearchTerm) { |
| 219 SearchRow search_row; | 219 SearchRow search_row; |
| 220 search_row.set_search_term(base::UTF8ToUTF16("google")); | 220 search_row.set_search_term(base::UTF8ToUTF16("google")); |
| 221 search_row.set_url(GURL("http://google.com")); | 221 search_row.set_url(GURL("http://google.com")); |
| 222 search_row.set_keyword_id(1); | 222 search_row.set_keyword_id(1); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 service_->UpdateSearchTerms(update_row, | 267 service_->UpdateSearchTerms(update_row, |
| 268 std::string(), | 268 std::string(), |
| 269 std::vector<base::string16>(), | 269 std::vector<base::string16>(), |
| 270 Bind(&CallbackHelper::OnUpdated, callback.get()), | 270 Bind(&CallbackHelper::OnUpdated, callback.get()), |
| 271 &cancelable_tracker_); | 271 &cancelable_tracker_); |
| 272 base::MessageLoop::current()->Run(); | 272 base::MessageLoop::current()->Run(); |
| 273 EXPECT_TRUE(callback->success()); | 273 EXPECT_TRUE(callback->success()); |
| 274 EXPECT_EQ(1, callback->count()); | 274 EXPECT_EQ(1, callback->count()); |
| 275 | 275 |
| 276 // Delete the row. | 276 // Delete the row. |
| 277 service_->DeleteSearchTerms(std::string(), std::vector<base::string16>(), | 277 service_->DeleteSearchTerms(std::string(), |
| 278 &cancelable_consumer_, Bind(&CallbackHelper::OnDeleted, callback.get())); | 278 std::vector<base::string16>(), |
| 279 Bind(&CallbackHelper::OnDeleted, callback.get()), |
| 280 &cancelable_tracker_); |
| 279 base::MessageLoop::current()->Run(); | 281 base::MessageLoop::current()->Run(); |
| 280 EXPECT_TRUE(callback->success()); | 282 EXPECT_TRUE(callback->success()); |
| 281 EXPECT_EQ(1, callback->count()); | 283 EXPECT_EQ(1, callback->count()); |
| 282 } | 284 } |
| 283 | 285 |
| 284 } // namespace | 286 } // namespace |
| OLD | NEW |