1 // Copyright 2016 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 "gmock/gmock.h" 6 7 namespace blink { 8 9 namespace simple_test { 10 11 class Interface { 12 public: MyMethod(int my_param)13 virtual void MyMethod(int my_param) {} 14 }; 15 16 class MockedInterface : public Interface { 17 public: 18 MOCK_METHOD1(MyMethod, void(int)); 19 }; 20 Test()21void Test() { 22 MockedInterface mocked_interface; 23 EXPECT_CALL(mocked_interface, MyMethod(1)); 24 EXPECT_CALL( 25 mocked_interface, // A comment to prevent reformatting into single line. 26 MyMethod(1)); 27 mocked_interface.MyMethod(123); 28 29 int arg; 30 ON_CALL(mocked_interface, MyMethod(1)) 31 .WillByDefault(testing::SaveArg<0>(&arg)); 32 } 33 34 } // namespace simple_test 35 36 namespace no_base_method_to_override { 37 38 class MockDestructible { 39 public: 40 MOCK_METHOD0(Destruct, void()); 41 }; 42 Test()43void Test() { 44 MockDestructible destructible; 45 EXPECT_CALL(destructible, Destruct()); 46 } 47 48 } // namespace no_base_method_to_override 49 50 } // namespace blink 51