| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/chromeos/policy/remote_commands/device_command_screensh
ot_job.h" | 5 #include "chrome/browser/chromeos/policy/remote_commands/device_command_screensh
ot_job.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 scoped_refptr<base::RefCountedBytes> GenerateTestPNG(const int& width, | 118 scoped_refptr<base::RefCountedBytes> GenerateTestPNG(const int& width, |
| 119 const int& height) { | 119 const int& height) { |
| 120 const SkColor background_color = SK_ColorBLUE; | 120 const SkColor background_color = SK_ColorBLUE; |
| 121 SkBitmap bmp; | 121 SkBitmap bmp; |
| 122 bmp.allocN32Pixels(width, height); | 122 bmp.allocN32Pixels(width, height); |
| 123 for (int y = 0; y < height; ++y) { | 123 for (int y = 0; y < height; ++y) { |
| 124 for (int x = 0; x < width; ++x) | 124 for (int x = 0; x < width; ++x) |
| 125 *bmp.getAddr32(x, y) = background_color; | 125 *bmp.getAddr32(x, y) = background_color; |
| 126 } | 126 } |
| 127 SkAutoLockPixels lock(bmp); | |
| 128 scoped_refptr<base::RefCountedBytes> png_bytes(new base::RefCountedBytes()); | 127 scoped_refptr<base::RefCountedBytes> png_bytes(new base::RefCountedBytes()); |
| 129 gfx::PNGCodec::ColorFormat color_format = gfx::PNGCodec::FORMAT_RGBA; | 128 gfx::PNGCodec::ColorFormat color_format = gfx::PNGCodec::FORMAT_RGBA; |
| 130 if (!gfx::PNGCodec::Encode( | 129 if (!gfx::PNGCodec::Encode( |
| 131 reinterpret_cast<const unsigned char*>(bmp.getPixels()), color_format, | 130 reinterpret_cast<const unsigned char*>(bmp.getPixels()), color_format, |
| 132 gfx::Size(bmp.width(), bmp.height()), | 131 gfx::Size(bmp.width(), bmp.height()), |
| 133 static_cast<int>(bmp.rowBytes()), false, | 132 static_cast<int>(bmp.rowBytes()), false, |
| 134 std::vector<gfx::PNGCodec::Comment>(), &png_bytes->data())) { | 133 std::vector<gfx::PNGCodec::Comment>(), &png_bytes->data())) { |
| 135 LOG(ERROR) << "Failed to encode image"; | 134 LOG(ERROR) << "Failed to encode image"; |
| 136 } | 135 } |
| 137 return png_bytes; | 136 return png_bytes; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 base::Bind(&DeviceCommandScreenshotTest::VerifyResults, | 308 base::Bind(&DeviceCommandScreenshotTest::VerifyResults, |
| 310 base::Unretained(this), base::Unretained(job.get()), | 309 base::Unretained(this), base::Unretained(job.get()), |
| 311 RemoteCommandJob::FAILED, | 310 RemoteCommandJob::FAILED, |
| 312 CreatePayloadFromResultCode( | 311 CreatePayloadFromResultCode( |
| 313 DeviceCommandScreenshotJob::FAILURE_AUTHENTICATION))); | 312 DeviceCommandScreenshotJob::FAILURE_AUTHENTICATION))); |
| 314 EXPECT_TRUE(success); | 313 EXPECT_TRUE(success); |
| 315 run_loop_.Run(); | 314 run_loop_.Run(); |
| 316 } | 315 } |
| 317 | 316 |
| 318 } // namespace policy | 317 } // namespace policy |
| OLD | NEW |