Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / history / android / sqlite_cursor_unittest.cc
index f2fff07..4c26105 100644 (file)
 #include "base/android/jni_array.h"
 #include "base/android/jni_string.h"
 #include "base/strings/utf_string_conversions.h"
+#include "base/task/cancelable_task_tracker.h"
 #include "base/time/time.h"
 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/favicon/chrome_favicon_client.h"
+#include "chrome/browser/favicon/chrome_favicon_client_factory.h"
 #include "chrome/browser/favicon/favicon_service.h"
 #include "chrome/browser/history/android/android_history_provider_service.h"
 #include "chrome/browser/history/android/android_history_types.h"
@@ -101,7 +104,7 @@ class SQLiteCursorTest : public testing::Test,
   content::TestBrowserThread ui_thread_;
   content::TestBrowserThread file_thread_;
   scoped_ptr<AndroidHistoryProviderService> service_;
-  CancelableRequestConsumer cancelable_consumer_;
+  base::CancelableTaskTracker cancelable_tracker_;
   TestingProfile* testing_profile_;
   HistoryService* hs_;
 
@@ -125,17 +128,13 @@ class CallbackHelper : public base::RefCountedThreadSafe<CallbackHelper> {
     return statement_;
   }
 
-  void OnInserted(AndroidHistoryProviderService::Handle handle,
-                  bool success,
-                  int64 id) {
-    success_ = success;
+  void OnInserted(int64 id) {
+    success_ = id != 0;
     base::MessageLoop::current()->Quit();
   }
 
-  void OnQueryResult(AndroidHistoryProviderService::Handle handle,
-                     bool success,
-                     AndroidStatement* statement) {
-    success_ = success;
+  void OnQueryResult(AndroidStatement* statement) {
+    success_ = statement != NULL;
     statement_ = statement;
     base::MessageLoop::current()->Quit();
   }
@@ -168,8 +167,10 @@ TEST_F(SQLiteCursorTest, Run) {
   scoped_refptr<CallbackHelper> callback(new CallbackHelper());
 
   // Insert a row and verify it succeeded.
-  service_->InsertHistoryAndBookmark(row, &cancelable_consumer_,
-      Bind(&CallbackHelper::OnInserted, callback.get()));
+  service_->InsertHistoryAndBookmark(
+      row,
+      Bind(&CallbackHelper::OnInserted, callback.get()),
+      &cancelable_tracker_);
 
   base::MessageLoop::current()->Run();
   EXPECT_TRUE(callback->success());
@@ -181,9 +182,13 @@ TEST_F(SQLiteCursorTest, Run) {
   projections.push_back(HistoryAndBookmarkRow::FAVICON);
 
   // Query the inserted row.
-  service_->QueryHistoryAndBookmarks(projections, std::string(),
-      std::vector<base::string16>(), std::string(), &cancelable_consumer_,
-      Bind(&CallbackHelper::OnQueryResult, callback.get()));
+  service_->QueryHistoryAndBookmarks(
+      projections,
+      std::string(),
+      std::vector<base::string16>(),
+      std::string(),
+      Bind(&CallbackHelper::OnQueryResult, callback.get()),
+      &cancelable_tracker_);
   base::MessageLoop::current()->Run();
   ASSERT_TRUE(callback->success());
 
@@ -198,7 +203,10 @@ TEST_F(SQLiteCursorTest, Run) {
   column_names.push_back(HistoryAndBookmarkRow::GetAndroidName(
       HistoryAndBookmarkRow::FAVICON));
 
-  FaviconService* favicon_service = new FaviconService(testing_profile_);
+  FaviconClient* favicon_client =
+      ChromeFaviconClientFactory::GetForProfile(testing_profile_);
+  FaviconService* favicon_service =
+      new FaviconService(testing_profile_, favicon_client);
 
   SQLiteCursor* cursor = new SQLiteCursor(column_names, statement,
       service_.get(), favicon_service);