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