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 #ifndef CHROME_TEST_BASE_TESTING_PROFILE_MANAGER_H_ | |
6 #define CHROME_TEST_BASE_TESTING_PROFILE_MANAGER_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "chrome/browser/profiles/fake_profile_info_interface.h" | |
12 #include "chrome/browser/profiles/profile_manager.h" | |
13 | |
14 class ProfileInfoCache; | |
15 class TestingProfile; | |
16 | |
17 // The TestingProfileManager is used whenever a ProfileManager is needed in a | |
18 // test environment. It overrides only GetProfileInfo() and friends, but at | |
19 // some point in the future it may make use of the TestingProfiles it holds. | |
20 class TestingProfileManager : public ProfileManager { | |
21 public: | |
22 typedef std::map<TestingProfile*, AvatarMenuModel::Item*> TestingProfiles; | |
23 | |
24 TestingProfileManager(); | |
25 virtual ~TestingProfileManager(); | |
26 | |
27 // Creates an AvatarMenuModel::Item for use in AddTestingProfile(). Caller | |
28 // owns the result. | |
29 static AvatarMenuModel::Item* CreateFakeInfo( | |
30 std::string name) WARN_UNUSED_RESULT; | |
31 | |
32 // Adds a TestingProfile with an AvatarMenuModel::Item. The |info| is used by | |
33 // the FakeProfileInfo, while the TestingProfile is merely a way to key this | |
34 // information in your test. The |profile| is unused otherwise. | |
35 void AddTestingProfile(TestingProfile* profile, AvatarMenuModel::Item* info); | |
36 | |
37 // Removes a profile and the corresponding AvatarMenuModel::Item from the | |
38 // |fake_profile_info_|. | |
39 void RemoveTestingProfile(TestingProfile* profile); | |
40 | |
41 const TestingProfiles& testing_profiles() { | |
42 return testing_profiles_; | |
43 } | |
44 | |
45 FakeProfileInfo& fake_profile_info() { | |
46 return fake_profile_info_; | |
47 } | |
48 | |
49 // ProfileManager: | |
50 virtual ProfileInfoInterface& GetProfileInfo(); | |
51 virtual ProfileInfoCache& GetMutableProfileInfo(); | |
52 | |
53 private: | |
54 TestingProfiles testing_profiles_; | |
55 | |
56 FakeProfileInfo fake_profile_info_; | |
57 }; | |
58 | |
59 #endif // CHROME_TEST_BASE_TESTING_PROFILE_MANAGER_H_ | |
OLD | NEW |