| Index: chromeos/printing/ppd_cache_unittest.cc
|
| diff --git a/chromeos/printing/ppd_cache_unittest.cc b/chromeos/printing/ppd_cache_unittest.cc
|
| index 4aafe9700e03635cc424544705ae297a1ba02c33..dd021f3842f558cc1aaffee80697c8da3e233366 100644
|
| --- a/chromeos/printing/ppd_cache_unittest.cc
|
| +++ b/chromeos/printing/ppd_cache_unittest.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/run_loop.h"
|
| #include "base/single_thread_task_runner.h"
|
| +#include "base/test/scoped_task_environment.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "chromeos/printing/ppd_cache.h"
|
| #include "net/url_request/test_url_request_interceptor.h"
|
| @@ -27,7 +28,10 @@ namespace {
|
| // the test.
|
| class PpdCacheTest : public ::testing::Test {
|
| public:
|
| - PpdCacheTest() : loop_(base::MessageLoop::TYPE_IO) {}
|
| + PpdCacheTest()
|
| + : scoped_task_environment_(
|
| + base::test::ScopedTaskEnvironment::MainThreadType::IO) {}
|
| +
|
| void SetUp() override {
|
| ASSERT_TRUE(ppd_cache_temp_dir_.CreateUniqueTempDir());
|
| }
|
| @@ -37,8 +41,7 @@ class PpdCacheTest : public ::testing::Test {
|
| // a (nonexistant) subdirectory of temp_dir_ to the cache to exercise
|
| // the lazy-creation-of-the-cache-directory code.
|
| scoped_refptr<PpdCache> CreateTestCache() {
|
| - return PpdCache::Create(ppd_cache_temp_dir_.GetPath().Append("Cache"),
|
| - loop_.task_runner().get());
|
| + return PpdCache::Create(ppd_cache_temp_dir_.GetPath().Append("Cache"));
|
| }
|
|
|
| void CaptureFindResult(const PpdCache::FindResult& result) {
|
| @@ -49,6 +52,9 @@ class PpdCacheTest : public ::testing::Test {
|
| void CaptureStoreResult() { ++captured_store_results_; }
|
|
|
| protected:
|
| + // Environment for task schedulers.
|
| + base::test::ScopedTaskEnvironment scoped_task_environment_;
|
| +
|
| // Number of find results we've captured.
|
| int captured_find_results_ = 0;
|
|
|
| @@ -61,7 +67,6 @@ class PpdCacheTest : public ::testing::Test {
|
| // Overrider for DIR_CHROMEOS_PPD_CACHE that points it at a temporary
|
| // directory for the life of the test.
|
| base::ScopedTempDir ppd_cache_temp_dir_;
|
| - base::MessageLoop loop_;
|
| };
|
|
|
|
|
| @@ -70,7 +75,7 @@ TEST_F(PpdCacheTest, SimpleMiss) {
|
| auto cache = CreateTestCache();
|
| cache->Find("foo", base::Bind(&PpdCacheTest::CaptureFindResult,
|
| base::Unretained(this)));
|
| - base::RunLoop().RunUntilIdle();
|
| + scoped_task_environment_.RunUntilIdle();
|
| EXPECT_EQ(captured_find_results_, 1);
|
| EXPECT_FALSE(find_result_.success);
|
| }
|
| @@ -83,19 +88,19 @@ TEST_F(PpdCacheTest, MissThenHit) {
|
|
|
| cache->Find(kTestKey, base::Bind(&PpdCacheTest::CaptureFindResult,
|
| base::Unretained(this)));
|
| - base::RunLoop().RunUntilIdle();
|
| + scoped_task_environment_.RunUntilIdle();
|
| EXPECT_EQ(captured_find_results_, 1);
|
| EXPECT_FALSE(find_result_.success);
|
|
|
| cache->Store(
|
| kTestKey, kTestContents,
|
| base::Bind(&PpdCacheTest::CaptureStoreResult, base::Unretained(this)));
|
| - base::RunLoop().RunUntilIdle();
|
| + scoped_task_environment_.RunUntilIdle();
|
| EXPECT_EQ(captured_store_results_, 1);
|
|
|
| cache->Find(kTestKey, base::Bind(&PpdCacheTest::CaptureFindResult,
|
| base::Unretained(this)));
|
| - base::RunLoop().RunUntilIdle();
|
| + scoped_task_environment_.RunUntilIdle();
|
| EXPECT_EQ(captured_find_results_, 2);
|
| EXPECT_TRUE(find_result_.success);
|
| EXPECT_EQ(find_result_.contents, kTestContents);
|
| @@ -103,7 +108,7 @@ TEST_F(PpdCacheTest, MissThenHit) {
|
|
|
| cache->Find(kTestKey2, base::Bind(&PpdCacheTest::CaptureFindResult,
|
| base::Unretained(this)));
|
| - base::RunLoop().RunUntilIdle();
|
| + scoped_task_environment_.RunUntilIdle();
|
| EXPECT_EQ(captured_find_results_, 3);
|
| EXPECT_FALSE(find_result_.success);
|
| }
|
|
|