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

Unified Diff: content/browser/indexed_db/indexed_db_factory_unittest.cc

Issue 2930183002: Let IndexedDBContextImpl create its own task runner (Closed)
Patch Set: Use ScopedTaskEnvironment for most tests Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_factory_unittest.cc
diff --git a/content/browser/indexed_db/indexed_db_factory_unittest.cc b/content/browser/indexed_db/indexed_db_factory_unittest.cc
index 374143ad3b935d4c7102bb4ac0e1398f883329ad..2b2fe144050cf8cf2d9069bb99e4baf14d8c7de8 100644
--- a/content/browser/indexed_db/indexed_db_factory_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_factory_unittest.cc
@@ -13,8 +13,8 @@
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/test/test_simple_task_runner.h"
-#include "base/threading/thread_task_runner_handle.h"
+#include "base/test/scoped_task_environment.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "content/browser/indexed_db/indexed_db_connection.h"
#include "content/browser/indexed_db/indexed_db_context_impl.h"
#include "content/browser/indexed_db/indexed_db_data_format_version.h"
@@ -72,13 +72,19 @@ class MockIDBFactory : public IndexedDBFactoryImpl {
class IndexedDBFactoryTest : public testing::Test {
public:
+ IndexedDBFactoryTest()
+ : scoped_task_environment_(
+ base::test::ScopedTaskEnvironment::MainThreadType::UI),
+ quota_manager_proxy_(new MockQuotaManagerProxy(nullptr, nullptr)) {}
+
void SetUp() override {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- task_runner_ = new base::TestSimpleTaskRunner();
- quota_manager_proxy_ = new MockQuotaManagerProxy(nullptr, nullptr);
- context_ = new IndexedDBContextImpl(
- temp_dir_.GetPath(), nullptr /* special_storage_policy */,
- quota_manager_proxy_.get(), task_runner_.get());
+ context_ = new IndexedDBContextImpl(temp_dir_.GetPath(),
+ nullptr /* special_storage_policy */,
+ quota_manager_proxy_.get());
+ // Assign current task runner so that methods on factory can be invoked
+ // directly from test bodies.
+ context_->SetTaskRunnerForTesting(base::SequencedTaskRunnerHandle::Get());
idb_factory_ = new MockIDBFactory(context_.get());
}
@@ -87,17 +93,16 @@ class IndexedDBFactoryTest : public testing::Test {
}
protected:
- IndexedDBFactoryTest() {}
MockIDBFactory* factory() const { return idb_factory_.get(); }
void clear_factory() { idb_factory_ = nullptr; }
IndexedDBContextImpl* context() const { return context_.get(); }
private:
base::ScopedTempDir temp_dir_;
- scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
+ scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_;
scoped_refptr<IndexedDBContextImpl> context_;
scoped_refptr<MockIDBFactory> idb_factory_;
- scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_;
TestBrowserThreadBundle thread_bundle_;
DISALLOW_COPY_AND_ASSIGN(IndexedDBFactoryTest);
@@ -238,7 +243,7 @@ class LookingForQuotaErrorMockCallbacks : public IndexedDBCallbacks {
: IndexedDBCallbacks(nullptr,
url::Origin(),
nullptr,
- base::ThreadTaskRunnerHandle::Get()),
+ base::SequencedTaskRunnerHandle::Get()),
error_called_(false) {}
void OnError(const IndexedDBDatabaseError& error) override {
error_called_ = true;

Powered by Google App Engine
This is Rietveld 408576698