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

Side by Side Diff: ash/display/display_color_manager_chromeos_unittest.cc

Issue 1182063002: Add support for more advanced color correction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@qcms-fixed-point-gamma
Patch Set: Rebase after quirks changes Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « ash/display/display_color_manager_chromeos.cc ('k') | ash/display/test_data/4c834a42.icc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ash/display/display_color_manager_chromeos.h" 5 #include "ash/display/display_color_manager_chromeos.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/pattern.h" 12 #include "base/strings/pattern.h"
13 #include "base/test/scoped_path_override.h" 13 #include "base/test/scoped_path_override.h"
14 #include "base/test/sequenced_worker_pool_owner.h" 14 #include "base/test/sequenced_worker_pool_owner.h"
15 #include "chromeos/chromeos_paths.h" 15 #include "chromeos/chromeos_paths.h"
16 #include "components/quirks/quirks_manager.h" 16 #include "components/quirks/quirks_manager.h"
17 #include "net/url_request/url_request_context_getter.h" 17 #include "net/url_request/url_request_context_getter.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/display/chromeos/test/action_logger_util.h" 19 #include "ui/display/chromeos/test/action_logger_util.h"
20 #include "ui/display/chromeos/test/test_display_snapshot.h" 20 #include "ui/display/chromeos/test/test_display_snapshot.h"
21 #include "ui/display/chromeos/test/test_native_display_delegate.h" 21 #include "ui/display/chromeos/test/test_native_display_delegate.h"
22 22
23 namespace ash { 23 namespace ash {
24 24
25 namespace { 25 namespace {
26 26
27 const char kSetGammaAction[] = 27 const char kSetGammaAction[] =
28 "set_gamma_ramp(id=123,rgb[0]*rgb[255]=???????????\?)"; 28 "set_color_correction(id=123,gamma[0]*gamma[255]=???????????\?)";
29 const char kSetFullCTMAction[] =
30 "set_color_correction(id=123,degamma[0]*gamma[0]*ctm[0]*ctm[8]*)";
29 31
30 class DisplayColorManagerForTest : public DisplayColorManager { 32 class DisplayColorManagerForTest : public DisplayColorManager {
31 public: 33 public:
32 DisplayColorManagerForTest(ui::DisplayConfigurator* configurator, 34 DisplayColorManagerForTest(ui::DisplayConfigurator* configurator,
33 base::SequencedWorkerPool* blocking_pool) 35 base::SequencedWorkerPool* blocking_pool)
34 : DisplayColorManager(configurator, blocking_pool) {} 36 : DisplayColorManager(configurator, blocking_pool) {}
35 37
36 void SetOnFinishedForTest(base::Closure on_finished_for_test) { 38 void SetOnFinishedForTest(base::Closure on_finished_for_test) {
37 on_finished_for_test_ = on_finished_for_test; 39 on_finished_for_test_ = on_finished_for_test;
38 } 40 }
39 41
40 private: 42 private:
41 void FinishLoadCalibrationForDisplay(int64_t display_id, 43 void FinishLoadCalibrationForDisplay(int64_t display_id,
42 int64_t product_id, 44 int64_t product_id,
45 bool has_color_correction_matrix,
43 ui::DisplayConnectionType type, 46 ui::DisplayConnectionType type,
44 const base::FilePath& path, 47 const base::FilePath& path,
45 bool file_downloaded) override { 48 bool file_downloaded) override {
46 DisplayColorManager::FinishLoadCalibrationForDisplay( 49 DisplayColorManager::FinishLoadCalibrationForDisplay(
47 display_id, product_id, type, path, file_downloaded); 50 display_id, product_id, has_color_correction_matrix, type, path,
51 file_downloaded);
48 // If path is empty, there is no icc file, and the DCM's work is done. 52 // If path is empty, there is no icc file, and the DCM's work is done.
49 if (path.empty() && !on_finished_for_test_.is_null()) { 53 if (path.empty() && !on_finished_for_test_.is_null()) {
50 on_finished_for_test_.Run(); 54 on_finished_for_test_.Run();
51 on_finished_for_test_.Reset(); 55 on_finished_for_test_.Reset();
52 } 56 }
53 } 57 }
54 58
55 void UpdateCalibrationData(int64_t display_id, 59 void UpdateCalibrationData(int64_t display_id,
56 int64_t product_id, 60 int64_t product_id,
57 scoped_ptr<ColorCalibrationData> data) override { 61 scoped_ptr<ColorCalibrationData> data) override {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 scoped_ptr<base::SequencedWorkerPoolOwner> pool_owner_; 160 scoped_ptr<base::SequencedWorkerPoolOwner> pool_owner_;
157 161
158 private: 162 private:
159 DISALLOW_COPY_AND_ASSIGN(DisplayColorManagerTest); 163 DISALLOW_COPY_AND_ASSIGN(DisplayColorManagerTest);
160 }; 164 };
161 165
162 TEST_F(DisplayColorManagerTest, VCGTOnly) { 166 TEST_F(DisplayColorManagerTest, VCGTOnly) {
163 std::vector<const ui::DisplayMode*> modes; 167 std::vector<const ui::DisplayMode*> modes;
164 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); 168 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f);
165 modes.push_back(&mode); 169 modes.push_back(&mode);
166 scoped_ptr<ui::TestDisplaySnapshot> snapshot = 170 ui::TestDisplaySnapshot snapshot(
167 make_scoped_ptr(new ui::TestDisplaySnapshot( 171 123, gfx::Point(0, 0), /* origin */
168 123, gfx::Point(0, 0), /* origin */ 172 gfx::Size(0, 0), /* physical_size */
169 gfx::Size(0, 0), /* physical_size */ 173 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */
170 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ 174 false, /* is_aspect_preserving_scaling */
171 false, /* is_aspect_preserving_scaling */ 175 0x06af5c10, /* product_id */
172 0x06af5c10, /* product_id */ 176 false, /* has_color_correction_matrix */
173 modes, /* modes */ 177 modes, /* modes */
174 modes[0] /* current_mode */, 178 modes[0] /* current_mode */, modes[0] /* native_mode */);
175 modes[0] /* native_mode */));
176 std::vector<ui::DisplaySnapshot*> outputs; 179 std::vector<ui::DisplaySnapshot*> outputs;
177 outputs.push_back(snapshot.get()); 180 outputs.push_back(&snapshot);
178 native_display_delegate_->set_outputs(outputs); 181 native_display_delegate_->set_outputs(outputs);
179 182
180 configurator_.OnConfigurationChanged(); 183 configurator_.OnConfigurationChanged();
181 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); 184 EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
182 185
183 log_->GetActionsAndClear(); 186 log_->GetActionsAndClear();
184 WaitOnColorCalibration(); 187 WaitOnColorCalibration();
185 EXPECT_TRUE(base::MatchPattern(log_->GetActionsAndClear(), kSetGammaAction)); 188 EXPECT_TRUE(base::MatchPattern(log_->GetActionsAndClear(), kSetGammaAction));
186 } 189 }
187 190
191 TEST_F(DisplayColorManagerTest, VCGTOnlyWithPlatformCTM) {
192 std::vector<const ui::DisplayMode*> modes;
193 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f);
194 modes.push_back(&mode);
195 ui::TestDisplaySnapshot snapshot(
196 123, gfx::Point(0, 0), /* origin */
197 gfx::Size(0, 0), /* physical_size */
198 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */
199 false, /* is_aspect_preserving_scaling */
200 0x06af5c10, /* product_id */
201 true, /* has_color_correction_matrix */
202 modes, /* modes */
203 modes[0] /* current_mode */, modes[0] /* native_mode */);
204 std::vector<ui::DisplaySnapshot*> outputs;
205 outputs.push_back(&snapshot);
206 native_display_delegate_->set_outputs(outputs);
207
208 configurator_.OnConfigurationChanged();
209 EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
210
211 log_->GetActionsAndClear();
212 WaitOnColorCalibration();
213 EXPECT_TRUE(base::MatchPattern(log_->GetActionsAndClear(), kSetGammaAction));
214 }
215
216 TEST_F(DisplayColorManagerTest, FullWithPlatformCTM) {
217 std::vector<const ui::DisplayMode*> modes;
218 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f);
219 modes.push_back(&mode);
220 ui::TestDisplaySnapshot snapshot(
221 123, gfx::Point(0, 0), /* origin */
222 gfx::Size(0, 0), /* physical_size */
223 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */
224 false, /* is_aspect_preserving_scaling */
225 0x4c834a42, /* product_id */
226 true, /* has_color_correction_matrix */
227 modes, /* modes */
228 modes[0] /* current_mode */, modes[0] /* native_mode */);
229 std::vector<ui::DisplaySnapshot*> outputs;
230 outputs.push_back(&snapshot);
231 native_display_delegate_->set_outputs(outputs);
232
233 configurator_.OnConfigurationChanged();
234 EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
235
236 log_->GetActionsAndClear();
237 WaitOnColorCalibration();
238 EXPECT_TRUE(
239 base::MatchPattern(log_->GetActionsAndClear(), kSetFullCTMAction));
240 }
241
242 TEST_F(DisplayColorManagerTest, FullWithoutPlatformCTM) {
243 std::vector<const ui::DisplayMode*> modes;
244 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f);
245 modes.push_back(&mode);
246 ui::TestDisplaySnapshot snapshot(
247 123, gfx::Point(0, 0), /* origin */
248 gfx::Size(0, 0), /* physical_size */
249 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */
250 false, /* is_aspect_preserving_scaling */
251 0x4c834a42, /* product_id */
252 false, /* has_color_correction_matrix */
253 modes, /* modes */
254 modes[0] /* current_mode */, modes[0] /* native_mode */);
255 std::vector<ui::DisplaySnapshot*> outputs;
256 outputs.push_back(&snapshot);
257 native_display_delegate_->set_outputs(outputs);
258
259 configurator_.OnConfigurationChanged();
260 EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
261
262 log_->GetActionsAndClear();
263 WaitOnColorCalibration();
264 EXPECT_STREQ("", log_->GetActionsAndClear().c_str());
265 }
266
188 TEST_F(DisplayColorManagerTest, NoMatchProductID) { 267 TEST_F(DisplayColorManagerTest, NoMatchProductID) {
189 std::vector<const ui::DisplayMode*> modes; 268 std::vector<const ui::DisplayMode*> modes;
190 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); 269 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f);
191 modes.push_back(&mode); 270 modes.push_back(&mode);
192 scoped_ptr<ui::TestDisplaySnapshot> snapshot = 271 ui::TestDisplaySnapshot snapshot(
193 make_scoped_ptr(new ui::TestDisplaySnapshot( 272 123, gfx::Point(0, 0), /* origin */
194 123, gfx::Point(0, 0), /* origin */ 273 gfx::Size(0, 0), /* physical_size */
195 gfx::Size(0, 0), /* physical_size */ 274 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */
196 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ 275 false, /* is_aspect_preserving_scaling */
197 false, /* is_aspect_preserving_scaling */ 276 0, /* product_id */
198 0, /* product_id */ 277 false, /* has_color_correction_matrix */
199 modes, /* modes */ 278 modes, /* modes */
200 modes[0] /* current_mode */, 279 modes[0] /* current_mode */, modes[0] /* native_mode */);
201 modes[0] /* native_mode */));
202 std::vector<ui::DisplaySnapshot*> outputs; 280 std::vector<ui::DisplaySnapshot*> outputs;
203 outputs.push_back(snapshot.get()); 281 outputs.push_back(&snapshot);
204 native_display_delegate_->set_outputs(outputs); 282 native_display_delegate_->set_outputs(outputs);
205 283
206 configurator_.OnConfigurationChanged(); 284 configurator_.OnConfigurationChanged();
207 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); 285 EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
208 286
209 log_->GetActionsAndClear(); 287 log_->GetActionsAndClear();
210 WaitOnColorCalibration(); 288 WaitOnColorCalibration();
211 EXPECT_STREQ("", log_->GetActionsAndClear().c_str()); 289 EXPECT_STREQ("", log_->GetActionsAndClear().c_str());
212 } 290 }
213 291
214 TEST_F(DisplayColorManagerTest, NoVCGT) { 292 TEST_F(DisplayColorManagerTest, NoVCGT) {
215 std::vector<const ui::DisplayMode*> modes; 293 std::vector<const ui::DisplayMode*> modes;
216 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); 294 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f);
217 modes.push_back(&mode); 295 modes.push_back(&mode);
218 scoped_ptr<ui::TestDisplaySnapshot> snapshot = 296 ui::TestDisplaySnapshot snapshot(
219 make_scoped_ptr(new ui::TestDisplaySnapshot( 297 123, gfx::Point(0, 0), /* origin */
220 123, gfx::Point(0, 0), /* origin */ 298 gfx::Size(0, 0), /* physical_size */
221 gfx::Size(0, 0), /* physical_size */ 299 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */
222 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ 300 false, /* is_aspect_preserving_scaling */
223 false, /* is_aspect_preserving_scaling */ 301 0x0dae3211, /* product_id */
224 0x0dae3211, /* product_id */ 302 false, /* has_color_correction_matrix */
225 modes, /* modes */ 303 modes, /* modes */
226 modes[0] /* current_mode */, 304 modes[0] /* current_mode */, modes[0] /* native_mode */);
227 modes[0] /* native_mode */));
228 std::vector<ui::DisplaySnapshot*> outputs; 305 std::vector<ui::DisplaySnapshot*> outputs;
229 outputs.push_back(snapshot.get()); 306 outputs.push_back(&snapshot);
230 native_display_delegate_->set_outputs(outputs); 307 native_display_delegate_->set_outputs(outputs);
231 308
232 configurator_.OnConfigurationChanged(); 309 configurator_.OnConfigurationChanged();
233 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); 310 EXPECT_TRUE(test_api_.TriggerConfigureTimeout());
234 311
235 log_->GetActionsAndClear(); 312 log_->GetActionsAndClear();
236 WaitOnColorCalibration(); 313 WaitOnColorCalibration();
237 EXPECT_STREQ("", log_->GetActionsAndClear().c_str()); 314 EXPECT_STREQ("", log_->GetActionsAndClear().c_str());
238 } 315 }
239 316
240 } // namespace ash 317 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_color_manager_chromeos.cc ('k') | ash/display/test_data/4c834a42.icc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698