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

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: Add unit tests. 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 namespace {
18
19 const std::string kFakeManagedUserId = "fakeID";
Bernhard Bauer 2014/02/07 09:54:24 const char[], otherwise you'll get a static initia
Adrian Kuegel 2014/02/07 10:24:47 Done.
20
21 }
22
23 class SupervisedUserPrefMappingServiceTest : public ::testing::Test {
24 protected:
25 SupervisedUserPrefMappingServiceTest() {
26 profile_.GetPrefs()->SetString(prefs::kManagedUserId, kFakeManagedUserId);
27 shared_settings_service_ =
28 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
29 &profile_);
30 mapping_service_ =
31 SupervisedUserPrefMappingServiceFactory::GetForBrowserContext(
32 &profile_);
33 }
34 virtual ~SupervisedUserPrefMappingServiceTest() {}
35
36 // testing::Test overrides:
37 virtual void SetUp() OVERRIDE {
38 mapping_service_->Init();
39 }
40
41 virtual void TearDown() OVERRIDE {
42 mapping_service_->Shutdown();
43 shared_settings_service_->Shutdown();
44 }
45
46 TestingProfile profile_;
47 ManagedUserSharedSettingsService* shared_settings_service_;
48 SupervisedUserPrefMappingService* mapping_service_;
49 };
50
51 TEST_F(SupervisedUserPrefMappingServiceTest, CheckPrefUpdate) {
52 EXPECT_TRUE(shared_settings_service_->GetValue(
53 kFakeManagedUserId, managed_users::kChromeAvatarIndex) ==
54 NULL);
55 profile_.GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, 4);
56 const base::Value* value = shared_settings_service_->GetValue(
57 kFakeManagedUserId, managed_users::kChromeAvatarIndex);
58 int avatar_index;
59 value->GetAsInteger(&avatar_index);
60 EXPECT_EQ(avatar_index, 4);
61 }
62
63 TEST_F(SupervisedUserPrefMappingServiceTest, CheckSharedSettingUpdate) {
64 EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), -1);
65 shared_settings_service_->SetValue(kFakeManagedUserId,
66 managed_users::kChromeAvatarIndex,
67 base::FundamentalValue(1));
68 mapping_service_->OnSharedSettingChanged(kFakeManagedUserId,
69 managed_users::kChromeAvatarIndex);
70 EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), 1);
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698