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 TESTS_NACL_IO_TEST_PEPPER_INTERFACE_MOCK_H_ 6 #define TESTS_NACL_IO_TEST_PEPPER_INTERFACE_MOCK_H_ 7 8 #include "gmock/gmock.h" 9 #include "nacl_io/pepper_interface.h" 10 11 // Mock interface class definitions. 12 #include "nacl_io/pepper/undef_macros.h" 13 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ 14 class BaseClass##Mock : public nacl_io::BaseClass { \ 15 public: \ 16 BaseClass##Mock(); \ 17 virtual ~BaseClass##Mock(); 18 #define END_INTERFACE(BaseClass, PPInterface) \ 19 }; 20 #define METHOD0(Class, ReturnType, MethodName) \ 21 MOCK_METHOD0(MethodName, ReturnType()); 22 #define METHOD1(Class, ReturnType, MethodName, Type0) \ 23 MOCK_METHOD1(MethodName, ReturnType(Type0)); 24 #define METHOD2(Class, ReturnType, MethodName, Type0, Type1) \ 25 MOCK_METHOD2(MethodName, ReturnType(Type0, Type1)); 26 #define METHOD3(Class, ReturnType, MethodName, Type0, Type1, Type2) \ 27 MOCK_METHOD3(MethodName, ReturnType(Type0, Type1, Type2)); 28 #define METHOD4(Class, ReturnType, MethodName, Type0, Type1, Type2, Type3) \ 29 MOCK_METHOD4(MethodName, ReturnType(Type0, Type1, Type2, Type3)); 30 #define METHOD5(Class, ReturnType, MethodName, Type0, Type1, Type2, Type3, \ 31 Type4) \ 32 MOCK_METHOD5(MethodName, ReturnType(Type0, Type1, Type2, Type3, Type4)); 33 #include "nacl_io/pepper/all_interfaces.h" 34 35 36 class PepperInterfaceMock : public nacl_io::PepperInterface { 37 public: 38 explicit PepperInterfaceMock(PP_Instance instance); 39 ~PepperInterfaceMock(); 40 41 virtual PP_Instance GetInstance(); 42 43 // Interface getters. 44 #include "nacl_io/pepper/undef_macros.h" 45 #include "nacl_io/pepper/define_empty_macros.h" 46 #undef BEGIN_INTERFACE 47 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ 48 virtual BaseClass##Mock* Get##BaseClass(); 49 #include "nacl_io/pepper/all_interfaces.h" 50 51 private: 52 PP_Instance instance_; 53 54 // Interface pointers. 55 #include "nacl_io/pepper/undef_macros.h" 56 #include "nacl_io/pepper/define_empty_macros.h" 57 #undef BEGIN_INTERFACE 58 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ 59 BaseClass##Mock* BaseClass##interface_; 60 #include "nacl_io/pepper/all_interfaces.h" 61 }; 62 63 64 #endif // TESTS_NACL_IO_TEST_PEPPER_INTERFACE_MOCK_H_ 65