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

Unified Diff: chrome/browser/history/android/android_provider_backend_unittest.cc

Issue 2543023003: Fix TestBrowserThread destruction order in Android history tests. (Closed)
Patch Set: undo safe_browsing changes Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/history/android/bookmark_model_sql_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/android/android_provider_backend_unittest.cc
diff --git a/chrome/browser/history/android/android_provider_backend_unittest.cc b/chrome/browser/history/android/android_provider_backend_unittest.cc
index b76070790c159797f9ffdaf11e4739749800575f..12b4f7574f4bb688f7014daac563e07fa586a273 100644
--- a/chrome/browser/history/android/android_provider_backend_unittest.cc
+++ b/chrome/browser/history/android/android_provider_backend_unittest.cc
@@ -11,7 +11,9 @@
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/history/chrome_history_client.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -29,7 +31,7 @@
#include "components/history/core/browser/keyword_search_term.h"
#include "components/history/core/test/test_history_database.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/test/test_browser_thread.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -170,10 +172,13 @@ class AndroidProviderBackendTest : public testing::Test {
AndroidProviderBackendTest()
: thumbnail_db_(NULL),
profile_manager_(TestingBrowserProcess::GetGlobal()),
- bookmark_model_(NULL),
- ui_thread_(BrowserThread::UI, &message_loop_),
- file_thread_(BrowserThread::FILE, &message_loop_) {}
- ~AndroidProviderBackendTest() override {}
+ bookmark_model_(NULL) {}
+
+ ~AndroidProviderBackendTest() override {
+ // Avoid use after frees by running any unhandled tasks before freeing this
+ // fixture's members.
+ base::RunLoop().RunUntilIdle();
+ }
protected:
void SetUp() override {
@@ -245,6 +250,8 @@ class AndroidProviderBackendTest : public testing::Test {
return true;
}
+ content::TestBrowserThreadBundle thread_bundle_;
+
AndroidProviderBackendNotifier notifier_;
scoped_refptr<HistoryBackend> history_backend_;
TestHistoryDatabase history_db_;
@@ -256,9 +263,6 @@ class AndroidProviderBackendTest : public testing::Test {
TestingProfileManager profile_manager_;
BookmarkModel* bookmark_model_;
- base::MessageLoopForUI message_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread file_thread_;
std::unique_ptr<history::HistoryClient> history_client_;
std::unique_ptr<history::HistoryBackendClient> history_backend_client_;
@@ -303,7 +307,7 @@ TEST_F(AndroidProviderBackendTest, UpdateTables) {
scoped_refptr<HistoryBackend> history_backend;
history_backend = new HistoryBackend(new AndroidProviderBackendDelegate(),
history_client_->CreateBackendClient(),
- message_loop_.task_runner());
+ base::ThreadTaskRunnerHandle::Get());
history_backend->Init(false,
TestHistoryDatabaseParamsForPath(temp_dir_.GetPath()));
history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED);
@@ -439,7 +443,7 @@ TEST_F(AndroidProviderBackendTest, QueryHistoryAndBookmarks) {
scoped_refptr<HistoryBackend> history_backend;
history_backend = new HistoryBackend(new AndroidProviderBackendDelegate(),
history_client_->CreateBackendClient(),
- message_loop_.task_runner());
+ base::ThreadTaskRunnerHandle::Get());
history_backend->Init(false,
TestHistoryDatabaseParamsForPath(temp_dir_.GetPath()));
history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED);
@@ -1827,7 +1831,7 @@ TEST_F(AndroidProviderBackendTest, QueryWithoutThumbnailDB) {
scoped_refptr<HistoryBackend> history_backend;
history_backend = new HistoryBackend(new AndroidProviderBackendDelegate(),
history_client_->CreateBackendClient(),
- message_loop_.task_runner());
+ base::ThreadTaskRunnerHandle::Get());
history_backend->Init(false,
TestHistoryDatabaseParamsForPath(temp_dir_.GetPath()));
history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED);
« no previous file with comments | « no previous file | chrome/browser/history/android/bookmark_model_sql_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698