• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "chromeos/attestation/mock_attestation_flow.h"
6 
7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 
10 using testing::_;
11 using testing::Invoke;
12 
13 namespace chromeos {
14 namespace attestation {
15 
FakeServerProxy()16 FakeServerProxy::FakeServerProxy() : result_(true) {}
17 
~FakeServerProxy()18 FakeServerProxy::~FakeServerProxy() {}
19 
SendEnrollRequest(const std::string & request,const DataCallback & callback)20 void FakeServerProxy::SendEnrollRequest(const std::string& request,
21                                         const DataCallback& callback) {
22   callback.Run(result_, request + "_response");
23 }
24 
SendCertificateRequest(const std::string & request,const DataCallback & callback)25 void FakeServerProxy::SendCertificateRequest(const std::string& request,
26                                              const DataCallback& callback) {
27   callback.Run(result_, request + "_response");
28 }
29 
MockServerProxy()30 MockServerProxy::MockServerProxy() {}
31 
~MockServerProxy()32 MockServerProxy::~MockServerProxy() {}
33 
DeferToFake(bool success)34 void MockServerProxy::DeferToFake(bool success) {
35   fake_.set_result(success);
36   ON_CALL(*this, SendEnrollRequest(_, _))
37       .WillByDefault(Invoke(&fake_, &FakeServerProxy::SendEnrollRequest));
38   ON_CALL(*this, SendCertificateRequest(_, _))
39       .WillByDefault(Invoke(&fake_, &FakeServerProxy::SendCertificateRequest));
40 }
41 
MockObserver()42 MockObserver::MockObserver() {}
43 
~MockObserver()44 MockObserver::~MockObserver() {}
45 
MockAttestationFlow()46 MockAttestationFlow::MockAttestationFlow()
47     : AttestationFlow(NULL, NULL, scoped_ptr<ServerProxy>()) {}
48 
~MockAttestationFlow()49 MockAttestationFlow::~MockAttestationFlow() {}
50 
51 }  // namespace attestation
52 }  // namespace chromeos
53