OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/color_analysis.h" | 5 #include "ui/gfx/color_analysis.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 current_result_index_(0) { | 97 current_result_index_(0) { |
98 } | 98 } |
99 | 99 |
100 virtual ~MockKMeanImageSampler() { | 100 virtual ~MockKMeanImageSampler() { |
101 } | 101 } |
102 | 102 |
103 void AddSample(int sample) { | 103 void AddSample(int sample) { |
104 prebaked_sample_results_.push_back(sample); | 104 prebaked_sample_results_.push_back(sample); |
105 } | 105 } |
106 | 106 |
107 void Reset() { | |
108 prebaked_sample_results_.clear(); | |
109 ResetCounter(); | |
110 } | |
111 | |
112 void ResetCounter() { | |
113 current_result_index_ = 0; | |
114 } | |
115 | |
116 virtual int GetSample(int width, int height) OVERRIDE { | 107 virtual int GetSample(int width, int height) OVERRIDE { |
117 if (current_result_index_ >= prebaked_sample_results_.size()) { | 108 if (current_result_index_ >= prebaked_sample_results_.size()) { |
118 current_result_index_ = 0; | 109 current_result_index_ = 0; |
119 } | 110 } |
120 | 111 |
121 if (prebaked_sample_results_.empty()) { | 112 if (prebaked_sample_results_.empty()) { |
122 return 0; | 113 return 0; |
123 } | 114 } |
124 | 115 |
125 return prebaked_sample_results_[current_result_index_++]; | 116 return prebaked_sample_results_[current_result_index_++]; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 uint8_t min_gl = 0; | 461 uint8_t min_gl = 0; |
471 uint8_t max_gl = 0; | 462 uint8_t max_gl = 0; |
472 Calculate8bitBitmapMinMax(result, &min_gl, &max_gl); | 463 Calculate8bitBitmapMinMax(result, &min_gl, &max_gl); |
473 | 464 |
474 EXPECT_EQ(0, min_gl); | 465 EXPECT_EQ(0, min_gl); |
475 EXPECT_EQ(255, max_gl); | 466 EXPECT_EQ(255, max_gl); |
476 EXPECT_EQ(min_gl, SkColorGetA(result.getColor(0, 0))); | 467 EXPECT_EQ(min_gl, SkColorGetA(result.getColor(0, 0))); |
477 EXPECT_EQ(max_gl, SkColorGetA(result.getColor(299, 199))); | 468 EXPECT_EQ(max_gl, SkColorGetA(result.getColor(299, 199))); |
478 EXPECT_EQ(93U, SkColorGetA(result.getColor(150, 0))); | 469 EXPECT_EQ(93U, SkColorGetA(result.getColor(150, 0))); |
479 } | 470 } |
OLD | NEW |