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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_shared_settings_update_unittest.cc

Issue 335833003: Rename "managed (mode|user)" to "supervised user" (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments (+ a few other cleanups) Created 6 years, 6 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" 7 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service .h"
8 #include "chrome/browser/managed_mode/managed_user_shared_settings_update.h" 8 #include "chrome/browser/supervised_user/supervised_user_shared_settings_update. h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "sync/api/sync_change.h" 10 #include "sync/api/sync_change.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 class ManagedUserSharedSettingsUpdateTest : public testing::Test { 13 class SupervisedUserSharedSettingsUpdateTest : public testing::Test {
14 public: 14 public:
15 ManagedUserSharedSettingsUpdateTest() : service_(profile_.GetPrefs()) {} 15 SupervisedUserSharedSettingsUpdateTest() : service_(profile_.GetPrefs()) {}
16 virtual ~ManagedUserSharedSettingsUpdateTest() {} 16 virtual ~SupervisedUserSharedSettingsUpdateTest() {}
17 17
18 void OnSettingUpdated(bool success) { 18 void OnSettingUpdated(bool success) {
19 result_.reset(new bool(success)); 19 result_.reset(new bool(success));
20 } 20 }
21 21
22 protected: 22 protected:
23 TestingProfile profile_; 23 TestingProfile profile_;
24 ManagedUserSharedSettingsService service_; 24 SupervisedUserSharedSettingsService service_;
25 scoped_ptr<bool> result_; 25 scoped_ptr<bool> result_;
26 }; 26 };
27 27
28 TEST_F(ManagedUserSharedSettingsUpdateTest, Success) { 28 TEST_F(SupervisedUserSharedSettingsUpdateTest, Success) {
29 ManagedUserSharedSettingsUpdate update( 29 SupervisedUserSharedSettingsUpdate update(
30 &service_, 30 &service_,
31 "abcdef", 31 "abcdef",
32 "name", 32 "name",
33 scoped_ptr<base::Value>(new base::StringValue("Hans Moleman")), 33 scoped_ptr<base::Value>(new base::StringValue("Hans Moleman")),
34 base::Bind(&ManagedUserSharedSettingsUpdateTest::OnSettingUpdated, 34 base::Bind(&SupervisedUserSharedSettingsUpdateTest::OnSettingUpdated,
35 base::Unretained(this))); 35 base::Unretained(this)));
36 syncer::SyncChangeList changes; 36 syncer::SyncChangeList changes;
37 changes.push_back(syncer::SyncChange( 37 changes.push_back(syncer::SyncChange(
38 FROM_HERE, 38 FROM_HERE,
39 syncer::SyncChange::ACTION_UPDATE, 39 syncer::SyncChange::ACTION_UPDATE,
40 ManagedUserSharedSettingsService::CreateSyncDataForSetting( 40 SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
41 "abcdef", "name", base::StringValue("Hans Moleman"), true))); 41 "abcdef", "name", base::StringValue("Hans Moleman"), true)));
42 syncer::SyncError error = service_.ProcessSyncChanges(FROM_HERE, changes); 42 syncer::SyncError error = service_.ProcessSyncChanges(FROM_HERE, changes);
43 EXPECT_FALSE(error.IsSet()) << error.ToString(); 43 EXPECT_FALSE(error.IsSet()) << error.ToString();
44 ASSERT_TRUE(result_); 44 ASSERT_TRUE(result_);
45 EXPECT_TRUE(*result_); 45 EXPECT_TRUE(*result_);
46 } 46 }
47 47
48 TEST_F(ManagedUserSharedSettingsUpdateTest, Failure) { 48 TEST_F(SupervisedUserSharedSettingsUpdateTest, Failure) {
49 ManagedUserSharedSettingsUpdate update( 49 SupervisedUserSharedSettingsUpdate update(
50 &service_, 50 &service_,
51 "abcdef", 51 "abcdef",
52 "name", 52 "name",
53 scoped_ptr<base::Value>(new base::StringValue("Hans Moleman")), 53 scoped_ptr<base::Value>(new base::StringValue("Hans Moleman")),
54 base::Bind(&ManagedUserSharedSettingsUpdateTest::OnSettingUpdated, 54 base::Bind(&SupervisedUserSharedSettingsUpdateTest::OnSettingUpdated,
55 base::Unretained(this))); 55 base::Unretained(this)));
56 56
57 // Syncing down a different change will cause the update to fail. 57 // Syncing down a different change will cause the update to fail.
58 syncer::SyncChangeList changes; 58 syncer::SyncChangeList changes;
59 changes.push_back(syncer::SyncChange( 59 changes.push_back(syncer::SyncChange(
60 FROM_HERE, 60 FROM_HERE,
61 syncer::SyncChange::ACTION_UPDATE, 61 syncer::SyncChange::ACTION_UPDATE,
62 ManagedUserSharedSettingsService::CreateSyncDataForSetting( 62 SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
63 "abcdef", 63 "abcdef",
64 "name", 64 "name",
65 base::StringValue("Barney Gumble"), 65 base::StringValue("Barney Gumble"),
66 true))); 66 true)));
67 syncer::SyncError error = service_.ProcessSyncChanges(FROM_HERE, changes); 67 syncer::SyncError error = service_.ProcessSyncChanges(FROM_HERE, changes);
68 EXPECT_FALSE(error.IsSet()) << error.ToString(); 68 EXPECT_FALSE(error.IsSet()) << error.ToString();
69 ASSERT_TRUE(result_); 69 ASSERT_TRUE(result_);
70 EXPECT_FALSE(*result_); 70 EXPECT_FALSE(*result_);
71 } 71 }
72 72
73 TEST_F(ManagedUserSharedSettingsUpdateTest, Cancel) { 73 TEST_F(SupervisedUserSharedSettingsUpdateTest, Cancel) {
74 { 74 {
75 ManagedUserSharedSettingsUpdate update( 75 SupervisedUserSharedSettingsUpdate update(
76 &service_, 76 &service_,
77 "abcdef", 77 "abcdef",
78 "name", 78 "name",
79 scoped_ptr<base::Value>(new base::StringValue("Hans Moleman")), 79 scoped_ptr<base::Value>(new base::StringValue("Hans Moleman")),
80 base::Bind(&ManagedUserSharedSettingsUpdateTest::OnSettingUpdated, 80 base::Bind(&SupervisedUserSharedSettingsUpdateTest::OnSettingUpdated,
81 base::Unretained(this))); 81 base::Unretained(this)));
82 ASSERT_FALSE(result_); 82 ASSERT_FALSE(result_);
83 } 83 }
84 ASSERT_FALSE(result_); 84 ASSERT_FALSE(result_);
85 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698