Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: chrome/browser/managed_mode/supervised_user_pref_mapping_service_unittest.cc

Issue 147083016: Add avatar syncing for supervised users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/managed_mode/managed_user_constants.h"
9 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
10 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto ry.h"
11 #include "chrome/browser/managed_mode/supervised_user_pref_mapping_service.h"
12 #include "chrome/browser/managed_mode/supervised_user_pref_mapping_service_facto ry.h"
13 #include "chrome/common/pref_names.h"
14 #include "chrome/test/base/testing_profile.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 const char kFakeManagedUserId[] = "fakeID";
18
19 class SupervisedUserPrefMappingServiceTest : public ::testing::Test {
20 protected:
21 SupervisedUserPrefMappingServiceTest() {
22 profile_.GetPrefs()->SetString(prefs::kManagedUserId, kFakeManagedUserId);
23 shared_settings_service_ =
24 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
25 &profile_);
26 mapping_service_ =
27 SupervisedUserPrefMappingServiceFactory::GetForBrowserContext(
28 &profile_);
29 }
30 virtual ~SupervisedUserPrefMappingServiceTest() {}
31
32 // testing::Test overrides:
33 virtual void SetUp() OVERRIDE {
34 mapping_service_->Init();
35 }
36
37 virtual void TearDown() OVERRIDE {
38 mapping_service_->Shutdown();
39 shared_settings_service_->Shutdown();
40 }
41
42 TestingProfile profile_;
43 ManagedUserSharedSettingsService* shared_settings_service_;
44 SupervisedUserPrefMappingService* mapping_service_;
45 };
46
47 TEST_F(SupervisedUserPrefMappingServiceTest, CheckPrefUpdate) {
48 EXPECT_TRUE(shared_settings_service_->GetValue(
49 kFakeManagedUserId, managed_users::kChromeAvatarIndex) ==
50 NULL);
51 profile_.GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, 4);
52 const base::Value* value = shared_settings_service_->GetValue(
53 kFakeManagedUserId, managed_users::kChromeAvatarIndex);
54 int avatar_index;
55 value->GetAsInteger(&avatar_index);
56 EXPECT_EQ(avatar_index, 4);
57 }
58
59 TEST_F(SupervisedUserPrefMappingServiceTest, CheckSharedSettingUpdate) {
60 EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), -1);
61 shared_settings_service_->SetValue(kFakeManagedUserId,
62 managed_users::kChromeAvatarIndex,
63 base::FundamentalValue(1));
64 mapping_service_->OnSharedSettingChanged(kFakeManagedUserId,
65 managed_users::kChromeAvatarIndex);
66 EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), 1);
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698