| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gmock/gmock.h" | 5 #include "gmock/gmock.h" |
| 6 | 6 |
| 7 namespace blink { | 7 namespace blink { |
| 8 | 8 |
| 9 namespace simple_test { | 9 namespace simple_test { |
| 10 | 10 |
| 11 class Interface { | 11 class Interface { |
| 12 public: | 12 public: |
| 13 virtual void MyMethod(int my_param) {} | 13 virtual void MyMethod(int my_param) {} |
| 14 }; | 14 }; |
| 15 | 15 |
| 16 class MockedInterface : public Interface { | 16 class MockedInterface : public Interface { |
| 17 public: | 17 public: |
| 18 MOCK_METHOD1(MyMethod, void(int)); | 18 MOCK_METHOD1(MyMethod, void(int)); |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 void Test() { | 21 void Test() { |
| 22 MockedInterface mocked_interface; | 22 MockedInterface mocked_interface; |
| 23 EXPECT_CALL(mocked_interface, MyMethod(1)); | 23 EXPECT_CALL(mocked_interface, MyMethod(1)); |
| 24 EXPECT_CALL( | 24 EXPECT_CALL( |
| 25 mocked_interface, // A comment to prevent reformatting into single line. | 25 mocked_interface, // A comment to prevent reformatting into single line. |
| 26 MyMethod(1)); | 26 MyMethod(1)); |
| 27 mocked_interface.MyMethod(123); | 27 mocked_interface.MyMethod(123); |
| 28 |
| 29 int arg; |
| 30 ON_CALL(mocked_interface, MyMethod(1)) |
| 31 .WillByDefault(testing::SaveArg<0>(&arg)); |
| 28 } | 32 } |
| 29 | 33 |
| 30 } // namespace simple_test | 34 } // namespace simple_test |
| 31 | 35 |
| 32 namespace no_base_method_to_override { | 36 namespace no_base_method_to_override { |
| 33 | 37 |
| 34 class MockDestructible { | 38 class MockDestructible { |
| 35 public: | 39 public: |
| 36 MOCK_METHOD0(Destruct, void()); | 40 MOCK_METHOD0(Destruct, void()); |
| 37 }; | 41 }; |
| 38 | 42 |
| 39 void Test() { | 43 void Test() { |
| 40 MockDestructible destructible; | 44 MockDestructible destructible; |
| 41 EXPECT_CALL(destructible, Destruct()); | 45 EXPECT_CALL(destructible, Destruct()); |
| 42 } | 46 } |
| 43 | 47 |
| 44 } // namespace no_base_method_to_override | 48 } // namespace no_base_method_to_override |
| 45 | 49 |
| 46 } // namespace blink | 50 } // namespace blink |
| OLD | NEW |