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" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 SQLiteCursorTest() | 48 SQLiteCursorTest() |
49 : profile_manager_( | 49 : profile_manager_( |
50 TestingBrowserProcess::GetGlobal()), | 50 TestingBrowserProcess::GetGlobal()), |
51 ui_thread_(BrowserThread::UI, &message_loop_), | 51 ui_thread_(BrowserThread::UI, &message_loop_), |
52 file_thread_(BrowserThread::FILE, &message_loop_) { | 52 file_thread_(BrowserThread::FILE, &message_loop_) { |
53 } | 53 } |
54 virtual ~SQLiteCursorTest() { | 54 virtual ~SQLiteCursorTest() { |
55 } | 55 } |
56 | 56 |
57 protected: | 57 protected: |
58 virtual void SetUp() OVERRIDE { | 58 virtual void SetUp() override { |
59 // Setup the testing profile, so the bookmark_model_sql_handler could | 59 // Setup the testing profile, so the bookmark_model_sql_handler could |
60 // get the bookmark model from it. | 60 // get the bookmark model from it. |
61 ASSERT_TRUE(profile_manager_.SetUp()); | 61 ASSERT_TRUE(profile_manager_.SetUp()); |
62 // It seems that the name has to be chrome::kInitialProfile, so it | 62 // It seems that the name has to be chrome::kInitialProfile, so it |
63 // could be found by ProfileManager::GetLastUsedProfile(). | 63 // could be found by ProfileManager::GetLastUsedProfile(). |
64 testing_profile_ = profile_manager_.CreateTestingProfile( | 64 testing_profile_ = profile_manager_.CreateTestingProfile( |
65 chrome::kInitialProfile); | 65 chrome::kInitialProfile); |
66 | 66 |
67 testing_profile_->CreateBookmarkModel(true); | 67 testing_profile_->CreateBookmarkModel(true); |
68 test::WaitForBookmarkModelToLoad( | 68 test::WaitForBookmarkModelToLoad( |
69 BookmarkModelFactory::GetForProfile(testing_profile_)); | 69 BookmarkModelFactory::GetForProfile(testing_profile_)); |
70 | 70 |
71 testing_profile_->CreateFaviconService(); | 71 testing_profile_->CreateFaviconService(); |
72 ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false)); | 72 ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false)); |
73 service_.reset(new AndroidHistoryProviderService(testing_profile_)); | 73 service_.reset(new AndroidHistoryProviderService(testing_profile_)); |
74 hs_ = HistoryServiceFactory::GetForProfile(testing_profile_, | 74 hs_ = HistoryServiceFactory::GetForProfile(testing_profile_, |
75 Profile::EXPLICIT_ACCESS); | 75 Profile::EXPLICIT_ACCESS); |
76 } | 76 } |
77 | 77 |
78 virtual void TearDown() OVERRIDE { | 78 virtual void TearDown() override { |
79 testing_profile_->DestroyHistoryService(); | 79 testing_profile_->DestroyHistoryService(); |
80 profile_manager_.DeleteTestingProfile(chrome::kInitialProfile); | 80 profile_manager_.DeleteTestingProfile(chrome::kInitialProfile); |
81 testing_profile_ = NULL; | 81 testing_profile_ = NULL; |
82 } | 82 } |
83 | 83 |
84 // Override SQLiteCursor::TestObserver. | 84 // Override SQLiteCursor::TestObserver. |
85 virtual void OnPostMoveToTask() OVERRIDE { | 85 virtual void OnPostMoveToTask() override { |
86 base::MessageLoop::current()->Run(); | 86 base::MessageLoop::current()->Run(); |
87 } | 87 } |
88 | 88 |
89 virtual void OnGetMoveToResult() OVERRIDE { | 89 virtual void OnGetMoveToResult() override { |
90 base::MessageLoop::current()->Quit(); | 90 base::MessageLoop::current()->Quit(); |
91 } | 91 } |
92 | 92 |
93 virtual void OnPostGetFaviconTask() OVERRIDE { | 93 virtual void OnPostGetFaviconTask() override { |
94 base::MessageLoop::current()->Run(); | 94 base::MessageLoop::current()->Run(); |
95 } | 95 } |
96 | 96 |
97 virtual void OnGetFaviconResult() OVERRIDE { | 97 virtual void OnGetFaviconResult() override { |
98 base::MessageLoop::current()->Quit(); | 98 base::MessageLoop::current()->Quit(); |
99 } | 99 } |
100 | 100 |
101 protected: | 101 protected: |
102 TestingProfileManager profile_manager_; | 102 TestingProfileManager profile_manager_; |
103 base::MessageLoop message_loop_; | 103 base::MessageLoop message_loop_; |
104 content::TestBrowserThread ui_thread_; | 104 content::TestBrowserThread ui_thread_; |
105 content::TestBrowserThread file_thread_; | 105 content::TestBrowserThread file_thread_; |
106 scoped_ptr<AndroidHistoryProviderService> service_; | 106 scoped_ptr<AndroidHistoryProviderService> service_; |
107 base::CancelableTaskTracker cancelable_tracker_; | 107 base::CancelableTaskTracker cancelable_tracker_; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 cursor->GetBlob(env, NULL, 3); | 223 cursor->GetBlob(env, NULL, 3); |
224 std::vector<uint8> out; | 224 std::vector<uint8> out; |
225 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); | 225 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); |
226 EXPECT_EQ(data_bytes->data().size(), out.size()); | 226 EXPECT_EQ(data_bytes->data().size(), out.size()); |
227 EXPECT_EQ(data_bytes->data()[0], out[0]); | 227 EXPECT_EQ(data_bytes->data()[0], out[0]); |
228 cursor->Destroy(env, NULL); | 228 cursor->Destroy(env, NULL); |
229 // Cursor::Destroy posts the task in UI thread, run Message loop to release | 229 // Cursor::Destroy posts the task in UI thread, run Message loop to release |
230 // the statement, delete SQLiteCursor itself etc. | 230 // the statement, delete SQLiteCursor itself etc. |
231 content::RunAllPendingInMessageLoop(); | 231 content::RunAllPendingInMessageLoop(); |
232 } | 232 } |
OLD | NEW |