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