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

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

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 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 #include <stdint.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/history/history_service_factory.h" 21 #include "chrome/browser/history/history_service_factory.h"
22 #include "chrome/common/chrome_constants.h" 22 #include "chrome/common/chrome_constants.h"
23 #include "chrome/test/base/testing_browser_process.h" 23 #include "chrome/test/base/testing_browser_process.h"
24 #include "chrome/test/base/testing_profile.h" 24 #include "chrome/test/base/testing_profile.h"
25 #include "chrome/test/base/testing_profile_manager.h" 25 #include "chrome/test/base/testing_profile_manager.h"
26 #include "components/bookmarks/test/bookmark_test_helpers.h" 26 #include "components/bookmarks/test/bookmark_test_helpers.h"
27 #include "components/history/core/browser/android/android_history_types.h" 27 #include "components/history/core/browser/android/android_history_types.h"
28 #include "components/history/core/browser/android/android_time.h" 28 #include "components/history/core/browser/android/android_time.h"
29 #include "components/history/core/browser/history_service.h" 29 #include "components/history/core/browser/history_service.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/test/test_browser_thread.h" 31 #include "content/public/test/test_browser_thread_bundle.h"
32 #include "content/public/test/test_utils.h" 32 #include "content/public/test/test_utils.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 34
35 namespace { 35 namespace {
36 36
37 using base::Bind; 37 using base::Bind;
38 using base::Time; 38 using base::Time;
39 using content::BrowserThread;
40 using history::AndroidStatement; 39 using history::AndroidStatement;
41 using history::HistoryAndBookmarkRow; 40 using history::HistoryAndBookmarkRow;
42 using history::SearchRow; 41 using history::SearchRow;
43 42
44 // The test cases in this file don't test the JNI interface which will be 43 // The test cases in this file don't test the JNI interface which will be
45 // covered in Java tests. 44 // covered in Java tests.
46 class SQLiteCursorTest : public testing::Test, 45 class SQLiteCursorTest : public testing::Test,
47 public SQLiteCursor::TestObserver { 46 public SQLiteCursor::TestObserver {
48 public: 47 public:
49 SQLiteCursorTest() 48 SQLiteCursorTest() : profile_manager_(TestingBrowserProcess::GetGlobal()) {}
50 : profile_manager_(
51 TestingBrowserProcess::GetGlobal()),
52 ui_thread_(BrowserThread::UI, &message_loop_),
53 file_thread_(BrowserThread::FILE, &message_loop_) {
54 }
55 ~SQLiteCursorTest() override {} 49 ~SQLiteCursorTest() override {}
56 50
57 protected: 51 protected:
58 void SetUp() override { 52 void SetUp() override {
59 // Setup the testing profile, so the bookmark_model_sql_handler could 53 // Setup the testing profile, so the bookmark_model_sql_handler could
60 // get the bookmark model from it. 54 // get the bookmark model from it.
61 ASSERT_TRUE(profile_manager_.SetUp()); 55 ASSERT_TRUE(profile_manager_.SetUp());
62 // It seems that the name has to be chrome::kInitialProfile, so it 56 // It seems that the name has to be chrome::kInitialProfile, so it
63 // could be found by ProfileManager::GetLastUsedProfile(). 57 // could be found by ProfileManager::GetLastUsedProfile().
64 testing_profile_ = profile_manager_.CreateTestingProfile( 58 testing_profile_ = profile_manager_.CreateTestingProfile(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 run_loop_ = nullptr; 95 run_loop_ = nullptr;
102 } 96 }
103 97
104 void OnGetFaviconResult() override { 98 void OnGetFaviconResult() override {
105 ASSERT_TRUE(run_loop_); 99 ASSERT_TRUE(run_loop_);
106 run_loop_->QuitWhenIdle(); 100 run_loop_->QuitWhenIdle();
107 } 101 }
108 102
109 protected: 103 protected:
110 TestingProfileManager profile_manager_; 104 TestingProfileManager profile_manager_;
111 base::MessageLoop message_loop_; 105 content::TestBrowserThreadBundle test_browser_thread_bundle_;
112 content::TestBrowserThread ui_thread_;
113 content::TestBrowserThread file_thread_;
114 std::unique_ptr<AndroidHistoryProviderService> service_; 106 std::unique_ptr<AndroidHistoryProviderService> service_;
115 base::CancelableTaskTracker cancelable_tracker_; 107 base::CancelableTaskTracker cancelable_tracker_;
116 TestingProfile* testing_profile_; 108 TestingProfile* testing_profile_;
117 history::HistoryService* hs_; 109 history::HistoryService* hs_;
118 std::unique_ptr<base::RunLoop> run_loop_; 110 std::unique_ptr<base::RunLoop> run_loop_;
119 111
120 private: 112 private:
121 DISALLOW_COPY_AND_ASSIGN(SQLiteCursorTest); 113 DISALLOW_COPY_AND_ASSIGN(SQLiteCursorTest);
122 }; 114 };
123 115
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 cursor->GetBlob(env, NULL, 3); 218 cursor->GetBlob(env, NULL, 3);
227 std::vector<uint8_t> out; 219 std::vector<uint8_t> out;
228 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); 220 base::android::JavaByteArrayToByteVector(env, data.obj(), &out);
229 EXPECT_EQ(data_bytes->data().size(), out.size()); 221 EXPECT_EQ(data_bytes->data().size(), out.size());
230 EXPECT_EQ(data_bytes->data()[0], out[0]); 222 EXPECT_EQ(data_bytes->data()[0], out[0]);
231 cursor->Destroy(env, NULL); 223 cursor->Destroy(env, NULL);
232 // Cursor::Destroy posts the task in UI thread, run Message loop to release 224 // Cursor::Destroy posts the task in UI thread, run Message loop to release
233 // the statement, delete SQLiteCursor itself etc. 225 // the statement, delete SQLiteCursor itself etc.
234 content::RunAllPendingInMessageLoop(); 226 content::RunAllPendingInMessageLoop();
235 } 227 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698