blob: a1a0b33e4dd05fa36822958c64c5a4ddce731ec5 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wallpaper/wallpaper_controller_test_api.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h"
namespace ash {
namespace {
const WallpaperInfo kTestWallpaperInfo = {"", WALLPAPER_LAYOUT_CENTER, DEFAULT,
base::Time::Now().LocalMidnight()};
gfx::ImageSkia CreateImageWithColor(const SkColor color) {
gfx::Canvas canvas(gfx::Size(5, 5), 1.0f, true);
canvas.DrawColor(color);
return gfx::ImageSkia::CreateFrom1xBitmap(canvas.GetBitmap());
}
} // namespace
WallpaperControllerTestApi::WallpaperControllerTestApi(
WallpaperController* controller)
: controller_(controller) {}
WallpaperControllerTestApi::~WallpaperControllerTestApi() = default;
SkColor WallpaperControllerTestApi::ApplyColorProducingWallpaper() {
controller_->ShowWallpaperImage(
CreateImageWithColor(SkColorSetRGB(60, 40, 40)), kTestWallpaperInfo,
false /*preview_mode=*/);
return SkColorSetRGB(18, 12, 12);
}
void WallpaperControllerTestApi::StartWallpaperPreview() {
controller_->ShowWallpaperImage(CreateImageWithColor(SK_ColorBLUE),
kTestWallpaperInfo, true /*preview_mode=*/);
}
} // namespace ash