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" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/threading/thread_restrictions.h" |
16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
17 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 18 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
18 #include "chromeos/chromeos_switches.h" | 19 #include "chromeos/chromeos_switches.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/gfx/codec/jpeg_codec.h" | 21 #include "ui/gfx/codec/jpeg_codec.h" |
21 #include "ui/gfx/geometry/point.h" | 22 #include "ui/gfx/geometry/point.h" |
22 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
23 | 24 |
24 namespace chromeos { | 25 namespace chromeos { |
25 | 26 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 SkBitmap bitmap; | 105 SkBitmap bitmap; |
105 bitmap.allocN32Pixels(width, height); | 106 bitmap.allocN32Pixels(width, height); |
106 bitmap.eraseColor(color); | 107 bitmap.eraseColor(color); |
107 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 108 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
108 } | 109 } |
109 | 110 |
110 bool WriteJPEGFile(const base::FilePath& path, | 111 bool WriteJPEGFile(const base::FilePath& path, |
111 int width, | 112 int width, |
112 int height, | 113 int height, |
113 SkColor color) { | 114 SkColor color) { |
| 115 base::ThreadRestrictions::ScopedAllowIO allow_io; |
114 std::vector<unsigned char> output; | 116 std::vector<unsigned char> output; |
115 if (!CreateJPEGImage(width, height, color, &output)) | 117 if (!CreateJPEGImage(width, height, color, &output)) |
116 return false; | 118 return false; |
117 | 119 |
118 size_t bytes_written = base::WriteFile( | 120 size_t bytes_written = base::WriteFile( |
119 path, reinterpret_cast<const char*>(&output[0]), output.size()); | 121 path, reinterpret_cast<const char*>(&output[0]), output.size()); |
120 if (bytes_written != output.size()) { | 122 if (bytes_written != output.size()) { |
121 LOG(ERROR) << "Wrote " << bytes_written << " byte(s) instead of " | 123 LOG(ERROR) << "Wrote " << bytes_written << " byte(s) instead of " |
122 << output.size() << " to " << path.value(); | 124 << output.size() << " to " << path.value(); |
123 return false; | 125 return false; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 kWallpaperSize, | 224 kWallpaperSize, |
223 kLargeChildWallpaperColor)); | 225 kLargeChildWallpaperColor)); |
224 | 226 |
225 command_line->reset(new base::CommandLine(options)); | 227 command_line->reset(new base::CommandLine(options)); |
226 WallpaperManager::Get()->SetCommandLineForTesting(command_line->get()); | 228 WallpaperManager::Get()->SetCommandLineForTesting(command_line->get()); |
227 } | 229 } |
228 | 230 |
229 } // namespace wallpaper_manager_test_utils | 231 } // namespace wallpaper_manager_test_utils |
230 | 232 |
231 } // namespace chromeos | 233 } // namespace chromeos |
OLD | NEW |