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 3 // found in the LICENSE file. 4 5 #ifndef CHROMEOS_ATTESTATION_MOCK_ATTESTATION_FLOW_H_ 6 #define CHROMEOS_ATTESTATION_MOCK_ATTESTATION_FLOW_H_ 7 8 #include "chromeos/attestation/attestation_flow.h" 9 10 #include "base/basictypes.h" 11 #include "base/callback.h" 12 #include "testing/gmock/include/gmock/gmock.h" 13 14 namespace chromeos { 15 namespace attestation { 16 17 // A fake server proxy which just appends "_response" to every request. 18 class FakeServerProxy : public ServerProxy { 19 public: 20 FakeServerProxy(); 21 virtual ~FakeServerProxy(); 22 23 void set_result(bool result) { 24 result_ = result; 25 } 26 27 virtual void SendEnrollRequest(const std::string& request, 28 const DataCallback& callback) OVERRIDE; 29 30 virtual void SendCertificateRequest(const std::string& request, 31 const DataCallback& callback) OVERRIDE; 32 33 private: 34 bool result_; 35 36 DISALLOW_COPY_AND_ASSIGN(FakeServerProxy); 37 }; 38 39 class MockServerProxy : public ServerProxy { 40 public: 41 MockServerProxy(); 42 virtual ~MockServerProxy(); 43 44 void DeferToFake(bool result); 45 MOCK_METHOD2(SendEnrollRequest, 46 void(const std::string&, const DataCallback&)); 47 MOCK_METHOD2(SendCertificateRequest, 48 void(const std::string&, const DataCallback&)); 49 50 private: 51 FakeServerProxy fake_; 52 }; 53 54 // This class can be used to mock AttestationFlow callbacks. 55 class MockObserver { 56 public: 57 MockObserver(); 58 virtual ~MockObserver(); 59 60 MOCK_METHOD2(MockCertificateCallback, void(bool, const std::string&)); 61 }; 62 63 class MockAttestationFlow : public AttestationFlow { 64 public: 65 MockAttestationFlow(); 66 virtual ~MockAttestationFlow(); 67 68 MOCK_METHOD5(GetCertificate, void(AttestationCertificateProfile, 69 const std::string&, 70 const std::string&, 71 bool, 72 const CertificateCallback&)); 73 }; 74 75 } // namespace attestation 76 } // namespace chromeos 77 78 #endif // CHROMEOS_ATTESTATION_MOCK_ATTESTATION_FLOW_H_ 79