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

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

Issue 370663002: Revert 281304 "Pass an instance of FaviconClient to FaviconService." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 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
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"
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_model_factory.h"
15 #include "chrome/browser/favicon/chrome_favicon_client.h"
16 #include "chrome/browser/favicon/chrome_favicon_client_factory.h"
17 #include "chrome/browser/favicon/favicon_service.h" 15 #include "chrome/browser/favicon/favicon_service.h"
18 #include "chrome/browser/history/android/android_history_provider_service.h" 16 #include "chrome/browser/history/android/android_history_provider_service.h"
19 #include "chrome/browser/history/android/android_history_types.h" 17 #include "chrome/browser/history/android/android_history_types.h"
20 #include "chrome/browser/history/android/android_time.h" 18 #include "chrome/browser/history/android/android_time.h"
21 #include "chrome/browser/history/history_service.h" 19 #include "chrome/browser/history/history_service.h"
22 #include "chrome/browser/history/history_service_factory.h" 20 #include "chrome/browser/history/history_service_factory.h"
23 #include "chrome/common/chrome_constants.h" 21 #include "chrome/common/chrome_constants.h"
24 #include "chrome/test/base/testing_browser_process.h" 22 #include "chrome/test/base/testing_browser_process.h"
25 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
26 #include "chrome/test/base/testing_profile_manager.h" 24 #include "chrome/test/base/testing_profile_manager.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 std::vector<std::string> column_names; 191 std::vector<std::string> column_names;
194 column_names.push_back( 192 column_names.push_back(
195 HistoryAndBookmarkRow::GetAndroidName(HistoryAndBookmarkRow::URL)); 193 HistoryAndBookmarkRow::GetAndroidName(HistoryAndBookmarkRow::URL));
196 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( 194 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName(
197 HistoryAndBookmarkRow::LAST_VISIT_TIME)); 195 HistoryAndBookmarkRow::LAST_VISIT_TIME));
198 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( 196 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName(
199 HistoryAndBookmarkRow::VISIT_COUNT)); 197 HistoryAndBookmarkRow::VISIT_COUNT));
200 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( 198 column_names.push_back(HistoryAndBookmarkRow::GetAndroidName(
201 HistoryAndBookmarkRow::FAVICON)); 199 HistoryAndBookmarkRow::FAVICON));
202 200
203 FaviconClient* favicon_client = 201 FaviconService* favicon_service = new FaviconService(testing_profile_);
204 ChromeFaviconClientFactory::GetForProfile(testing_profile_);
205 FaviconService* favicon_service =
206 new FaviconService(testing_profile_, favicon_client);
207 202
208 SQLiteCursor* cursor = new SQLiteCursor(column_names, statement, 203 SQLiteCursor* cursor = new SQLiteCursor(column_names, statement,
209 service_.get(), favicon_service); 204 service_.get(), favicon_service);
210 cursor->set_test_observer(this); 205 cursor->set_test_observer(this);
211 JNIEnv* env = base::android::AttachCurrentThread(); 206 JNIEnv* env = base::android::AttachCurrentThread();
212 EXPECT_EQ(1, cursor->GetCount(env, NULL)); 207 EXPECT_EQ(1, cursor->GetCount(env, NULL));
213 EXPECT_EQ(0, cursor->MoveTo(env, NULL, 0)); 208 EXPECT_EQ(0, cursor->MoveTo(env, NULL, 0));
214 EXPECT_EQ(row.url().spec(), base::android::ConvertJavaStringToUTF8( 209 EXPECT_EQ(row.url().spec(), base::android::ConvertJavaStringToUTF8(
215 cursor->GetString(env, NULL, 0)).c_str()); 210 cursor->GetString(env, NULL, 0)).c_str());
216 EXPECT_EQ(history::ToDatabaseTime(row.last_visit_time()), 211 EXPECT_EQ(history::ToDatabaseTime(row.last_visit_time()),
217 cursor->GetLong(env, NULL, 1)); 212 cursor->GetLong(env, NULL, 1));
218 EXPECT_EQ(row.visit_count(), cursor->GetInt(env, NULL, 2)); 213 EXPECT_EQ(row.visit_count(), cursor->GetInt(env, NULL, 2));
219 base::android::ScopedJavaLocalRef<jbyteArray> data = 214 base::android::ScopedJavaLocalRef<jbyteArray> data =
220 cursor->GetBlob(env, NULL, 3); 215 cursor->GetBlob(env, NULL, 3);
221 std::vector<uint8> out; 216 std::vector<uint8> out;
222 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); 217 base::android::JavaByteArrayToByteVector(env, data.obj(), &out);
223 EXPECT_EQ(data_bytes->data().size(), out.size()); 218 EXPECT_EQ(data_bytes->data().size(), out.size());
224 EXPECT_EQ(data_bytes->data()[0], out[0]); 219 EXPECT_EQ(data_bytes->data()[0], out[0]);
225 cursor->Destroy(env, NULL); 220 cursor->Destroy(env, NULL);
226 // Cursor::Destroy posts the task in UI thread, run Message loop to release 221 // Cursor::Destroy posts the task in UI thread, run Message loop to release
227 // the statement, delete SQLiteCursor itself etc. 222 // the statement, delete SQLiteCursor itself etc.
228 content::RunAllPendingInMessageLoop(); 223 content::RunAllPendingInMessageLoop();
229 } 224 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/favicon/favicon_service_factory.cc ('k') | trunk/src/chrome/test/base/testing_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698