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

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

Issue 15701011: Only wait for CancelAllRequests done if the post task succeeds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync again Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/android/sqlite_cursor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 HistoryAndBookmarkRow::GetAndroidName(HistoryAndBookmarkRow::URL)); 190 HistoryAndBookmarkRow::GetAndroidName(HistoryAndBookmarkRow::URL));
191 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( 191 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName(
192 HistoryAndBookmarkRow::LAST_VISIT_TIME)); 192 HistoryAndBookmarkRow::LAST_VISIT_TIME));
193 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( 193 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName(
194 HistoryAndBookmarkRow::VISIT_COUNT)); 194 HistoryAndBookmarkRow::VISIT_COUNT));
195 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( 195 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName(
196 HistoryAndBookmarkRow::FAVICON)); 196 HistoryAndBookmarkRow::FAVICON));
197 197
198 FaviconService* favicon_service = new FaviconService(hs_); 198 FaviconService* favicon_service = new FaviconService(hs_);
199 199
200 // Wraps cursor in a block, so the destructor will be called after that. 200 SQLiteCursor* cursor = new SQLiteCursor(column_names, statement,
201 { 201 service_.get(), favicon_service);
202 SQLiteCursor cursor(column_names, statement, service_.get(), 202 cursor->set_test_observer(this);
203 favicon_service); 203 JNIEnv* env = base::android::AttachCurrentThread();
204 cursor.set_test_observer(this); 204 EXPECT_EQ(1, cursor->GetCount(env, NULL));
205 JNIEnv* env = base::android::AttachCurrentThread(); 205 EXPECT_EQ(0, cursor->MoveTo(env, NULL, 0));
206 EXPECT_EQ(1, cursor.GetCount(env, NULL)); 206 EXPECT_EQ(row.url().spec(), base::android::ConvertJavaStringToUTF8(
207 EXPECT_EQ(0, cursor.MoveTo(env, NULL, 0)); 207 cursor->GetString(env, NULL, 0)).c_str());
208 EXPECT_EQ(row.url().spec(), base::android::ConvertJavaStringToUTF8( 208 EXPECT_EQ(history::ToDatabaseTime(row.last_visit_time()),
209 cursor.GetString(env, NULL, 0)).c_str()); 209 cursor->GetLong(env, NULL, 1));
210 EXPECT_EQ(history::ToDatabaseTime(row.last_visit_time()), 210 EXPECT_EQ(row.visit_count(), cursor->GetInt(env, NULL, 2));
211 cursor.GetLong(env, NULL, 1)); 211 base::android::ScopedJavaLocalRef<jbyteArray> data =
212 EXPECT_EQ(row.visit_count(), cursor.GetInt(env, NULL, 2)); 212 cursor->GetBlob(env, NULL, 3);
213 base::android::ScopedJavaLocalRef<jbyteArray> data = 213 std::vector<uint8> out;
214 cursor.GetBlob(env, NULL, 3); 214 base::android::JavaByteArrayToByteVector(env, data.obj(), &out);
215 std::vector<uint8> out; 215 EXPECT_EQ(data_bytes->data().size(), out.size());
216 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); 216 EXPECT_EQ(data_bytes->data()[0], out[0]);
217 EXPECT_EQ(data_bytes->data().size(), out.size()); 217 cursor->Destroy(env, NULL);
218 EXPECT_EQ(data_bytes->data()[0], out[0]); 218 // Cursor::Destroy posts the task in UI thread, run Message loop to release
219 } 219 // the statement, delete SQLiteCursor itself etc.
220
221 // Cursor's destructor post the task in UI thread, run Message loop to release
222 // the statement etc.
223 content::RunAllPendingInMessageLoop(); 220 content::RunAllPendingInMessageLoop();
224 } 221 }
OLDNEW
« no previous file with comments | « chrome/browser/history/android/sqlite_cursor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698