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

Side by Side Diff: chrome/browser/history/android/android_history_provider_service_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/android_history_provider_service.h" 5 #include "chrome/browser/history/android/android_history_provider_service.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/task/cancelable_task_tracker.h" 13 #include "base/task/cancelable_task_tracker.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
16 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
17 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "chrome/test/base/testing_profile_manager.h" 19 #include "chrome/test/base/testing_profile_manager.h"
20 #include "components/bookmarks/test/bookmark_test_helpers.h" 20 #include "components/bookmarks/test/bookmark_test_helpers.h"
21 #include "components/history/core/browser/android/android_history_types.h" 21 #include "components/history/core/browser/android/android_history_types.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread_bundle.h"
24 #include "sql/statement.h" 24 #include "sql/statement.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 namespace { 27 namespace {
28 28
29 using base::Bind; 29 using base::Bind;
30 using base::Time; 30 using base::Time;
31 using content::BrowserThread;
32 using history::AndroidStatement; 31 using history::AndroidStatement;
33 using history::HistoryAndBookmarkRow; 32 using history::HistoryAndBookmarkRow;
34 using history::SearchRow; 33 using history::SearchRow;
35 34
36 // The test cases in this file don't intent to test the detail features of 35 // The test cases in this file don't intent to test the detail features of
37 // Android content provider which have been covered by 36 // Android content provider which have been covered by
38 // android_provider_backend_unittest.cc, instead, they verify the code path to 37 // android_provider_backend_unittest.cc, instead, they verify the code path to
39 // AndroidProviderBackend working fine. 38 // AndroidProviderBackend working fine.
40 39
41 class AndroidHistoryProviderServiceTest : public testing::Test { 40 class AndroidHistoryProviderServiceTest : public testing::Test {
42 public: 41 public:
43 AndroidHistoryProviderServiceTest() 42 AndroidHistoryProviderServiceTest()
44 : profile_manager_( 43 : profile_manager_(TestingBrowserProcess::GetGlobal()) {}
45 TestingBrowserProcess::GetGlobal()),
46 ui_thread_(BrowserThread::UI, &message_loop_),
47 file_thread_(BrowserThread::FILE, &message_loop_) {
48 }
49 ~AndroidHistoryProviderServiceTest() override {} 44 ~AndroidHistoryProviderServiceTest() override {}
50 45
51 protected: 46 protected:
52 void SetUp() override { 47 void SetUp() override {
53 // Setup the testing profile, so the bookmark_model_sql_handler could 48 // Setup the testing profile, so the bookmark_model_sql_handler could
54 // get the bookmark model from it. 49 // get the bookmark model from it.
55 ASSERT_TRUE(profile_manager_.SetUp()); 50 ASSERT_TRUE(profile_manager_.SetUp());
56 // It seems that the name has to be chrome::kInitialProfile, so it 51 // It seems that the name has to be chrome::kInitialProfile, so it
57 // could be found by ProfileManager::GetLastUsedProfile(). 52 // could be found by ProfileManager::GetLastUsedProfile().
58 testing_profile_ = profile_manager_.CreateTestingProfile( 53 testing_profile_ = profile_manager_.CreateTestingProfile(
59 chrome::kInitialProfile); 54 chrome::kInitialProfile);
60 55
61 testing_profile_->CreateBookmarkModel(true); 56 testing_profile_->CreateBookmarkModel(true);
62 bookmarks::test::WaitForBookmarkModelToLoad( 57 bookmarks::test::WaitForBookmarkModelToLoad(
63 BookmarkModelFactory::GetForBrowserContext(testing_profile_)); 58 BookmarkModelFactory::GetForBrowserContext(testing_profile_));
64 ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false)); 59 ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false));
65 service_.reset(new AndroidHistoryProviderService(testing_profile_)); 60 service_.reset(new AndroidHistoryProviderService(testing_profile_));
66 } 61 }
67 62
68 void TearDown() override { 63 void TearDown() override {
69 testing_profile_->DestroyHistoryService(); 64 testing_profile_->DestroyHistoryService();
70 profile_manager_.DeleteTestingProfile(chrome::kInitialProfile); 65 profile_manager_.DeleteTestingProfile(chrome::kInitialProfile);
71 testing_profile_ = nullptr; 66 testing_profile_ = nullptr;
72 } 67 }
73 68
74 protected: 69 protected:
75 TestingProfileManager profile_manager_; 70 TestingProfileManager profile_manager_;
76 base::MessageLoop message_loop_; 71 content::TestBrowserThreadBundle test_browser_thread_bundle_;
77 content::TestBrowserThread ui_thread_;
78 content::TestBrowserThread file_thread_;
79 std::unique_ptr<AndroidHistoryProviderService> service_; 72 std::unique_ptr<AndroidHistoryProviderService> service_;
80 base::CancelableTaskTracker cancelable_tracker_; 73 base::CancelableTaskTracker cancelable_tracker_;
81 TestingProfile* testing_profile_; 74 TestingProfile* testing_profile_;
82 75
83 private: 76 private:
84 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderServiceTest); 77 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderServiceTest);
85 }; 78 };
86 79
87 class CallbackHelper : public base::RefCountedThreadSafe<CallbackHelper> { 80 class CallbackHelper : public base::RefCountedThreadSafe<CallbackHelper> {
88 public: 81 public:
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 service_->DeleteSearchTerms(std::string(), 283 service_->DeleteSearchTerms(std::string(),
291 std::vector<base::string16>(), 284 std::vector<base::string16>(),
292 Bind(&CallbackHelper::OnDeleted, callback.get()), 285 Bind(&CallbackHelper::OnDeleted, callback.get()),
293 &cancelable_tracker_); 286 &cancelable_tracker_);
294 RunMessageLoop(callback.get()); 287 RunMessageLoop(callback.get());
295 EXPECT_TRUE(callback->success()); 288 EXPECT_TRUE(callback->success());
296 EXPECT_EQ(1, callback->count()); 289 EXPECT_EQ(1, callback->count());
297 } 290 }
298 291
299 } // namespace 292 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698