pepper_interface_mock.cc revision 3551c9c881056c480085172ff9840cab31610854
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 "pepper_interface_mock.h"
6
7PepperInterfaceMock::PepperInterfaceMock(PP_Instance instance)
8    : instance_(instance),
9
10    // Initialize interfaces.
11#include "nacl_io/pepper/undef_macros.h"
12#include "nacl_io/pepper/define_empty_macros.h"
13#undef BEGIN_INTERFACE
14#define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \
15    BaseClass##interface_(new BaseClass##Mock),
16#include "nacl_io/pepper/all_interfaces.h"
17
18    // Dummy value so we can ensure that no interface ends the initializer list.
19    dummy_(0) {
20}
21
22PepperInterfaceMock::~PepperInterfaceMock() {
23
24  // Delete interfaces.
25#include "nacl_io/pepper/undef_macros.h"
26#include "nacl_io/pepper/define_empty_macros.h"
27#undef BEGIN_INTERFACE
28#define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \
29    delete BaseClass##interface_;
30#include "nacl_io/pepper/all_interfaces.h"
31
32}
33
34PP_Instance PepperInterfaceMock::GetInstance() {
35  return instance_;
36}
37
38// Define Getter functions, constructors, destructors.
39#include "nacl_io/pepper/undef_macros.h"
40#include "nacl_io/pepper/define_empty_macros.h"
41#undef BEGIN_INTERFACE
42#define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \
43    BaseClass##Mock* PepperInterfaceMock::Get##BaseClass() { \
44      return BaseClass##interface_; \
45    } \
46    BaseClass##Mock::BaseClass##Mock() { \
47    } \
48    BaseClass##Mock::~BaseClass##Mock() { \
49    }
50#include "nacl_io/pepper/all_interfaces.h"
51
52