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

Side by Side Diff: chrome/browser/chromeos/login/users/mock_user_manager.cc

Issue 785893003: Adapt Chrome OS related part of ChildAccountService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ClearUserList method updated for mock. Created 6 years 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
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/users/mock_user_manager.h" 5 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
6 6
7 #include "base/stl_util.h"
7 #include "base/task_runner.h" 8 #include "base/task_runner.h"
8 #include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h" 9 #include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h"
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" 10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/test/base/testing_profile.h"
10 12
11 namespace { 13 namespace {
12 14
13 class FakeTaskRunner : public base::TaskRunner { 15 class FakeTaskRunner : public base::TaskRunner {
14 public: 16 public:
15 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, 17 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
16 const base::Closure& task, 18 const base::Closure& task,
17 base::TimeDelta delay) override { 19 base::TimeDelta delay) override {
18 task.Run(); 20 task.Run();
19 return true; 21 return true;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 UserFlow* MockUserManager::GetUserFlow(const std::string&) const { 100 UserFlow* MockUserManager::GetUserFlow(const std::string&) const {
99 return user_flow_.get(); 101 return user_flow_.get();
100 } 102 }
101 103
102 user_manager::User* MockUserManager::CreatePublicAccountUser( 104 user_manager::User* MockUserManager::CreatePublicAccountUser(
103 const std::string& email) { 105 const std::string& email) {
104 ClearUserList(); 106 ClearUserList();
105 user_manager::User* user = user_manager::User::CreatePublicAccountUser(email); 107 user_manager::User* user = user_manager::User::CreatePublicAccountUser(email);
106 user_list_.push_back(user); 108 user_list_.push_back(user);
107 ProfileHelper::Get()->SetProfileToUserMappingForTesting(user); 109 ProfileHelper::Get()->SetProfileToUserMappingForTesting(user);
110
111 TestingProfile* profile = new TestingProfile();
112 profile->set_profile_name(email);
Marc Treib 2014/12/08 16:59:34 You probably want to add |profile| to |profile_lis
merkulova 2014/12/10 11:55:44 Done.
113 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, profile);
114
108 return user_list_.back(); 115 return user_list_.back();
109 } 116 }
110 117
111 void MockUserManager::AddUser(const std::string& email) { 118 void MockUserManager::AddUser(const std::string& email) {
112 user_manager::User* user = user_manager::User::CreateRegularUser(email); 119 user_manager::User* user = user_manager::User::CreateRegularUser(email);
113 user_list_.push_back(user); 120 user_list_.push_back(user);
114 ProfileHelper::Get()->SetProfileToUserMappingForTesting(user); 121 ProfileHelper::Get()->SetProfileToUserMappingForTesting(user);
122
123 TestingProfile* profile = new TestingProfile();
124 profile->set_profile_name(email);
Marc Treib 2014/12/08 16:59:34 Here too.
merkulova 2014/12/10 11:55:44 Done.
125 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, profile);
115 } 126 }
116 127
117 void MockUserManager::ClearUserList() { 128 void MockUserManager::ClearUserList() {
118 // Can't use STLDeleteElements because of the protected destructor of User. 129 // Can't use STLDeleteElements because of the protected destructor of User.
119 user_manager::UserList::iterator user; 130 user_manager::UserList::iterator user;
120 for (user = user_list_.begin(); user != user_list_.end(); ++user) 131 for (user = user_list_.begin(); user != user_list_.end(); ++user)
121 delete *user; 132 delete *user;
122 user_list_.clear(); 133 user_list_.clear();
134
135 STLDeleteElements(&profile_list_);
123 } 136 }
124 137
125 } // namespace chromeos 138 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698