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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/shell.h" | 11 #include "ash/common/wallpaper/wallpaper_controller.h" |
12 #include "ash/wallpaper/wallpaper_controller.h" | 12 #include "ash/common/wallpaper/wallpaper_controller_observer.h" |
13 #include "ash/wallpaper/wallpaper_controller_observer.h" | 13 #include "ash/common/wm_shell.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
18 #include "base/json/json_writer.h" | 18 #include "base/json/json_writer.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
22 #include "chrome/browser/chromeos/login/login_manager_test.h" | 22 #include "chrome/browser/chromeos/login/login_manager_test.h" |
23 #include "chrome/browser/chromeos/login/startup_utils.h" | 23 #include "chrome/browser/chromeos/login/startup_utils.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 uint64_t pixel_number = bitmap.width() * bitmap.height(); | 108 uint64_t pixel_number = bitmap.width() * bitmap.height(); |
109 return SkColorSetARGB((a + pixel_number / 2) / pixel_number, | 109 return SkColorSetARGB((a + pixel_number / 2) / pixel_number, |
110 (r + pixel_number / 2) / pixel_number, | 110 (r + pixel_number / 2) / pixel_number, |
111 (g + pixel_number / 2) / pixel_number, | 111 (g + pixel_number / 2) / pixel_number, |
112 (b + pixel_number / 2) / pixel_number); | 112 (b + pixel_number / 2) / pixel_number); |
113 } | 113 } |
114 | 114 |
115 // Obtain wallpaper image and return its average ARGB color. | 115 // Obtain wallpaper image and return its average ARGB color. |
116 SkColor GetAverageWallpaperColor() { | 116 SkColor GetAverageWallpaperColor() { |
117 const gfx::ImageSkia image = | 117 const gfx::ImageSkia image = |
118 ash::Shell::GetInstance()->wallpaper_controller()->GetWallpaper(); | 118 ash::WmShell::Get()->wallpaper_controller()->GetWallpaper(); |
119 | 119 |
120 const gfx::ImageSkiaRep& representation = image.GetRepresentation(1.); | 120 const gfx::ImageSkiaRep& representation = image.GetRepresentation(1.); |
121 if (representation.is_null()) { | 121 if (representation.is_null()) { |
122 ADD_FAILURE() << "No image representation."; | 122 ADD_FAILURE() << "No image representation."; |
123 return SkColorSetARGB(0, 0, 0, 0); | 123 return SkColorSetARGB(0, 0, 0, 0); |
124 } | 124 } |
125 | 125 |
126 const SkBitmap& bitmap = representation.sk_bitmap(); | 126 const SkBitmap& bitmap = representation.sk_bitmap(); |
127 return ComputeAverageColor(bitmap); | 127 return ComputeAverageColor(bitmap); |
128 } | 128 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 // Allow policy fetches to fail - these tests instead invoke InjectPolicy() | 193 // Allow policy fetches to fail - these tests instead invoke InjectPolicy() |
194 // to directly inject and modify policy dynamically. | 194 // to directly inject and modify policy dynamically. |
195 command_line->AppendSwitch(switches::kAllowFailedPolicyFetchForTest); | 195 command_line->AppendSwitch(switches::kAllowFailedPolicyFetchForTest); |
196 | 196 |
197 LoginManagerTest::SetUpCommandLine(command_line); | 197 LoginManagerTest::SetUpCommandLine(command_line); |
198 } | 198 } |
199 | 199 |
200 void SetUpOnMainThread() override { | 200 void SetUpOnMainThread() override { |
201 LoginManagerTest::SetUpOnMainThread(); | 201 LoginManagerTest::SetUpOnMainThread(); |
202 ash::Shell::GetInstance()->wallpaper_controller()->AddObserver(this); | 202 ash::WmShell::Get()->wallpaper_controller()->AddObserver(this); |
203 | 203 |
204 // Set up policy signing. | 204 // Set up policy signing. |
205 user_policy_builders_[0] = GetUserPolicyBuilder(testUsers_[0]); | 205 user_policy_builders_[0] = GetUserPolicyBuilder(testUsers_[0]); |
206 user_policy_builders_[1] = GetUserPolicyBuilder(testUsers_[1]); | 206 user_policy_builders_[1] = GetUserPolicyBuilder(testUsers_[1]); |
207 } | 207 } |
208 | 208 |
209 void TearDownOnMainThread() override { | 209 void TearDownOnMainThread() override { |
210 ash::Shell::GetInstance()->wallpaper_controller()->RemoveObserver(this); | 210 ash::WmShell::Get()->wallpaper_controller()->RemoveObserver(this); |
211 LoginManagerTest::TearDownOnMainThread(); | 211 LoginManagerTest::TearDownOnMainThread(); |
212 } | 212 } |
213 | 213 |
214 // ash::WallpaperControllerObserver: | 214 // ash::WallpaperControllerObserver: |
215 void OnWallpaperDataChanged() override { | 215 void OnWallpaperDataChanged() override { |
216 ++wallpaper_change_count_; | 216 ++wallpaper_change_count_; |
217 if (run_loop_) | 217 if (run_loop_) |
218 run_loop_->Quit(); | 218 run_loop_->Quit(); |
219 } | 219 } |
220 | 220 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 414 |
415 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { | 415 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { |
416 LoginUser(testUsers_[0].GetUserEmail()); | 416 LoginUser(testUsers_[0].GetUserEmail()); |
417 | 417 |
418 // Wait until wallpaper has been loaded. | 418 // Wait until wallpaper has been loaded. |
419 RunUntilWallpaperChangeCount(1); | 419 RunUntilWallpaperChangeCount(1); |
420 ASSERT_EQ(kRedImageColor, GetAverageWallpaperColor()); | 420 ASSERT_EQ(kRedImageColor, GetAverageWallpaperColor()); |
421 } | 421 } |
422 | 422 |
423 } // namespace chromeos | 423 } // namespace chromeos |
OLD | NEW |