Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Side by Side Diff: chrome/browser/history/android/sqlite_cursor_unittest.cc

Issue 1550593002: Switch to standard integer types in chrome/browser/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 9
9 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 11 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
13 #include "base/macros.h"
12 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
13 #include "base/task/cancelable_task_tracker.h" 15 #include "base/task/cancelable_task_tracker.h"
14 #include "base/time/time.h" 16 #include "base/time/time.h"
15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 17 #include "chrome/browser/bookmarks/bookmark_model_factory.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/history_service_factory.h" 19 #include "chrome/browser/history/history_service_factory.h"
18 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
19 #include "chrome/test/base/testing_browser_process.h" 21 #include "chrome/test/base/testing_browser_process.h"
20 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
21 #include "chrome/test/base/testing_profile_manager.h" 23 #include "chrome/test/base/testing_profile_manager.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 114 }
113 115
114 bool success() const { 116 bool success() const {
115 return success_; 117 return success_;
116 } 118 }
117 119
118 AndroidStatement* statement() const { 120 AndroidStatement* statement() const {
119 return statement_; 121 return statement_;
120 } 122 }
121 123
122 void OnInserted(int64 id) { 124 void OnInserted(int64_t id) {
123 success_ = id != 0; 125 success_ = id != 0;
124 base::MessageLoop::current()->QuitWhenIdle(); 126 base::MessageLoop::current()->QuitWhenIdle();
125 } 127 }
126 128
127 void OnQueryResult(AndroidStatement* statement) { 129 void OnQueryResult(AndroidStatement* statement) {
128 success_ = statement != NULL; 130 success_ = statement != NULL;
129 statement_ = statement; 131 statement_ = statement;
130 base::MessageLoop::current()->QuitWhenIdle(); 132 base::MessageLoop::current()->QuitWhenIdle();
131 } 133 }
132 134
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 JNIEnv* env = base::android::AttachCurrentThread(); 202 JNIEnv* env = base::android::AttachCurrentThread();
201 EXPECT_EQ(1, cursor->GetCount(env, NULL)); 203 EXPECT_EQ(1, cursor->GetCount(env, NULL));
202 EXPECT_EQ(0, cursor->MoveTo(env, NULL, 0)); 204 EXPECT_EQ(0, cursor->MoveTo(env, NULL, 0));
203 EXPECT_EQ(row.url().spec(), base::android::ConvertJavaStringToUTF8( 205 EXPECT_EQ(row.url().spec(), base::android::ConvertJavaStringToUTF8(
204 cursor->GetString(env, NULL, 0)).c_str()); 206 cursor->GetString(env, NULL, 0)).c_str());
205 EXPECT_EQ(history::ToDatabaseTime(row.last_visit_time()), 207 EXPECT_EQ(history::ToDatabaseTime(row.last_visit_time()),
206 cursor->GetLong(env, NULL, 1)); 208 cursor->GetLong(env, NULL, 1));
207 EXPECT_EQ(row.visit_count(), cursor->GetInt(env, NULL, 2)); 209 EXPECT_EQ(row.visit_count(), cursor->GetInt(env, NULL, 2));
208 base::android::ScopedJavaLocalRef<jbyteArray> data = 210 base::android::ScopedJavaLocalRef<jbyteArray> data =
209 cursor->GetBlob(env, NULL, 3); 211 cursor->GetBlob(env, NULL, 3);
210 std::vector<uint8> out; 212 std::vector<uint8_t> out;
211 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); 213 base::android::JavaByteArrayToByteVector(env, data.obj(), &out);
212 EXPECT_EQ(data_bytes->data().size(), out.size()); 214 EXPECT_EQ(data_bytes->data().size(), out.size());
213 EXPECT_EQ(data_bytes->data()[0], out[0]); 215 EXPECT_EQ(data_bytes->data()[0], out[0]);
214 cursor->Destroy(env, NULL); 216 cursor->Destroy(env, NULL);
215 // 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
216 // the statement, delete SQLiteCursor itself etc. 218 // the statement, delete SQLiteCursor itself etc.
217 content::RunAllPendingInMessageLoop(); 219 content::RunAllPendingInMessageLoop();
218 } 220 }
OLDNEW
« no previous file with comments | « chrome/browser/history/android/sqlite_cursor.h ('k') | chrome/browser/history/android/urls_sql_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698