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 LIBRARIES_NACL_IO_TEST_PEPPER_INTERFACE_MOCK_H_ 6 #define LIBRARIES_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 METHOD1(Class, ReturnType, MethodName, Type0) \ 21 MOCK_METHOD1(MethodName, ReturnType(Type0)); 22 #define METHOD2(Class, ReturnType, MethodName, Type0, Type1) \ 23 MOCK_METHOD2(MethodName, ReturnType(Type0, Type1)); 24 #define METHOD3(Class, ReturnType, MethodName, Type0, Type1, Type2) \ 25 MOCK_METHOD3(MethodName, ReturnType(Type0, Type1, Type2)); 26 #define METHOD4(Class, ReturnType, MethodName, Type0, Type1, Type2, Type3) \ 27 MOCK_METHOD4(MethodName, ReturnType(Type0, Type1, Type2, Type3)); 28 #define METHOD5(Class, ReturnType, MethodName, Type0, Type1, Type2, Type3, \ 29 Type4) \ 30 MOCK_METHOD5(MethodName, ReturnType(Type0, Type1, Type2, Type3, Type4)); 31 #include "nacl_io/pepper/all_interfaces.h" 32 33 34 class PepperInterfaceMock : public nacl_io::PepperInterface { 35 public: 36 explicit PepperInterfaceMock(PP_Instance instance); 37 ~PepperInterfaceMock(); 38 39 virtual PP_Instance GetInstance(); 40 MOCK_METHOD1(AddRefResource, void(PP_Resource)); 41 MOCK_METHOD1(ReleaseResource, void(PP_Resource)); 42 MOCK_METHOD0(IsMainThread, bool()); 43 44 // Interface getters. 45 #include "nacl_io/pepper/undef_macros.h" 46 #include "nacl_io/pepper/define_empty_macros.h" 47 #undef BEGIN_INTERFACE 48 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ 49 virtual BaseClass##Mock* Get##BaseClass(); 50 #include "nacl_io/pepper/all_interfaces.h" 51 52 private: 53 PP_Instance instance_; 54 55 // Interface pointers. 56 #include "nacl_io/pepper/undef_macros.h" 57 #include "nacl_io/pepper/define_empty_macros.h" 58 #undef BEGIN_INTERFACE 59 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ 60 BaseClass##Mock* BaseClass##interface_; 61 #include "nacl_io/pepper/all_interfaces.h" 62 63 int dummy_; 64 }; 65 66 67 #endif // LIBRARIES_NACL_IO_TEST_PEPPER_INTERFACE_MOCK_H_ 68