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

Side by Side Diff: chrome/test/base/testing_profile_manager.h

Issue 16658015: Add device policies to control accessibility settings on the login screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed leaky tests. Created 7 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
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/test/base/testing_profile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_TEST_BASE_TESTING_PROFILE_MANAGER_H_ 5 #ifndef CHROME_TEST_BASE_TESTING_PROFILE_MANAGER_H_
6 #define CHROME_TEST_BASE_TESTING_PROFILE_MANAGER_H_ 6 #define CHROME_TEST_BASE_TESTING_PROFILE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
14 #include "chrome/test/base/scoped_testing_local_state.h" 15 #include "chrome/test/base/scoped_testing_local_state.h"
15 16
17 class PrefServiceSyncable;
16 class ProfileInfoCache; 18 class ProfileInfoCache;
17 class ProfileManager; 19 class ProfileManager;
18 class TestingBrowserProcess; 20 class TestingBrowserProcess;
19 class TestingProfile; 21 class TestingProfile;
20 22
21 // The TestingProfileManager is a TestingProfile factory for a multi-profile 23 // The TestingProfileManager is a TestingProfile factory for a multi-profile
22 // environment. It will bring up a full ProfileManager and attach it to the 24 // environment. It will bring up a full ProfileManager and attach it to the
23 // TestingBrowserProcess set up in your test. 25 // TestingBrowserProcess set up in your test.
24 // 26 //
25 // When a Profile is needed for testing, create it through the factory method 27 // When a Profile is needed for testing, create it through the factory method
26 // below instead of creating it via |new TestingProfile|. It is not possible 28 // below instead of creating it via |new TestingProfile|. It is not possible
27 // to register profiles created in that fashion with the ProfileManager. 29 // to register profiles created in that fashion with the ProfileManager.
28 class TestingProfileManager { 30 class TestingProfileManager {
29 public: 31 public:
30 explicit TestingProfileManager(TestingBrowserProcess* browser_process); 32 explicit TestingProfileManager(TestingBrowserProcess* browser_process);
31 ~TestingProfileManager(); 33 ~TestingProfileManager();
32 34
33 // This needs to be called in testing::Test::SetUp() to put the object in a 35 // This needs to be called in testing::Test::SetUp() to put the object in a
34 // valid state. Some work cannot be done in a constructor because it may 36 // valid state. Some work cannot be done in a constructor because it may
35 // call gtest asserts to verify setup. The result of this call can be used 37 // call gtest asserts to verify setup. The result of this call can be used
36 // to ASSERT before doing more SetUp work in the test. 38 // to ASSERT before doing more SetUp work in the test.
37 bool SetUp() WARN_UNUSED_RESULT; 39 bool SetUp() WARN_UNUSED_RESULT;
38 40
39 // Creates a new TestingProfile whose data lives in a directory related to 41 // Creates a new TestingProfile whose data lives in a directory related to
40 // profile_name, which is a non-user-visible key for the test environment. 42 // profile_name, which is a non-user-visible key for the test environment.
43 // |prefs| is the PrefService used by the profile. If it is NULL, the profile
44 // creates a PrefService on demand.
41 // |user_name| and |avatar_id| are passed along to the ProfileInfoCache and 45 // |user_name| and |avatar_id| are passed along to the ProfileInfoCache and
42 // provide the user-visible profile metadata. This will register the 46 // provide the user-visible profile metadata. This will register the
43 // TestingProfile with the profile subsystem as well. The subsystem owns the 47 // TestingProfile with the profile subsystem as well. The subsystem owns the
44 // Profile and returns a weak pointer. 48 // Profile and returns a weak pointer.
45 TestingProfile* CreateTestingProfile(const std::string& profile_name, 49 TestingProfile* CreateTestingProfile(const std::string& profile_name,
50 scoped_ptr<PrefServiceSyncable> prefs,
46 const string16& user_name, 51 const string16& user_name,
47 int avatar_id); 52 int avatar_id);
48 53
49 // Small helper for creating testing profiles. Just forwards to above. 54 // Small helper for creating testing profiles. Just forwards to above.
50 TestingProfile* CreateTestingProfile(const std::string& name); 55 TestingProfile* CreateTestingProfile(const std::string& name);
51 56
52 // Deletes a TestingProfile from the profile subsystem. 57 // Deletes a TestingProfile from the profile subsystem.
53 void DeleteTestingProfile(const std::string& profile_name); 58 void DeleteTestingProfile(const std::string& profile_name);
54 59
55 // Deletes the cache instance. This is useful for testing that the cache is 60 // Deletes the cache instance. This is useful for testing that the cache is
(...skipping 30 matching lines...) Expand all
86 // Weak reference to the profile manager. 91 // Weak reference to the profile manager.
87 ProfileManager* profile_manager_; 92 ProfileManager* profile_manager_;
88 93
89 // Map of profile_name to TestingProfile* from CreateTestingProfile(). 94 // Map of profile_name to TestingProfile* from CreateTestingProfile().
90 TestingProfilesMap testing_profiles_; 95 TestingProfilesMap testing_profiles_;
91 96
92 DISALLOW_COPY_AND_ASSIGN(TestingProfileManager); 97 DISALLOW_COPY_AND_ASSIGN(TestingProfileManager);
93 }; 98 };
94 99
95 #endif // CHROME_TEST_BASE_TESTING_PROFILE_MANAGER_H_ 100 #endif // CHROME_TEST_BASE_TESTING_PROFILE_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/test/base/testing_profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698