| 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_TEST_UTIL_
H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_TEST_UTIL_
H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_TEST_UTIL_
H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_TEST_UTIL_
H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "chrome/browser/image_decoder.h" | 14 #include "chrome/browser/image_decoder.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class FilePath; | 17 class FilePath; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace gfx { | 20 namespace gfx { |
| 21 class ImageSkia; | 21 class ImageSkia; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace chromeos { | 24 namespace chromeos { |
| 25 namespace test { | 25 namespace test { |
| 26 | 26 |
| 27 extern const char kUserAvatarImage1RelativePath[]; | 27 extern const char kUserAvatarImage1RelativePath[]; |
| 28 extern const char kUserAvatarImage2RelativePath[]; | 28 extern const char kUserAvatarImage2RelativePath[]; |
| 29 // Points to a png file with transparent pixels. |
| 30 extern const char kUserAvatarImage3RelativePath[]; |
| 29 | 31 |
| 30 // Returns |true| if the two given images are pixel-for-pixel identical. | 32 // Returns |true| if the two given images are pixel-for-pixel identical. |
| 31 bool AreImagesEqual(const gfx::ImageSkia& first, const gfx::ImageSkia& second); | 33 bool AreImagesEqual(const gfx::ImageSkia& first, const gfx::ImageSkia& second); |
| 32 | 34 |
| 33 class ImageLoader : public ImageDecoder::ImageRequest { | 35 class ImageLoader : public ImageDecoder::ImageRequest { |
| 34 public: | 36 public: |
| 35 explicit ImageLoader(const base::FilePath& path); | 37 explicit ImageLoader(const base::FilePath& path); |
| 36 ~ImageLoader() override; | 38 ~ImageLoader() override; |
| 37 | 39 |
| 38 std::unique_ptr<gfx::ImageSkia> Load(); | 40 std::unique_ptr<gfx::ImageSkia> Load(); |
| 39 | 41 |
| 40 // ImageDecoder::ImageRequest: | 42 // ImageDecoder::ImageRequest: |
| 41 void OnImageDecoded(const SkBitmap& decoded_image) override; | 43 void OnImageDecoded(const SkBitmap& decoded_image) override; |
| 42 void OnDecodeImageFailed() override; | 44 void OnDecodeImageFailed() override; |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 base::FilePath path_; | 47 base::FilePath path_; |
| 46 base::RunLoop run_loop_; | 48 base::RunLoop run_loop_; |
| 47 | 49 |
| 48 std::unique_ptr<gfx::ImageSkia> decoded_image_; | 50 std::unique_ptr<gfx::ImageSkia> decoded_image_; |
| 49 | 51 |
| 50 DISALLOW_COPY_AND_ASSIGN(ImageLoader); | 52 DISALLOW_COPY_AND_ASSIGN(ImageLoader); |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 } // namespace test | 55 } // namespace test |
| 54 } // namespace chromeos | 56 } // namespace chromeos |
| 55 | 57 |
| 56 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_TEST_UT
IL_H_ | 58 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_TEST_UT
IL_H_ |
| OLD | NEW |