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

Side by Side Diff: chrome/browser/chromeos/login/mock_user_manager.h

Issue 9826010: Made a ScopedMockUserManagerEnabler to simplify UserManager mocking life-cycle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
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_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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698