| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/login/users/wallpaper/wallpaper_manager_test_u
tils.h" | 5 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_u
tils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 LOG(ERROR) << "Image is empty"; | 130 LOG(ERROR) << "Image is empty"; |
| 131 return false; | 131 return false; |
| 132 } | 132 } |
| 133 | 133 |
| 134 const SkBitmap* bitmap = image.bitmap(); | 134 const SkBitmap* bitmap = image.bitmap(); |
| 135 if (!bitmap) { | 135 if (!bitmap) { |
| 136 LOG(ERROR) << "Unable to get bitmap from image"; | 136 LOG(ERROR) << "Unable to get bitmap from image"; |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 | 139 |
| 140 bitmap->lockPixels(); | |
| 141 gfx::Point center = gfx::Rect(image.size()).CenterPoint(); | 140 gfx::Point center = gfx::Rect(image.size()).CenterPoint(); |
| 142 SkColor image_color = bitmap->getColor(center.x(), center.y()); | 141 SkColor image_color = bitmap->getColor(center.x(), center.y()); |
| 143 bitmap->unlockPixels(); | |
| 144 | 142 |
| 145 const int kDiff = 3; | 143 const int kDiff = 3; |
| 146 if (std::abs(static_cast<int>(SkColorGetA(image_color)) - | 144 if (std::abs(static_cast<int>(SkColorGetA(image_color)) - |
| 147 static_cast<int>(SkColorGetA(expected_color))) > kDiff || | 145 static_cast<int>(SkColorGetA(expected_color))) > kDiff || |
| 148 std::abs(static_cast<int>(SkColorGetR(image_color)) - | 146 std::abs(static_cast<int>(SkColorGetR(image_color)) - |
| 149 static_cast<int>(SkColorGetR(expected_color))) > kDiff || | 147 static_cast<int>(SkColorGetR(expected_color))) > kDiff || |
| 150 std::abs(static_cast<int>(SkColorGetG(image_color)) - | 148 std::abs(static_cast<int>(SkColorGetG(image_color)) - |
| 151 static_cast<int>(SkColorGetG(expected_color))) > kDiff || | 149 static_cast<int>(SkColorGetG(expected_color))) > kDiff || |
| 152 std::abs(static_cast<int>(SkColorGetB(image_color)) - | 150 std::abs(static_cast<int>(SkColorGetB(image_color)) - |
| 153 static_cast<int>(SkColorGetB(expected_color))) > kDiff) { | 151 static_cast<int>(SkColorGetB(expected_color))) > kDiff) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 kWallpaperSize, | 222 kWallpaperSize, |
| 225 kLargeChildWallpaperColor)); | 223 kLargeChildWallpaperColor)); |
| 226 | 224 |
| 227 command_line->reset(new base::CommandLine(options)); | 225 command_line->reset(new base::CommandLine(options)); |
| 228 WallpaperManager::Get()->SetCommandLineForTesting(command_line->get()); | 226 WallpaperManager::Get()->SetCommandLineForTesting(command_line->get()); |
| 229 } | 227 } |
| 230 | 228 |
| 231 } // namespace wallpaper_manager_test_utils | 229 } // namespace wallpaper_manager_test_utils |
| 232 | 230 |
| 233 } // namespace chromeos | 231 } // namespace chromeos |
| OLD | NEW |