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> |
| 6 |
5 #include <string> | 7 #include <string> |
6 #include <vector> | 8 #include <vector> |
7 | 9 |
8 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
9 #include "ash/desktop_background/desktop_background_controller_observer.h" | 11 #include "ash/desktop_background/desktop_background_controller_observer.h" |
10 #include "ash/shell.h" | 12 #include "ash/shell.h" |
11 #include "base/basictypes.h" | |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
15 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
16 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
| 18 #include "base/macros.h" |
17 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
18 #include "base/path_service.h" | 20 #include "base/path_service.h" |
19 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
20 #include "chrome/browser/chromeos/login/login_manager_test.h" | 22 #include "chrome/browser/chromeos/login/login_manager_test.h" |
21 #include "chrome/browser/chromeos/login/startup_utils.h" | 23 #include "chrome/browser/chromeos/login/startup_utils.h" |
22 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 24 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
23 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 25 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
24 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u
til.h" | 26 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u
til.h" |
25 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 27 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
26 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 28 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return SkColorSetARGB(0, 0, 0, 0); | 84 return SkColorSetARGB(0, 0, 0, 0); |
83 } | 85 } |
84 if (bitmap.isNull()) { | 86 if (bitmap.isNull()) { |
85 ADD_FAILURE() << "Bitmap has no pixelref."; | 87 ADD_FAILURE() << "Bitmap has no pixelref."; |
86 return SkColorSetARGB(0, 0, 0, 0); | 88 return SkColorSetARGB(0, 0, 0, 0); |
87 } | 89 } |
88 if (bitmap.colorType() == kUnknown_SkColorType) { | 90 if (bitmap.colorType() == kUnknown_SkColorType) { |
89 ADD_FAILURE() << "Bitmap has not been configured."; | 91 ADD_FAILURE() << "Bitmap has not been configured."; |
90 return SkColorSetARGB(0, 0, 0, 0); | 92 return SkColorSetARGB(0, 0, 0, 0); |
91 } | 93 } |
92 uint64 a = 0, r = 0, g = 0, b = 0; | 94 uint64_t a = 0, r = 0, g = 0, b = 0; |
93 bitmap.lockPixels(); | 95 bitmap.lockPixels(); |
94 for (int x = 0; x < bitmap.width(); ++x) { | 96 for (int x = 0; x < bitmap.width(); ++x) { |
95 for (int y = 0; y < bitmap.height(); ++y) { | 97 for (int y = 0; y < bitmap.height(); ++y) { |
96 const SkColor color = bitmap.getColor(x, y); | 98 const SkColor color = bitmap.getColor(x, y); |
97 a += SkColorGetA(color); | 99 a += SkColorGetA(color); |
98 r += SkColorGetR(color); | 100 r += SkColorGetR(color); |
99 g += SkColorGetG(color); | 101 g += SkColorGetG(color); |
100 b += SkColorGetB(color); | 102 b += SkColorGetB(color); |
101 } | 103 } |
102 } | 104 } |
103 bitmap.unlockPixels(); | 105 bitmap.unlockPixels(); |
104 uint64 pixel_number = bitmap.width() * bitmap.height(); | 106 uint64_t pixel_number = bitmap.width() * bitmap.height(); |
105 return SkColorSetARGB((a + pixel_number / 2) / pixel_number, | 107 return SkColorSetARGB((a + pixel_number / 2) / pixel_number, |
106 (r + pixel_number / 2) / pixel_number, | 108 (r + pixel_number / 2) / pixel_number, |
107 (g + pixel_number / 2) / pixel_number, | 109 (g + pixel_number / 2) / pixel_number, |
108 (b + pixel_number / 2) / pixel_number); | 110 (b + pixel_number / 2) / pixel_number); |
109 } | 111 } |
110 | 112 |
111 // Obtain background image and return its average ARGB color. | 113 // Obtain background image and return its average ARGB color. |
112 SkColor GetAverageBackgroundColor() { | 114 SkColor GetAverageBackgroundColor() { |
113 const gfx::ImageSkia image = | 115 const gfx::ImageSkia image = |
114 ash::Shell::GetInstance()->desktop_background_controller()-> | 116 ash::Shell::GetInstance()->desktop_background_controller()-> |
(...skipping 29 matching lines...) Expand all Loading... |
144 const AccountId& account_id) { | 146 const AccountId& account_id) { |
145 scoped_ptr<policy::UserPolicyBuilder> | 147 scoped_ptr<policy::UserPolicyBuilder> |
146 user_policy_builder(new policy::UserPolicyBuilder()); | 148 user_policy_builder(new policy::UserPolicyBuilder()); |
147 base::FilePath user_keys_dir; | 149 base::FilePath user_keys_dir; |
148 EXPECT_TRUE(PathService::Get(DIR_USER_POLICY_KEYS, &user_keys_dir)); | 150 EXPECT_TRUE(PathService::Get(DIR_USER_POLICY_KEYS, &user_keys_dir)); |
149 const std::string sanitized_user_id = | 151 const std::string sanitized_user_id = |
150 CryptohomeClient::GetStubSanitizedUsername(account_id.GetUserEmail()); | 152 CryptohomeClient::GetStubSanitizedUsername(account_id.GetUserEmail()); |
151 const base::FilePath user_key_file = | 153 const base::FilePath user_key_file = |
152 user_keys_dir.AppendASCII(sanitized_user_id) | 154 user_keys_dir.AppendASCII(sanitized_user_id) |
153 .AppendASCII("policy.pub"); | 155 .AppendASCII("policy.pub"); |
154 std::vector<uint8> user_key_bits; | 156 std::vector<uint8_t> user_key_bits; |
155 EXPECT_TRUE(user_policy_builder->GetSigningKey()-> | 157 EXPECT_TRUE(user_policy_builder->GetSigningKey()-> |
156 ExportPublicKey(&user_key_bits)); | 158 ExportPublicKey(&user_key_bits)); |
157 EXPECT_TRUE(base::CreateDirectory(user_key_file.DirName())); | 159 EXPECT_TRUE(base::CreateDirectory(user_key_file.DirName())); |
158 EXPECT_EQ(base::WriteFile( | 160 EXPECT_EQ(base::WriteFile( |
159 user_key_file, | 161 user_key_file, |
160 reinterpret_cast<const char*>(user_key_bits.data()), | 162 reinterpret_cast<const char*>(user_key_bits.data()), |
161 user_key_bits.size()), | 163 user_key_bits.size()), |
162 static_cast<int>(user_key_bits.size())); | 164 static_cast<int>(user_key_bits.size())); |
163 user_policy_builder->policy_data().set_username(account_id.GetUserEmail()); | 165 user_policy_builder->policy_data().set_username(account_id.GetUserEmail()); |
164 return user_policy_builder.Pass(); | 166 return user_policy_builder.Pass(); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 404 |
403 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { | 405 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { |
404 LoginUser(testUsers_[0].GetUserEmail()); | 406 LoginUser(testUsers_[0].GetUserEmail()); |
405 | 407 |
406 // Wait until wallpaper has been loaded. | 408 // Wait until wallpaper has been loaded. |
407 RunUntilWallpaperChangeCount(1); | 409 RunUntilWallpaperChangeCount(1); |
408 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 410 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
409 } | 411 } |
410 | 412 |
411 } // namespace chromeos | 413 } // namespace chromeos |
OLD | NEW |