OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 "chrome/test/base/testing_profile_manager.h" |
| 6 |
| 7 #include <algorithm> |
| 8 |
| 9 #include "base/utf_string_conversions.h" |
| 10 |
| 11 TestingProfileManager::TestingProfileManager() { |
| 12 } |
| 13 |
| 14 TestingProfileManager::~TestingProfileManager() { |
| 15 } |
| 16 |
| 17 // static |
| 18 AvatarMenuModel::Item* TestingProfileManager::CreateFakeInfo(std::string name) { |
| 19 AvatarMenuModel::Item* item = |
| 20 new AvatarMenuModel::Item(0, FakeProfileInfo::GetTestImage()); |
| 21 item->name = UTF8ToUTF16(name); |
| 22 return item; |
| 23 } |
| 24 |
| 25 void TestingProfileManager::AddTestingProfile(TestingProfile* profile, |
| 26 AvatarMenuModel::Item* info) { |
| 27 testing_profiles_.insert(std::make_pair(profile, info)); |
| 28 fake_profile_info_.mock_profiles()->push_back(info); |
| 29 } |
| 30 |
| 31 void TestingProfileManager::RemoveTestingProfile(TestingProfile* profile) { |
| 32 std::map<TestingProfile*, AvatarMenuModel::Item*>::iterator it( |
| 33 testing_profiles_.find(profile)); |
| 34 DCHECK(it != testing_profiles_.end()); |
| 35 |
| 36 AvatarMenuModel::Item* info = it->second; |
| 37 std::vector<AvatarMenuModel::Item*>* info_list = |
| 38 fake_profile_info_.mock_profiles(); |
| 39 std::vector<AvatarMenuModel::Item*>::iterator info_it( |
| 40 std::find(info_list->begin(), info_list->end(), info)); |
| 41 DCHECK(info_it != fake_profile_info_.mock_profiles()->end()); |
| 42 |
| 43 testing_profiles_.erase(it); |
| 44 fake_profile_info_.mock_profiles()->erase(info_it); |
| 45 } |
| 46 |
| 47 ProfileInfoInterface& TestingProfileManager::GetProfileInfo() { |
| 48 return fake_profile_info_; |
| 49 } |
| 50 |
| 51 ProfileInfoCache& TestingProfileManager::GetMutableProfileInfo() { |
| 52 NOTIMPLEMENTED(); |
| 53 return ProfileManager::GetMutableProfileInfo(); |
| 54 } |
OLD | NEW |