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 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 }; | 144 }; |
145 | 145 |
146 } // namespace | 146 } // namespace |
147 | 147 |
148 TEST_F(SQLiteCursorTest, Run) { | 148 TEST_F(SQLiteCursorTest, Run) { |
149 HistoryAndBookmarkRow row; | 149 HistoryAndBookmarkRow row; |
150 row.set_raw_url("http://www.google.com/"); | 150 row.set_raw_url("http://www.google.com/"); |
151 row.set_url(GURL("http://www.google.com/")); | 151 row.set_url(GURL("http://www.google.com/")); |
152 std::vector<unsigned char> favicon_data; | 152 std::vector<unsigned char> favicon_data; |
153 favicon_data.push_back(1); | 153 favicon_data.push_back(1); |
154 base::RefCountedBytes *data_bytes = | 154 scoped_refptr<base::RefCountedBytes> data_bytes = |
155 base::RefCountedBytes::TakeVector(&favicon_data); | 155 base::RefCountedBytes::TakeVector(&favicon_data); |
156 row.set_favicon(data_bytes); | 156 row.set_favicon(data_bytes); |
157 row.set_last_visit_time(Time::Now()); | 157 row.set_last_visit_time(Time::Now()); |
158 row.set_visit_count(2); | 158 row.set_visit_count(2); |
159 row.set_title(base::UTF8ToUTF16("cnn")); | 159 row.set_title(base::UTF8ToUTF16("cnn")); |
160 scoped_refptr<CallbackHelper> callback(new CallbackHelper()); | 160 scoped_refptr<CallbackHelper> callback(new CallbackHelper()); |
161 | 161 |
162 // Insert a row and verify it succeeded. | 162 // Insert a row and verify it succeeded. |
163 service_->InsertHistoryAndBookmark( | 163 service_->InsertHistoryAndBookmark( |
164 row, | 164 row, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 cursor->GetBlob(env, NULL, 3); | 211 cursor->GetBlob(env, NULL, 3); |
212 std::vector<uint8_t> out; | 212 std::vector<uint8_t> out; |
213 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); | 213 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); |
214 EXPECT_EQ(data_bytes->data().size(), out.size()); | 214 EXPECT_EQ(data_bytes->data().size(), out.size()); |
215 EXPECT_EQ(data_bytes->data()[0], out[0]); | 215 EXPECT_EQ(data_bytes->data()[0], out[0]); |
216 cursor->Destroy(env, NULL); | 216 cursor->Destroy(env, NULL); |
217 // Cursor::Destroy posts the task in UI thread, run Message loop to release | 217 // Cursor::Destroy posts the task in UI thread, run Message loop to release |
218 // the statement, delete SQLiteCursor itself etc. | 218 // the statement, delete SQLiteCursor itself etc. |
219 content::RunAllPendingInMessageLoop(); | 219 content::RunAllPendingInMessageLoop(); |
220 } | 220 } |
OLD | NEW |