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

Side by Side Diff: chrome/browser/chromeos/login/managed/managed_user_test_base.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 "chrome/browser/chromeos/login/managed/managed_user_test_base.h" 5 #include "chrome/browser/chromeos/login/managed/managed_user_test_base.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/sequenced_worker_pool.h" 14 #include "base/threading/sequenced_worker_pool.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/chromeos/login/auth/key.h" 16 #include "chrome/browser/chromeos/login/auth/key.h"
17 #include "chrome/browser/chromeos/login/auth/user_context.h" 17 #include "chrome/browser/chromeos/login/auth/user_context.h"
18 #include "chrome/browser/chromeos/login/login_manager_test.h" 18 #include "chrome/browser/chromeos/login/login_manager_test.h"
19 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h " 19 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h "
20 #include "chrome/browser/chromeos/login/startup_utils.h" 20 #include "chrome/browser/chromeos/login/startup_utils.h"
21 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 21 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
22 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 22 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
23 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 23 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
24 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" 24 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
25 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" 25 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
26 #include "chrome/browser/managed_mode/managed_user_constants.h"
27 #include "chrome/browser/managed_mode/managed_user_registration_utility.h"
28 #include "chrome/browser/managed_mode/managed_user_registration_utility_stub.h"
29 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
30 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto ry.h"
31 #include "chrome/browser/managed_mode/managed_user_sync_service.h"
32 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
33 #include "chrome/browser/profiles/profile_impl.h" 26 #include "chrome/browser/profiles/profile_impl.h"
27 #include "chrome/browser/supervised_user/supervised_user_constants.h"
28 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
29 #include "chrome/browser/supervised_user/supervised_user_registration_utility_st ub.h"
30 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service .h"
31 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service _factory.h"
32 #include "chrome/browser/supervised_user/supervised_user_sync_service.h"
33 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
34 #include "chromeos/cryptohome/mock_async_method_caller.h" 34 #include "chromeos/cryptohome/mock_async_method_caller.h"
35 #include "chromeos/cryptohome/mock_homedir_methods.h" 35 #include "chromeos/cryptohome/mock_homedir_methods.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/test/browser_test_utils.h" 37 #include "content/public/test/browser_test_utils.h"
38 #include "content/public/test/test_utils.h" 38 #include "content/public/test/test_utils.h"
39 #include "sync/api/attachments/attachment_service_proxy_for_test.h" 39 #include "sync/api/attachments/attachment_service_proxy_for_test.h"
40 #include "sync/api/fake_sync_change_processor.h" 40 #include "sync/api/fake_sync_change_processor.h"
41 #include "sync/api/sync_change.h" 41 #include "sync/api/sync_change.h"
42 #include "sync/api/sync_error_factory_mock.h" 42 #include "sync/api/sync_error_factory_mock.h"
43 #include "sync/protocol/sync.pb.h" 43 #include "sync/protocol/sync.pb.h"
44 44
45 using testing::_; 45 using testing::_;
46 using base::StringPrintf; 46 using base::StringPrintf;
47 47
48 namespace chromeos { 48 namespace chromeos {
49 49
50 namespace { 50 namespace {
51 51
52 const char kCurrentPage[] = "$('managed-user-creation').currentPage_"; 52 const char kCurrentPage[] = "$('managed-user-creation').currentPage_";
53 } 53 }
54 54
55 ManagedUsersSyncTestAdapter::ManagedUsersSyncTestAdapter(Profile* profile) 55 ManagedUsersSyncTestAdapter::ManagedUsersSyncTestAdapter(Profile* profile)
56 : processor_(), next_sync_data_id_(0) { 56 : processor_(), next_sync_data_id_(0) {
57 service_ = ManagedUserSyncServiceFactory::GetForProfile(profile); 57 service_ = SupervisedUserSyncServiceFactory::GetForProfile(profile);
58 processor_ = new syncer::FakeSyncChangeProcessor(); 58 processor_ = new syncer::FakeSyncChangeProcessor();
59 service_->MergeDataAndStartSyncing( 59 service_->MergeDataAndStartSyncing(
60 syncer::SUPERVISED_USERS, 60 syncer::SUPERVISED_USERS,
61 syncer::SyncDataList(), 61 syncer::SyncDataList(),
62 scoped_ptr<syncer::SyncChangeProcessor>(processor_), 62 scoped_ptr<syncer::SyncChangeProcessor>(processor_),
63 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock)); 63 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock));
64 } 64 }
65 65
66 scoped_ptr< ::sync_pb::ManagedUserSpecifics> 66 scoped_ptr< ::sync_pb::ManagedUserSpecifics>
67 ManagedUsersSyncTestAdapter::GetFirstChange() { 67 ManagedUsersSyncTestAdapter::GetFirstChange() {
(...skipping 28 matching lines...) Expand all
96 syncer::SyncChangeList change_list; 96 syncer::SyncChangeList change_list;
97 change_list.push_back(change); 97 change_list.push_back(change);
98 98
99 service_->ProcessSyncChanges(FROM_HERE, change_list); 99 service_->ProcessSyncChanges(FROM_HERE, change_list);
100 } 100 }
101 101
102 ManagedUsersSharedSettingsSyncTestAdapter:: 102 ManagedUsersSharedSettingsSyncTestAdapter::
103 ManagedUsersSharedSettingsSyncTestAdapter(Profile* profile) 103 ManagedUsersSharedSettingsSyncTestAdapter(Profile* profile)
104 : processor_(), next_sync_data_id_(0) { 104 : processor_(), next_sync_data_id_(0) {
105 service_ = 105 service_ =
106 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile); 106 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
107 processor_ = new syncer::FakeSyncChangeProcessor(); 107 processor_ = new syncer::FakeSyncChangeProcessor();
108 service_->MergeDataAndStartSyncing( 108 service_->MergeDataAndStartSyncing(
109 syncer::SUPERVISED_USER_SHARED_SETTINGS, 109 syncer::SUPERVISED_USER_SHARED_SETTINGS,
110 syncer::SyncDataList(), 110 syncer::SyncDataList(),
111 scoped_ptr<syncer::SyncChangeProcessor>(processor_), 111 scoped_ptr<syncer::SyncChangeProcessor>(processor_),
112 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock)); 112 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock));
113 } 113 }
114 114
115 scoped_ptr< ::sync_pb::ManagedUserSharedSettingSpecifics> 115 scoped_ptr< ::sync_pb::ManagedUserSharedSettingSpecifics>
116 ManagedUsersSharedSettingsSyncTestAdapter::GetFirstChange() { 116 ManagedUsersSharedSettingsSyncTestAdapter::GetFirstChange() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 service_->ProcessSyncChanges(FROM_HERE, change_list); 148 service_->ProcessSyncChanges(FROM_HERE, change_list);
149 } 149 }
150 150
151 void ManagedUsersSharedSettingsSyncTestAdapter::AddChange( 151 void ManagedUsersSharedSettingsSyncTestAdapter::AddChange(
152 const std::string& mu_id, 152 const std::string& mu_id,
153 const std::string& key, 153 const std::string& key,
154 const base::Value& value, 154 const base::Value& value,
155 bool acknowledged, 155 bool acknowledged,
156 bool update) { 156 bool update) {
157 syncer::SyncData data = 157 syncer::SyncData data =
158 ManagedUserSharedSettingsService::CreateSyncDataForSetting( 158 SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
159 mu_id, key, value, acknowledged); 159 mu_id, key, value, acknowledged);
160 AddChange(data.GetSpecifics().managed_user_shared_setting(), update); 160 AddChange(data.GetSpecifics().managed_user_shared_setting(), update);
161 } 161 }
162 162
163 ManagedUserTestBase::ManagedUserTestBase() 163 ManagedUserTestBase::ManagedUserTestBase()
164 : LoginManagerTest(true), 164 : LoginManagerTest(true),
165 mock_async_method_caller_(NULL), 165 mock_async_method_caller_(NULL),
166 mock_homedir_methods_(NULL), 166 mock_homedir_methods_(NULL),
167 network_portal_detector_(NULL), 167 network_portal_detector_(NULL),
168 registration_utility_stub_(NULL) { 168 registration_utility_stub_(NULL) {
169 } 169 }
170 170
171 ManagedUserTestBase::~ManagedUserTestBase() { 171 ManagedUserTestBase::~ManagedUserTestBase() {
172 } 172 }
173 173
174 void ManagedUserTestBase::SetUpInProcessBrowserTestFixture() { 174 void ManagedUserTestBase::SetUpInProcessBrowserTestFixture() {
175 LoginManagerTest::SetUpInProcessBrowserTestFixture(); 175 LoginManagerTest::SetUpInProcessBrowserTestFixture();
176 mock_async_method_caller_ = new cryptohome::MockAsyncMethodCaller; 176 mock_async_method_caller_ = new cryptohome::MockAsyncMethodCaller;
177 mock_async_method_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); 177 mock_async_method_caller_->SetUp(true, cryptohome::MOUNT_ERROR_NONE);
178 cryptohome::AsyncMethodCaller::InitializeForTesting( 178 cryptohome::AsyncMethodCaller::InitializeForTesting(
179 mock_async_method_caller_); 179 mock_async_method_caller_);
180 180
181 mock_homedir_methods_ = new cryptohome::MockHomedirMethods; 181 mock_homedir_methods_ = new cryptohome::MockHomedirMethods;
182 mock_homedir_methods_->SetUp(true, cryptohome::MOUNT_ERROR_NONE); 182 mock_homedir_methods_->SetUp(true, cryptohome::MOUNT_ERROR_NONE);
183 cryptohome::HomedirMethods::InitializeForTesting(mock_homedir_methods_); 183 cryptohome::HomedirMethods::InitializeForTesting(mock_homedir_methods_);
184 184
185 registration_utility_stub_ = new ManagedUserRegistrationUtilityStub(); 185 registration_utility_stub_ = new SupervisedUserRegistrationUtilityStub();
186 scoped_utility_.reset(new ScopedTestingManagedUserRegistrationUtility( 186 scoped_utility_.reset(new ScopedTestingSupervisedUserRegistrationUtility(
187 registration_utility_stub_)); 187 registration_utility_stub_));
188 188
189 // Setup network portal detector to return online state for both 189 // Setup network portal detector to return online state for both
190 // ethernet and wifi networks. Ethernet is an active network by 190 // ethernet and wifi networks. Ethernet is an active network by
191 // default. 191 // default.
192 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); 192 network_portal_detector_ = new NetworkPortalDetectorTestImpl();
193 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); 193 NetworkPortalDetector::InitializeForTesting(network_portal_detector_);
194 NetworkPortalDetector::CaptivePortalState online_state; 194 NetworkPortalDetector::CaptivePortalState online_state;
195 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; 195 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE;
196 online_state.response_code = 204; 196 online_state.response_code = 204;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // Confirm deletion. 425 // Confirm deletion.
426 JSEval(StringPrintf( 426 JSEval(StringPrintf(
427 "$('pod-row').pods[%d].querySelector('.remove-warning-button').click()", 427 "$('pod-row').pods[%d].querySelector('.remove-warning-button').click()",
428 user_index)); 428 user_index));
429 429
430 // Make sure there is no supervised user in list. 430 // Make sure there is no supervised user in list.
431 ASSERT_EQ(original_user_count - 1, UserManager::Get()->GetUsers().size()); 431 ASSERT_EQ(original_user_count - 1, UserManager::Get()->GetUsers().size());
432 } 432 }
433 433
434 } // namespace chromeos 434 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698