| 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/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 void Reset() { | 102 void Reset() { |
| 103 prebaked_sample_results_.clear(); | 103 prebaked_sample_results_.clear(); |
| 104 ResetCounter(); | 104 ResetCounter(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ResetCounter() { | 107 void ResetCounter() { |
| 108 current_result_index_ = 0; | 108 current_result_index_ = 0; |
| 109 } | 109 } |
| 110 | 110 |
| 111 virtual int GetSample(int width, int height) { | 111 virtual int GetSample(int width, int height) OVERRIDE { |
| 112 if (current_result_index_ >= prebaked_sample_results_.size()) { | 112 if (current_result_index_ >= prebaked_sample_results_.size()) { |
| 113 current_result_index_ = 0; | 113 current_result_index_ = 0; |
| 114 } | 114 } |
| 115 | 115 |
| 116 if (prebaked_sample_results_.empty()) { | 116 if (prebaked_sample_results_.empty()) { |
| 117 return 0; | 117 return 0; |
| 118 } | 118 } |
| 119 | 119 |
| 120 return prebaked_sample_results_[current_result_index_++]; | 120 return prebaked_sample_results_[current_result_index_++]; |
| 121 } | 121 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 scoped_refptr<base::RefCountedBytes> png( | 171 scoped_refptr<base::RefCountedBytes> png( |
| 172 new base::RefCountedBytes( | 172 new base::RefCountedBytes( |
| 173 std::vector<unsigned char>( | 173 std::vector<unsigned char>( |
| 174 k1x3BlueRed, | 174 k1x3BlueRed, |
| 175 k1x3BlueRed + sizeof(k1x3BlueRed) / sizeof(unsigned char)))); | 175 k1x3BlueRed + sizeof(k1x3BlueRed) / sizeof(unsigned char)))); |
| 176 | 176 |
| 177 SkColor color = CalculateKMeanColorOfPNG(png, 100, 600, test_sampler); | 177 SkColor color = CalculateKMeanColorOfPNG(png, 100, 600, test_sampler); |
| 178 | 178 |
| 179 EXPECT_EQ(color, SkColorSetARGB(0xFF, 0xFF, 0x00, 0x00)); | 179 EXPECT_EQ(color, SkColorSetARGB(0xFF, 0xFF, 0x00, 0x00)); |
| 180 } | 180 } |
| OLD | NEW |