| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
| 13 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" | 13 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" |
| 14 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h" | 14 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #include "sync/api/attachments/attachment_id.h" | 17 #include "sync/api/attachments/attachment_id.h" |
| 18 #include "sync/api/attachments/attachment_service_proxy_for_test.h" | 18 #include "sync/api/attachments/attachment_service_proxy_for_test.h" |
| 19 #include "sync/api/sync_change.h" | 19 #include "sync/api/sync_change.h" |
| 20 #include "sync/api/sync_error_factory_mock.h" | 20 #include "sync/api/sync_error_factory_mock.h" |
| 21 #include "sync/protocol/sync.pb.h" | 21 #include "sync/protocol/sync.pb.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 23 |
| 24 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 25 #include "chrome/browser/chromeos/login/users/avatar/default_user_images.h" | 25 #include "components/user_manager/user_image/default_user_images.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 using sync_pb::ManagedUserSpecifics; | 28 using sync_pb::ManagedUserSpecifics; |
| 29 using syncer::SUPERVISED_USERS; | 29 using syncer::SUPERVISED_USERS; |
| 30 using syncer::SyncChange; | 30 using syncer::SyncChange; |
| 31 using syncer::SyncChangeList; | 31 using syncer::SyncChangeList; |
| 32 using syncer::SyncChangeProcessor; | 32 using syncer::SyncChangeProcessor; |
| 33 using syncer::SyncData; | 33 using syncer::SyncData; |
| 34 using syncer::SyncDataList; | 34 using syncer::SyncDataList; |
| 35 using syncer::SyncError; | 35 using syncer::SyncError; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 288 } |
| 289 | 289 |
| 290 TEST_F(SupervisedUserSyncServiceTest, GetAvatarIndex) { | 290 TEST_F(SupervisedUserSyncServiceTest, GetAvatarIndex) { |
| 291 int avatar = 100; | 291 int avatar = 100; |
| 292 EXPECT_TRUE(SupervisedUserSyncService::GetAvatarIndex(std::string(), | 292 EXPECT_TRUE(SupervisedUserSyncService::GetAvatarIndex(std::string(), |
| 293 &avatar)); | 293 &avatar)); |
| 294 EXPECT_EQ(SupervisedUserSyncService::kNoAvatar, avatar); | 294 EXPECT_EQ(SupervisedUserSyncService::kNoAvatar, avatar); |
| 295 | 295 |
| 296 int avatar_index = 4; | 296 int avatar_index = 4; |
| 297 #if defined(OS_CHROMEOS) | 297 #if defined(OS_CHROMEOS) |
| 298 avatar_index += chromeos::kFirstDefaultImageIndex; | 298 avatar_index += user_manager::kFirstDefaultImageIndex; |
| 299 #endif | 299 #endif |
| 300 std::string avatar_str = | 300 std::string avatar_str = |
| 301 SupervisedUserSyncService::BuildAvatarString(avatar_index); | 301 SupervisedUserSyncService::BuildAvatarString(avatar_index); |
| 302 #if defined(OS_CHROMEOS) | 302 #if defined(OS_CHROMEOS) |
| 303 EXPECT_EQ(base::StringPrintf("chromeos-avatar-index:%d", avatar_index), | 303 EXPECT_EQ(base::StringPrintf("chromeos-avatar-index:%d", avatar_index), |
| 304 avatar_str); | 304 avatar_str); |
| 305 #else | 305 #else |
| 306 EXPECT_EQ(base::StringPrintf("chrome-avatar-index:%d", avatar_index), | 306 EXPECT_EQ(base::StringPrintf("chrome-avatar-index:%d", avatar_index), |
| 307 avatar_str); | 307 avatar_str); |
| 308 #endif | 308 #endif |
| 309 EXPECT_TRUE(SupervisedUserSyncService::GetAvatarIndex(avatar_str, &avatar)); | 309 EXPECT_TRUE(SupervisedUserSyncService::GetAvatarIndex(avatar_str, &avatar)); |
| 310 EXPECT_EQ(avatar_index, avatar); | 310 EXPECT_EQ(avatar_index, avatar); |
| 311 | 311 |
| 312 avatar_index = 0; | 312 avatar_index = 0; |
| 313 #if defined(OS_CHROMEOS) | 313 #if defined(OS_CHROMEOS) |
| 314 avatar_index += chromeos::kFirstDefaultImageIndex; | 314 avatar_index += user_manager::kFirstDefaultImageIndex; |
| 315 #endif | 315 #endif |
| 316 avatar_str = SupervisedUserSyncService::BuildAvatarString(avatar_index); | 316 avatar_str = SupervisedUserSyncService::BuildAvatarString(avatar_index); |
| 317 #if defined(OS_CHROMEOS) | 317 #if defined(OS_CHROMEOS) |
| 318 EXPECT_EQ(base::StringPrintf("chromeos-avatar-index:%d", avatar_index), | 318 EXPECT_EQ(base::StringPrintf("chromeos-avatar-index:%d", avatar_index), |
| 319 avatar_str); | 319 avatar_str); |
| 320 #else | 320 #else |
| 321 EXPECT_EQ(base::StringPrintf("chrome-avatar-index:%d", avatar_index), | 321 EXPECT_EQ(base::StringPrintf("chrome-avatar-index:%d", avatar_index), |
| 322 avatar_str); | 322 avatar_str); |
| 323 #endif | 323 #endif |
| 324 EXPECT_TRUE(SupervisedUserSyncService::GetAvatarIndex(avatar_str, &avatar)); | 324 EXPECT_TRUE(SupervisedUserSyncService::GetAvatarIndex(avatar_str, &avatar)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex( | 362 EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex( |
| 363 "chrome-avatar-index:x", | 363 "chrome-avatar-index:x", |
| 364 &avatar)); | 364 &avatar)); |
| 365 | 365 |
| 366 EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex( | 366 EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex( |
| 367 "chromeos-avatar-index:5", | 367 "chromeos-avatar-index:5", |
| 368 &avatar)); | 368 &avatar)); |
| 369 #endif | 369 #endif |
| 370 } | 370 } |
| OLD | NEW |