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/sqlite_cursor.h" | 5 #include "chrome/browser/history/android/sqlite_cursor.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 15 #include "chrome/browser/favicon/chrome_favicon_client.h" |
| 16 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
15 #include "chrome/browser/favicon/favicon_service.h" | 17 #include "chrome/browser/favicon/favicon_service.h" |
16 #include "chrome/browser/history/android/android_history_provider_service.h" | 18 #include "chrome/browser/history/android/android_history_provider_service.h" |
17 #include "chrome/browser/history/android/android_history_types.h" | 19 #include "chrome/browser/history/android/android_history_types.h" |
18 #include "chrome/browser/history/android/android_time.h" | 20 #include "chrome/browser/history/android/android_time.h" |
19 #include "chrome/browser/history/history_service.h" | 21 #include "chrome/browser/history/history_service.h" |
20 #include "chrome/browser/history/history_service_factory.h" | 22 #include "chrome/browser/history/history_service_factory.h" |
21 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
22 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
23 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
24 #include "chrome/test/base/testing_profile_manager.h" | 26 #include "chrome/test/base/testing_profile_manager.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 std::vector<std::string> column_names; | 193 std::vector<std::string> column_names; |
192 column_names.push_back( | 194 column_names.push_back( |
193 HistoryAndBookmarkRow::GetAndroidName(HistoryAndBookmarkRow::URL)); | 195 HistoryAndBookmarkRow::GetAndroidName(HistoryAndBookmarkRow::URL)); |
194 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( | 196 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( |
195 HistoryAndBookmarkRow::LAST_VISIT_TIME)); | 197 HistoryAndBookmarkRow::LAST_VISIT_TIME)); |
196 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( | 198 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( |
197 HistoryAndBookmarkRow::VISIT_COUNT)); | 199 HistoryAndBookmarkRow::VISIT_COUNT)); |
198 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( | 200 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( |
199 HistoryAndBookmarkRow::FAVICON)); | 201 HistoryAndBookmarkRow::FAVICON)); |
200 | 202 |
201 FaviconService* favicon_service = new FaviconService(testing_profile_); | 203 FaviconClient* favicon_client = |
| 204 ChromeFaviconClientFactory::GetForProfile(testing_profile_); |
| 205 FaviconService* favicon_service = |
| 206 new FaviconService(testing_profile_, favicon_client); |
202 | 207 |
203 SQLiteCursor* cursor = new SQLiteCursor(column_names, statement, | 208 SQLiteCursor* cursor = new SQLiteCursor(column_names, statement, |
204 service_.get(), favicon_service); | 209 service_.get(), favicon_service); |
205 cursor->set_test_observer(this); | 210 cursor->set_test_observer(this); |
206 JNIEnv* env = base::android::AttachCurrentThread(); | 211 JNIEnv* env = base::android::AttachCurrentThread(); |
207 EXPECT_EQ(1, cursor->GetCount(env, NULL)); | 212 EXPECT_EQ(1, cursor->GetCount(env, NULL)); |
208 EXPECT_EQ(0, cursor->MoveTo(env, NULL, 0)); | 213 EXPECT_EQ(0, cursor->MoveTo(env, NULL, 0)); |
209 EXPECT_EQ(row.url().spec(), base::android::ConvertJavaStringToUTF8( | 214 EXPECT_EQ(row.url().spec(), base::android::ConvertJavaStringToUTF8( |
210 cursor->GetString(env, NULL, 0)).c_str()); | 215 cursor->GetString(env, NULL, 0)).c_str()); |
211 EXPECT_EQ(history::ToDatabaseTime(row.last_visit_time()), | 216 EXPECT_EQ(history::ToDatabaseTime(row.last_visit_time()), |
212 cursor->GetLong(env, NULL, 1)); | 217 cursor->GetLong(env, NULL, 1)); |
213 EXPECT_EQ(row.visit_count(), cursor->GetInt(env, NULL, 2)); | 218 EXPECT_EQ(row.visit_count(), cursor->GetInt(env, NULL, 2)); |
214 base::android::ScopedJavaLocalRef<jbyteArray> data = | 219 base::android::ScopedJavaLocalRef<jbyteArray> data = |
215 cursor->GetBlob(env, NULL, 3); | 220 cursor->GetBlob(env, NULL, 3); |
216 std::vector<uint8> out; | 221 std::vector<uint8> out; |
217 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); | 222 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); |
218 EXPECT_EQ(data_bytes->data().size(), out.size()); | 223 EXPECT_EQ(data_bytes->data().size(), out.size()); |
219 EXPECT_EQ(data_bytes->data()[0], out[0]); | 224 EXPECT_EQ(data_bytes->data()[0], out[0]); |
220 cursor->Destroy(env, NULL); | 225 cursor->Destroy(env, NULL); |
221 // Cursor::Destroy posts the task in UI thread, run Message loop to release | 226 // Cursor::Destroy posts the task in UI thread, run Message loop to release |
222 // the statement, delete SQLiteCursor itself etc. | 227 // the statement, delete SQLiteCursor itself etc. |
223 content::RunAllPendingInMessageLoop(); | 228 content::RunAllPendingInMessageLoop(); |
224 } | 229 } |
OLD | NEW |