| Index: ash/display/display_color_manager_chromeos_unittest.cc
|
| diff --git a/ash/display/display_color_manager_chromeos_unittest.cc b/ash/display/display_color_manager_chromeos_unittest.cc
|
| index 081042e8a6c9018434b992bee9ca55f068d5e9ba..9d64594798c9a5c560d9d1b7d8a5bbb3cd8b812a 100644
|
| --- a/ash/display/display_color_manager_chromeos_unittest.cc
|
| +++ b/ash/display/display_color_manager_chromeos_unittest.cc
|
| @@ -13,6 +13,8 @@
|
| #include "base/test/scoped_path_override.h"
|
| #include "base/test/sequenced_worker_pool_owner.h"
|
| #include "chromeos/chromeos_paths.h"
|
| +#include "components/quirks/quirks_manager.h"
|
| +#include "net/url_request/url_request_context_getter.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "ui/display/chromeos/test/action_logger_util.h"
|
| #include "ui/display/chromeos/test/test_display_snapshot.h"
|
| @@ -22,30 +24,33 @@ namespace ash {
|
|
|
| namespace {
|
|
|
| -// Monitors if any task is processed by the message loop.
|
| -class TaskObserver : public base::MessageLoop::TaskObserver {
|
| +const char kSetGammaAction[] =
|
| + "set_gamma_ramp(id=123,rgb[0]*rgb[255]=???????????\?)";
|
| +
|
| +// Implementation of QuirksManager::Delegate to fake chrome-restricted parts.
|
| +class QuirksManagerDelegateTestImpl : public quirks::QuirksManager::Delegate {
|
| public:
|
| - TaskObserver() { base::MessageLoop::current()->AddTaskObserver(this); }
|
| - ~TaskObserver() override {
|
| - base::MessageLoop::current()->RemoveTaskObserver(this);
|
| + QuirksManagerDelegateTestImpl(base::FilePath color_path)
|
| + : color_path_(color_path) {}
|
| + std::string GetApiKey() const override { return std::string(); }
|
| +
|
| + base::FilePath GetBuiltInDisplayProfileDirectory() const override {
|
| + return color_path_;
|
| }
|
|
|
| - // MessageLoop::TaskObserver overrides.
|
| - void WillProcessTask(const base::PendingTask& pending_task) override {}
|
| - void DidProcessTask(const base::PendingTask& pending_task) override {
|
| - base::MessageLoop::current()->QuitWhenIdle();
|
| + base::FilePath GetDownloadDisplayProfileDirectory() const override {
|
| + return base::FilePath();
|
| }
|
| + void CheckDaysSinceOobe() override {}
|
| + int GetDaysSinceOobe() const override { return 60; }
|
|
|
| private:
|
| - DISALLOW_COPY_AND_ASSIGN(TaskObserver);
|
| -};
|
| + ~QuirksManagerDelegateTestImpl() override = default;
|
|
|
| -// Run at least one task. WARNING: Will not return unless there is at least one
|
| -// task to be processed.
|
| -void RunBlockingPoolTask() {
|
| - TaskObserver task_observer;
|
| - base::RunLoop().Run();
|
| -}
|
| + base::FilePath color_path_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(QuirksManagerDelegateTestImpl);
|
| +};
|
|
|
| } // namespace
|
|
|
| @@ -71,9 +76,22 @@ class DisplayColorManagerTest : public testing::Test {
|
| .Append(FILE_PATH_LITERAL("test_data"));
|
| path_override_.reset(new base::ScopedPathOverride(
|
| chromeos::DIR_DEVICE_COLOR_CALIBRATION_PROFILES, color_path_));
|
| +
|
| + quirks::QuirksManager::Initialize(
|
| + new QuirksManagerDelegateTestImpl(color_path_),
|
| + pool_owner_->pool().get(), nullptr, nullptr);
|
| + }
|
| +
|
| + void TearDown() override {
|
| + quirks::QuirksManager::Shutdown();
|
| + pool_owner_->pool()->Shutdown();
|
| }
|
|
|
| - void TearDown() override { pool_owner_->pool()->Shutdown(); }
|
| + void WaitOnColorCalibration() {
|
| + base::RunLoop run_loop;
|
| + color_manager_->SetOnFinishedForTest(run_loop.QuitClosure());
|
| + run_loop.Run();
|
| + }
|
|
|
| DisplayColorManagerTest() : test_api_(&configurator_) {}
|
| ~DisplayColorManagerTest() override {}
|
| @@ -114,13 +132,10 @@ TEST_F(DisplayColorManagerTest, VCGTOnly) {
|
|
|
| configurator_.OnConfigurationChanged();
|
| EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
| - log_->GetActionsAndClear();
|
| -
|
| - RunBlockingPoolTask();
|
|
|
| - EXPECT_TRUE(base::MatchPattern(
|
| - log_->GetActionsAndClear(),
|
| - "set_gamma_ramp(id=123,rgb[0]*rgb[255]=???????????\?)"));
|
| + log_->GetActionsAndClear();
|
| + WaitOnColorCalibration();
|
| + EXPECT_TRUE(base::MatchPattern(log_->GetActionsAndClear(), kSetGammaAction));
|
| }
|
|
|
| TEST_F(DisplayColorManagerTest, NoMatchProductID) {
|
| @@ -145,7 +160,7 @@ TEST_F(DisplayColorManagerTest, NoMatchProductID) {
|
| EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
|
|
| log_->GetActionsAndClear();
|
| - RunBlockingPoolTask();
|
| + WaitOnColorCalibration();
|
| EXPECT_STREQ("", log_->GetActionsAndClear().c_str());
|
| }
|
|
|
| @@ -171,7 +186,7 @@ TEST_F(DisplayColorManagerTest, NoVCGT) {
|
| EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
|
|
|
| log_->GetActionsAndClear();
|
| - RunBlockingPoolTask();
|
| + WaitOnColorCalibration();
|
| EXPECT_STREQ("", log_->GetActionsAndClear().c_str());
|
| }
|
|
|
|
|