OLD | NEW |
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_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // You can't mock this function easily because nobody can create User objects | 61 // You can't mock this function easily because nobody can create User objects |
62 // but the UserManagerImpl and us. | 62 // but the UserManagerImpl and us. |
63 virtual User& GetLoggedInUser() OVERRIDE; | 63 virtual User& GetLoggedInUser() OVERRIDE; |
64 | 64 |
65 // Sets a new User instance. | 65 // Sets a new User instance. |
66 void SetLoggedInUser(const std::string& email, bool guest); | 66 void SetLoggedInUser(const std::string& email, bool guest); |
67 | 67 |
68 User* user_; | 68 User* user_; |
69 }; | 69 }; |
70 | 70 |
| 71 // Class that provides easy life-cycle management for mocking the UserManager |
| 72 // for tests. |
| 73 class ScopedMockUserManagerEnabler { |
| 74 public: |
| 75 ScopedMockUserManagerEnabler(); |
| 76 ~ScopedMockUserManagerEnabler(); |
| 77 |
| 78 MockUserManager* user_manager(); |
| 79 |
| 80 private: |
| 81 UserManager* old_user_manager_; |
| 82 scoped_ptr<MockUserManager> user_manager_; |
| 83 }; |
| 84 |
71 } // namespace chromeos | 85 } // namespace chromeos |
72 | 86 |
73 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_ | 87 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_USER_MANAGER_H_ |
OLD | NEW |