// Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_USER_MANAGER_SCOPED_USER_MANAGER_H_ #define COMPONENTS_USER_MANAGER_SCOPED_USER_MANAGER_H_ #include <memory> #include <utility> #include "base/memory/raw_ptr.h" #include "components/user_manager/user_manager_export.h" namespace user_manager { class UserManager; namespace internal { // Implementation details of ScopedUserManager. class USER_MANAGER_EXPORT ScopedUserManagerImpl { … }; } // namespace internal // Helper class for unit tests. Initializes the UserManager singleton to the // given UserManager and tears it down again on destruction. If the singleton // had already been initialized, its previous value is restored after tearing // down. // // Example use case. // class FooTest : public testing::Test { // public: // void SetUp() override { // fake_user_manager_.Reset(std::make_unique<FakeUserManager>()); // fake_user_manager_->AddUser(...); // ... // } // private: // TypedScopedUserManager<FakeUserManager> fake_user_manager_; // }; // template <typename T> class USER_MANAGER_EXPORT TypedScopedUserManager { … }; ScopedUserManager; } // namespace user_manager #endif // COMPONENTS_USER_MANAGER_SCOPED_USER_MANAGER_H_