| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/gfx/vector_canvas.h" | 5 #include "base/gfx/vector_canvas.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 void SaveToFile(const std::wstring& filename) { | 177 void SaveToFile(const std::wstring& filename) { |
| 178 std::vector<unsigned char> compressed; | 178 std::vector<unsigned char> compressed; |
| 179 ASSERT_TRUE(PNGEncoder::Encode(&*data_.begin(), | 179 ASSERT_TRUE(PNGEncoder::Encode(&*data_.begin(), |
| 180 PNGEncoder::FORMAT_BGRA, | 180 PNGEncoder::FORMAT_BGRA, |
| 181 size_.width(), | 181 size_.width(), |
| 182 size_.height(), | 182 size_.height(), |
| 183 row_length_, | 183 row_length_, |
| 184 true, | 184 true, |
| 185 &compressed)); | 185 &compressed)); |
| 186 ASSERT_TRUE(compressed.size()); | 186 ASSERT_TRUE(compressed.size()); |
| 187 FILE* f; | 187 FILE* f = file_util::OpenFile(filename, "wb"); |
| 188 ASSERT_EQ(_wfopen_s(&f, filename.c_str(), L"wbS"), 0); | 188 ASSERT_TRUE(f); |
| 189 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), | 189 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), |
| 190 compressed.size()); | 190 compressed.size()); |
| 191 fclose(f); | 191 file_util::CloseFile(f); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Returns the percentage of the image that is different from the other, | 194 // Returns the percentage of the image that is different from the other, |
| 195 // between 0 and 100. | 195 // between 0 and 100. |
| 196 double PercentageDifferent(const Image& rhs) const { | 196 double PercentageDifferent(const Image& rhs) const { |
| 197 if (size_ != rhs.size_ || row_length_ != rhs.row_length_ || | 197 if (size_ != rhs.size_ || row_length_ != rhs.row_length_ || |
| 198 size_.width() == 0 || size_.height() == 0) | 198 size_.width() == 0 || size_.height() == 0) |
| 199 return 100.; // When of different size or empty, they are 100% different. | 199 return 100.; // When of different size or empty, they are 100% different. |
| 200 | 200 |
| 201 // Compute pixels different in the overlap | 201 // Compute pixels different in the overlap |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 | 999 |
| 1000 { | 1000 { |
| 1001 vcanvas_->rotate(67); | 1001 vcanvas_->rotate(67); |
| 1002 pcanvas_->rotate(67); | 1002 pcanvas_->rotate(67); |
| 1003 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 1003 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 1004 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 1004 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 1005 EXPECT_EQ(0., ProcessImage(L"rotate")); | 1005 EXPECT_EQ(0., ProcessImage(L"rotate")); |
| 1006 } | 1006 } |
| 1007 } | 1007 } |
| 1008 | 1008 |
| OLD | NEW |