blob: c04a646b4460ba1be544776e1508ec5ff8f72617 [file] [log] [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_ELEVATION_SERVICE_SCOPED_MOCK_CONTEXT_H_
#define CHROME_ELEVATION_SERVICE_SCOPED_MOCK_CONTEXT_H_
#include <unknwn.h>
#include <wrl/client.h>
namespace elevation_service {
// Installs an implementation of IServerSecurity that allows code under test to
// successfully call ::CoImpersonateClient().
class ScopedMockContext {
public:
ScopedMockContext();
ScopedMockContext(const ScopedMockContext&) = delete;
ScopedMockContext& operator=(const ScopedMockContext&) = delete;
~ScopedMockContext();
bool Succeeded() const { return mock_call_context_; }
private:
Microsoft::WRL::ComPtr<IUnknown> mock_call_context_;
IUnknown* original_call_context_ = nullptr;
};
} // namespace elevation_service
#endif // CHROME_ELEVATION_SERVICE_SCOPED_MOCK_CONTEXT_H_