Home | History | Annotate | Download | only in attestation
      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::DefaultValue;
     12 using testing::Invoke;
     13 
     14 namespace chromeos {
     15 namespace attestation {
     16 
     17 FakeServerProxy::FakeServerProxy() : result_(true) {}
     18 
     19 FakeServerProxy::~FakeServerProxy() {}
     20 
     21 void FakeServerProxy::SendEnrollRequest(const std::string& request,
     22                                         const DataCallback& callback) {
     23   callback.Run(result_, request + "_response");
     24 }
     25 
     26 void FakeServerProxy::SendCertificateRequest(const std::string& request,
     27                                              const DataCallback& callback) {
     28   callback.Run(result_, request + "_response");
     29 }
     30 
     31 MockServerProxy::MockServerProxy() {
     32   DefaultValue<PrivacyCAType>::Set(DEFAULT_PCA);
     33 }
     34 
     35 MockServerProxy::~MockServerProxy() {}
     36 
     37 void MockServerProxy::DeferToFake(bool success) {
     38   fake_.set_result(success);
     39   ON_CALL(*this, SendEnrollRequest(_, _))
     40       .WillByDefault(Invoke(&fake_, &FakeServerProxy::SendEnrollRequest));
     41   ON_CALL(*this, SendCertificateRequest(_, _))
     42       .WillByDefault(Invoke(&fake_, &FakeServerProxy::SendCertificateRequest));
     43 }
     44 
     45 MockObserver::MockObserver() {}
     46 
     47 MockObserver::~MockObserver() {}
     48 
     49 MockAttestationFlow::MockAttestationFlow()
     50     : AttestationFlow(NULL, NULL, scoped_ptr<ServerProxy>()) {}
     51 
     52 MockAttestationFlow::~MockAttestationFlow() {}
     53 
     54 }  // namespace attestation
     55 }  // namespace chromeos
     56