| 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/common/wallpaper/wallpaper_controller.h" | 11 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 12 #include "ash/common/wallpaper/wallpaper_controller_observer.h" | 12 #include "ash/common/wallpaper/wallpaper_controller_observer.h" |
| 13 #include "ash/common/wm_shell.h" | 13 #include "ash/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/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 21 #include "base/numerics/safe_conversions.h" | 21 #include "base/numerics/safe_conversions.h" |
| 22 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 23 #include "base/run_loop.h" | 23 #include "base/run_loop.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 uint64_t pixel_number = bitmap.width() * bitmap.height(); | 116 uint64_t pixel_number = bitmap.width() * bitmap.height(); |
| 117 return SkColorSetARGB((a + pixel_number / 2) / pixel_number, | 117 return SkColorSetARGB((a + pixel_number / 2) / pixel_number, |
| 118 (r + pixel_number / 2) / pixel_number, | 118 (r + pixel_number / 2) / pixel_number, |
| 119 (g + pixel_number / 2) / pixel_number, | 119 (g + pixel_number / 2) / pixel_number, |
| 120 (b + pixel_number / 2) / pixel_number); | 120 (b + pixel_number / 2) / pixel_number); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Obtain wallpaper image and return its average ARGB color. | 123 // Obtain wallpaper image and return its average ARGB color. |
| 124 SkColor GetAverageWallpaperColor() { | 124 SkColor GetAverageWallpaperColor() { |
| 125 const gfx::ImageSkia image = | 125 const gfx::ImageSkia image = |
| 126 ash::WmShell::Get()->wallpaper_controller()->GetWallpaper(); | 126 ash::Shell::GetInstance()->wallpaper_controller()->GetWallpaper(); |
| 127 | 127 |
| 128 const gfx::ImageSkiaRep& representation = image.GetRepresentation(1.); | 128 const gfx::ImageSkiaRep& representation = image.GetRepresentation(1.); |
| 129 if (representation.is_null()) { | 129 if (representation.is_null()) { |
| 130 ADD_FAILURE() << "No image representation."; | 130 ADD_FAILURE() << "No image representation."; |
| 131 return SkColorSetARGB(0, 0, 0, 0); | 131 return SkColorSetARGB(0, 0, 0, 0); |
| 132 } | 132 } |
| 133 | 133 |
| 134 const SkBitmap& bitmap = representation.sk_bitmap(); | 134 const SkBitmap& bitmap = representation.sk_bitmap(); |
| 135 return ComputeAverageColor(bitmap); | 135 return ComputeAverageColor(bitmap); |
| 136 } | 136 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 // Allow policy fetches to fail - these tests instead invoke InjectPolicy() | 213 // Allow policy fetches to fail - these tests instead invoke InjectPolicy() |
| 214 // to directly inject and modify policy dynamically. | 214 // to directly inject and modify policy dynamically. |
| 215 command_line->AppendSwitch(switches::kAllowFailedPolicyFetchForTest); | 215 command_line->AppendSwitch(switches::kAllowFailedPolicyFetchForTest); |
| 216 | 216 |
| 217 LoginManagerTest::SetUpCommandLine(command_line); | 217 LoginManagerTest::SetUpCommandLine(command_line); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void SetUpOnMainThread() override { | 220 void SetUpOnMainThread() override { |
| 221 LoginManagerTest::SetUpOnMainThread(); | 221 LoginManagerTest::SetUpOnMainThread(); |
| 222 ash::WmShell::Get()->wallpaper_controller()->AddObserver(this); | 222 ash::Shell::GetInstance()->wallpaper_controller()->AddObserver(this); |
| 223 | 223 |
| 224 // Set up policy signing. | 224 // Set up policy signing. |
| 225 user_policy_builders_[0] = GetUserPolicyBuilder(testUsers_[0]); | 225 user_policy_builders_[0] = GetUserPolicyBuilder(testUsers_[0]); |
| 226 user_policy_builders_[1] = GetUserPolicyBuilder(testUsers_[1]); | 226 user_policy_builders_[1] = GetUserPolicyBuilder(testUsers_[1]); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void TearDownOnMainThread() override { | 229 void TearDownOnMainThread() override { |
| 230 ash::WmShell::Get()->wallpaper_controller()->RemoveObserver(this); | 230 ash::Shell::GetInstance()->wallpaper_controller()->RemoveObserver(this); |
| 231 LoginManagerTest::TearDownOnMainThread(); | 231 LoginManagerTest::TearDownOnMainThread(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 // ash::WallpaperControllerObserver: | 234 // ash::WallpaperControllerObserver: |
| 235 void OnWallpaperDataChanged() override { | 235 void OnWallpaperDataChanged() override { |
| 236 ++wallpaper_change_count_; | 236 ++wallpaper_change_count_; |
| 237 if (run_loop_) | 237 if (run_loop_) |
| 238 run_loop_->Quit(); | 238 run_loop_->Quit(); |
| 239 } | 239 } |
| 240 | 240 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 437 |
| 438 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { | 438 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { |
| 439 LoginUser(testUsers_[0].GetUserEmail()); | 439 LoginUser(testUsers_[0].GetUserEmail()); |
| 440 | 440 |
| 441 // Wait until wallpaper has been loaded. | 441 // Wait until wallpaper has been loaded. |
| 442 RunUntilWallpaperChangeCount(1); | 442 RunUntilWallpaperChangeCount(1); |
| 443 ASSERT_EQ(kRedImageColor, GetAverageWallpaperColor()); | 443 ASSERT_EQ(kRedImageColor, GetAverageWallpaperColor()); |
| 444 } | 444 } |
| 445 | 445 |
| 446 } // namespace chromeos | 446 } // namespace chromeos |
| OLD | NEW |