Commit b2061e74 authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

Use base::TaskEnvironment in ServiceWorkerStorageControlImplTest

The test will be moved out of content/. Replace BrowserTaskEnvironment
with TaskEnvironment.

Bug: 1016064
Change-Id: I018eeacf44a3d10462ee12c5c688d804115097f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2394898Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804661}
parent 9ca1b848
......@@ -12,12 +12,11 @@
#include "base/containers/span.h"
#include "base/files/scoped_temp_dir.h"
#include "base/test/bind_test_util.h"
#include "base/test/task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "content/browser/service_worker/service_worker_storage.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "mojo/public/cpp/system/data_pipe_utils.h"
#include "net/disk_cache/disk_cache.h"
#include "net/http/http_util.h"
......@@ -168,8 +167,7 @@ int WriteResponseMetadata(
class ServiceWorkerStorageControlImplTest : public testing::Test {
public:
ServiceWorkerStorageControlImplTest()
: task_environment_(BrowserTaskEnvironment::IO_MAINLOOP) {}
ServiceWorkerStorageControlImplTest() = default;
void SetUp() override {
ASSERT_TRUE(user_data_directory_.CreateUniqueTempDir());
......@@ -190,7 +188,7 @@ class ServiceWorkerStorageControlImplTest : public testing::Test {
void DestroyStorage() {
storage_impl_.reset();
disk_cache::FlushCacheThreadForTesting();
content::RunAllTasksUntilIdle();
task_environment().RunUntilIdle();
}
void RestartStorage() {
......@@ -203,6 +201,8 @@ class ServiceWorkerStorageControlImplTest : public testing::Test {
return storage_impl_.get();
}
base::test::TaskEnvironment& task_environment() { return task_environment_; }
void LazyInitializeForTest() { storage_impl_->LazyInitializeForTest(); }
FindRegistrationResult FindRegistrationForClientUrl(const GURL& client_url) {
......@@ -689,7 +689,7 @@ class ServiceWorkerStorageControlImplTest : public testing::Test {
private:
base::ScopedTempDir user_data_directory_;
BrowserTaskEnvironment task_environment_;
base::test::TaskEnvironment task_environment_;
std::unique_ptr<ServiceWorkerStorageControlImpl> storage_impl_;
};
......@@ -1536,8 +1536,7 @@ TEST_F(ServiceWorkerStorageControlImplTest, TrackRunningVersion) {
}
// Make sure all tasks are ran.
// TODO(bashi): Don't rely on RunAllTasksUntilIdle()?
content::RunAllTasksUntilIdle();
task_environment().RunUntilIdle();
// Resources shouldn't be purged because there are two active references.
{
......@@ -1555,7 +1554,7 @@ TEST_F(ServiceWorkerStorageControlImplTest, TrackRunningVersion) {
// Drop the second reference.
reference2.reset();
content::RunAllTasksUntilIdle();
task_environment().RunUntilIdle();
// Resources shouldn't be purged because there is an active reference yet.
{
......@@ -1573,7 +1572,7 @@ TEST_F(ServiceWorkerStorageControlImplTest, TrackRunningVersion) {
// Drop the third reference.
reference3.reset();
content::RunAllTasksUntilIdle();
task_environment().RunUntilIdle();
// Resources should have been purged.
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment