| 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_test_helpers.h" | 15 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" |
| 15 #include "chrome/browser/history/android/android_history_provider_service.h" | 16 #include "chrome/browser/history/android/android_history_provider_service.h" |
| 16 #include "chrome/browser/history/android/android_history_types.h" | 17 #include "chrome/browser/history/android/android_history_types.h" |
| 17 #include "chrome/browser/history/android/android_time.h" | 18 #include "chrome/browser/history/android/android_time.h" |
| 18 #include "chrome/browser/history/history_service.h" | 19 #include "chrome/browser/history/history_service.h" |
| 19 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
| 20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 23 #include "chrome/test/base/testing_profile_manager.h" | 24 #include "chrome/test/base/testing_profile_manager.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 53 virtual void SetUp() OVERRIDE { | 54 virtual void SetUp() OVERRIDE { |
| 54 // Setup the testing profile, so the bookmark_model_sql_handler could | 55 // Setup the testing profile, so the bookmark_model_sql_handler could |
| 55 // get the bookmark model from it. | 56 // get the bookmark model from it. |
| 56 ASSERT_TRUE(profile_manager_.SetUp()); | 57 ASSERT_TRUE(profile_manager_.SetUp()); |
| 57 // It seems that the name has to be chrome::kInitialProfile, so it | 58 // It seems that the name has to be chrome::kInitialProfile, so it |
| 58 // could be found by ProfileManager::GetLastUsedProfile(). | 59 // could be found by ProfileManager::GetLastUsedProfile(). |
| 59 testing_profile_ = profile_manager_.CreateTestingProfile( | 60 testing_profile_ = profile_manager_.CreateTestingProfile( |
| 60 chrome::kInitialProfile); | 61 chrome::kInitialProfile); |
| 61 | 62 |
| 62 testing_profile_->CreateBookmarkModel(true); | 63 testing_profile_->CreateBookmarkModel(true); |
| 63 test::WaitForBookmarkModelToLoad(testing_profile_); | 64 test::WaitForBookmarkModelToLoad( |
| 65 BookmarkModelFactory::GetForProfile(testing_profile_)); |
| 64 | 66 |
| 65 testing_profile_->CreateFaviconService(); | 67 testing_profile_->CreateFaviconService(); |
| 66 ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false)); | 68 ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false)); |
| 67 service_.reset(new AndroidHistoryProviderService(testing_profile_)); | 69 service_.reset(new AndroidHistoryProviderService(testing_profile_)); |
| 68 hs_ = HistoryServiceFactory::GetForProfile(testing_profile_, | 70 hs_ = HistoryServiceFactory::GetForProfile(testing_profile_, |
| 69 Profile::EXPLICIT_ACCESS); | 71 Profile::EXPLICIT_ACCESS); |
| 70 } | 72 } |
| 71 | 73 |
| 72 virtual void TearDown() OVERRIDE { | 74 virtual void TearDown() OVERRIDE { |
| 73 testing_profile_->DestroyHistoryService(); | 75 testing_profile_->DestroyHistoryService(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 cursor->GetBlob(env, NULL, 3); | 214 cursor->GetBlob(env, NULL, 3); |
| 213 std::vector<uint8> out; | 215 std::vector<uint8> out; |
| 214 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); | 216 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); |
| 215 EXPECT_EQ(data_bytes->data().size(), out.size()); | 217 EXPECT_EQ(data_bytes->data().size(), out.size()); |
| 216 EXPECT_EQ(data_bytes->data()[0], out[0]); | 218 EXPECT_EQ(data_bytes->data()[0], out[0]); |
| 217 cursor->Destroy(env, NULL); | 219 cursor->Destroy(env, NULL); |
| 218 // Cursor::Destroy posts the task in UI thread, run Message loop to release | 220 // Cursor::Destroy posts the task in UI thread, run Message loop to release |
| 219 // the statement, delete SQLiteCursor itself etc. | 221 // the statement, delete SQLiteCursor itself etc. |
| 220 content::RunAllPendingInMessageLoop(); | 222 content::RunAllPendingInMessageLoop(); |
| 221 } | 223 } |
| OLD | NEW |