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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_TEST_UTILS_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_TEST_UTILS_H_
10 #include "ash/ash_constants.h"
11 #include "ui/gfx/image/image_skia.h"
19 namespace wallpaper_manager_test_utils
{
21 // Colors used for different default wallpapers by CreateCmdlineWallpapers().
22 extern const SkColor kLargeDefaultWallpaperColor
;
23 extern const SkColor kSmallDefaultWallpaperColor
;
24 extern const SkColor kLargeGuestWallpaperColor
;
25 extern const SkColor kSmallGuestWallpaperColor
;
26 extern const SkColor kLargeChildWallpaperColor
;
27 extern const SkColor kSmallChildWallpaperColor
;
29 // A custom color, specifically chosen to not
30 // conflict with any of the default wallpaper colors.
31 extern const SkColor kCustomWallpaperColor
;
33 // Dimension used for width and height of default wallpaper images. A
34 // small value is used to minimize the amount of time spent compressing
35 // and writing images.
36 extern const int kWallpaperSize
;
38 // Creates compressed JPEG image of solid color.
39 // Result bytes are written to |output|.
40 // Returns true if gfx::JPEGCodec::Encode() succeeds.
41 bool CreateJPEGImage(int width
,
44 std::vector
<unsigned char>* output
);
46 // Creates a test image of given size.
47 gfx::ImageSkia
CreateTestImage(int width
, int height
, SkColor color
);
49 // Writes a JPEG image of the specified size and color to |path|. Returns
51 bool WriteJPEGFile(const base::FilePath
& path
,
56 // Returns true if the color at the center of |image| is close to
57 // |expected_color|. (The center is used so small wallpaper images can be
59 bool ImageIsNearColor(gfx::ImageSkia image
, SkColor expected_color
);
61 // Wait until all wallpaper loading is done, and WallpaperManager comes into
63 void WaitAsyncWallpaperLoadFinished();
65 // Initializes default wallpaper paths "*default_*file" and writes JPEG
66 // wallpaper images to them.
67 // Only needs to be called (once) by tests that want to test loading of
68 // default wallpapers.
69 void CreateCmdlineWallpapers(const base::ScopedTempDir
& dir
,
70 scoped_ptr
<base::CommandLine
>* command_line
);
72 } // namespace wallpaper_manager_test_utils
73 } // namespace chromeos
75 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_TEST_UTILS_H_