Chromium Code Reviews| Index: chromeos/attestation/mock_attestation_flow.h |
| diff --git a/chromeos/attestation/mock_attestation_flow.h b/chromeos/attestation/mock_attestation_flow.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..94dee83335f30ee94a3920ece84005554ec1ea51 |
| --- /dev/null |
| +++ b/chromeos/attestation/mock_attestation_flow.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chromeos/attestation/attestation_flow.h" |
| + |
| +#include "testing/gmock/include/gmock/gmock.h" |
| + |
| +namespace chromeos { |
| +namespace attestation { |
| + |
| +// A fake server proxy which just appends "_response" to every request. |
| +class FakeServerProxy : public ServerProxy { |
| + public: |
| + FakeServerProxy() : result_(true) {} |
| + virtual ~FakeServerProxy() {} |
| + |
| + void set_result(bool result) { |
| + result_ = result; |
| + } |
| + void SendEnrollRequest(const std::string& request, |
| + const DataCallback& callback) { |
| + callback.Run(result_, request + "_response"); |
|
Mattias Nissler (ping if slow)
2013/01/18 13:38:46
#include "base/callback.h"
dkrahn
2013/01/22 22:50:11
Done.
|
| + } |
| + void SendCertificateRequest(const std::string& request, |
| + const DataCallback& callback) { |
| + callback.Run(result_, request + "_response"); |
| + } |
| + |
| + private: |
| + bool result_; |
|
Mattias Nissler (ping if slow)
2013/01/18 13:38:46
DISALLOW_COPY_AND_ASSIGN(FakeServerProxy) and #inc
dkrahn
2013/01/22 22:50:11
Done.
|
| +}; |
| + |
| +class MockServerProxy : public ServerProxy { |
| + public: |
| + MockServerProxy(); |
| + virtual ~MockServerProxy(); |
| + |
| + void DeferToFake(bool result); |
| + MOCK_METHOD2(SendEnrollRequest, |
| + void(const std::string&, const DataCallback&)); |
| + MOCK_METHOD2(SendCertificateRequest, |
| + void(const std::string&, const DataCallback&)); |
| + |
| + private: |
| + FakeServerProxy fake_; |
| +}; |
| + |
| +// This class can be used to mock AttestationFlow callbacks. |
| +class MockObserver { |
| + public: |
| + MockObserver(); |
| + virtual ~MockObserver(); |
| + |
| + MOCK_METHOD2(MockCertificateCallback, void(bool, const std::string&)); |
| +}; |
| + |
| +} // namespace attestation |
| +} // namespace chromeos |