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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 current_result_index_(0) { | 113 current_result_index_(0) { |
114 } | 114 } |
115 | 115 |
116 virtual ~MockKMeanImageSampler() { | 116 virtual ~MockKMeanImageSampler() { |
117 } | 117 } |
118 | 118 |
119 void AddSample(int sample) { | 119 void AddSample(int sample) { |
120 prebaked_sample_results_.push_back(sample); | 120 prebaked_sample_results_.push_back(sample); |
121 } | 121 } |
122 | 122 |
123 virtual int GetSample(int width, int height) OVERRIDE { | 123 virtual int GetSample(int width, int height) override { |
124 if (current_result_index_ >= prebaked_sample_results_.size()) { | 124 if (current_result_index_ >= prebaked_sample_results_.size()) { |
125 current_result_index_ = 0; | 125 current_result_index_ = 0; |
126 } | 126 } |
127 | 127 |
128 if (prebaked_sample_results_.empty()) { | 128 if (prebaked_sample_results_.empty()) { |
129 return 0; | 129 return 0; |
130 } | 130 } |
131 | 131 |
132 return prebaked_sample_results_[current_result_index_++]; | 132 return prebaked_sample_results_[current_result_index_++]; |
133 } | 133 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 Calculate8bitBitmapMinMax(result, &min_gl, &max_gl); | 496 Calculate8bitBitmapMinMax(result, &min_gl, &max_gl); |
497 | 497 |
498 EXPECT_EQ(0, min_gl); | 498 EXPECT_EQ(0, min_gl); |
499 EXPECT_EQ(255, max_gl); | 499 EXPECT_EQ(255, max_gl); |
500 EXPECT_EQ(min_gl, SkColorGetA(result.getColor(0, 0))); | 500 EXPECT_EQ(min_gl, SkColorGetA(result.getColor(0, 0))); |
501 EXPECT_EQ(max_gl, SkColorGetA(result.getColor(299, 199))); | 501 EXPECT_EQ(max_gl, SkColorGetA(result.getColor(299, 199))); |
502 EXPECT_EQ(93U, SkColorGetA(result.getColor(150, 0))); | 502 EXPECT_EQ(93U, SkColorGetA(result.getColor(150, 0))); |
503 } | 503 } |
504 | 504 |
505 } // namespace color_utils | 505 } // namespace color_utils |
OLD | NEW |