OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/wallpaper/wallpaper_color_calculator.h" | 5 #include "components/wallpaper/wallpaper_color_calculator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 : task_runner_(new base::TestMockTimeTaskRunner()) { | 75 : task_runner_(new base::TestMockTimeTaskRunner()) { |
76 // Creates an |image_| that will yield a non-default prominent color. | 76 // Creates an |image_| that will yield a non-default prominent color. |
77 const gfx::Size kImageSize(300, 200); | 77 const gfx::Size kImageSize(300, 200); |
78 const SkColor kGray = SkColorSetRGB(10, 10, 10); | 78 const SkColor kGray = SkColorSetRGB(10, 10, 10); |
79 const SkColor kVibrantGreen = SkColorSetRGB(25, 200, 25); | 79 const SkColor kVibrantGreen = SkColorSetRGB(25, 200, 25); |
80 | 80 |
81 gfx::Canvas canvas(kImageSize, 1.0f, true); | 81 gfx::Canvas canvas(kImageSize, 1.0f, true); |
82 canvas.FillRect(gfx::Rect(kImageSize), kGray); | 82 canvas.FillRect(gfx::Rect(kImageSize), kGray); |
83 canvas.FillRect(gfx::Rect(0, 1, 300, 1), kVibrantGreen); | 83 canvas.FillRect(gfx::Rect(0, 1, 300, 1), kVibrantGreen); |
84 | 84 |
85 image_ = gfx::ImageSkia::CreateFrom1xBitmap(canvas.ToBitmap()); | 85 image_ = gfx::ImageSkia::CreateFrom1xBitmap(canvas.GetBitmap()); |
86 | 86 |
87 calculator_ = base::MakeUnique<WallpaperColorCalculator>( | 87 calculator_ = base::MakeUnique<WallpaperColorCalculator>( |
88 image_, color_utils::LumaRange::NORMAL, | 88 image_, color_utils::LumaRange::NORMAL, |
89 color_utils::SaturationRange::VIBRANT, nullptr); | 89 color_utils::SaturationRange::VIBRANT, nullptr); |
90 calculator_->AddObserver(&observer_); | 90 calculator_->AddObserver(&observer_); |
91 | 91 |
92 InstallTaskRunner(task_runner_); | 92 InstallTaskRunner(task_runner_); |
93 } | 93 } |
94 | 94 |
95 WallPaperColorCalculatorTest::~WallPaperColorCalculatorTest() {} | 95 WallPaperColorCalculatorTest::~WallPaperColorCalculatorTest() {} |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 calculator_.reset(); | 138 calculator_.reset(); |
139 | 139 |
140 EXPECT_TRUE(task_runner_->HasPendingTask()); | 140 EXPECT_TRUE(task_runner_->HasPendingTask()); |
141 | 141 |
142 task_runner_->RunUntilIdle(); | 142 task_runner_->RunUntilIdle(); |
143 EXPECT_FALSE(observer_.WasNotified()); | 143 EXPECT_FALSE(observer_.WasNotified()); |
144 EXPECT_FALSE(task_runner_->HasPendingTask()); | 144 EXPECT_FALSE(task_runner_->HasPendingTask()); |
145 } | 145 } |
146 | 146 |
147 } // namespace wallpaper | 147 } // namespace wallpaper |
OLD | NEW |