Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef MEDIA_BASE_MOCK_MEDIA_LOG_H_ | 5 #ifndef MEDIA_BASE_MOCK_MEDIA_LOG_H_ |
| 6 #define MEDIA_BASE_MOCK_MEDIA_LOG_H_ | 6 #define MEDIA_BASE_MOCK_MEDIA_LOG_H_ |
| 7 | 7 |
| 8 #include "media/base/media_log.h" | 8 #include "media/base/media_log.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 | 10 |
| 11 // Helper macro to reduce boilerplate when verifying media log entries. | |
| 12 // "media_log_" is expected to be a scoped_refptr<MockMediaLog>, optionally a | |
| 13 // StrictMock, in scope of the usage of this macro. | |
| 14 #define EXPECT_MEDIA_LOG_STRING(x) \ | |
|
wolenetz
2015/08/18 21:13:48
I lifted this helper macro out of SourceBufferStre
| |
| 15 EXPECT_CALL(*media_log_, DoAddEventLogString((x))) | |
| 16 | |
| 11 namespace media { | 17 namespace media { |
| 12 | 18 |
| 13 class MockMediaLog : public MediaLog { | 19 class MockMediaLog : public MediaLog { |
| 14 public: | 20 public: |
| 15 MockMediaLog(); | 21 MockMediaLog(); |
| 16 | 22 |
| 17 MOCK_METHOD1(DoAddEventLogString, void(const std::string& event)); | 23 MOCK_METHOD1(DoAddEventLogString, void(const std::string& event)); |
| 18 | 24 |
| 19 // Trampoline method to workaround GMOCK problems with scoped_ptr<>. | 25 // Trampoline method to workaround GMOCK problems with scoped_ptr<>. |
| 20 // Also simplifies tests to be able to string match on the log string | 26 // Also simplifies tests to be able to string match on the log string |
| 21 // representation on the added event. | 27 // representation on the added event. |
| 22 void AddEvent(scoped_ptr<MediaLogEvent> event) override { | 28 void AddEvent(scoped_ptr<MediaLogEvent> event) override { |
| 23 DoAddEventLogString(MediaEventToLogString(*event)); | 29 DoAddEventLogString(MediaEventToLogString(*event)); |
| 24 } | 30 } |
| 25 | 31 |
| 26 protected: | 32 protected: |
| 27 virtual ~MockMediaLog(); | 33 virtual ~MockMediaLog(); |
| 28 | 34 |
| 29 private: | 35 private: |
| 30 DISALLOW_COPY_AND_ASSIGN(MockMediaLog); | 36 DISALLOW_COPY_AND_ASSIGN(MockMediaLog); |
| 31 }; | 37 }; |
| 32 | 38 |
| 33 } // namespace media | 39 } // namespace media |
| 34 | 40 |
| 35 #endif // MEDIA_BASE_MOCK_MEDIA_LOG_H_ | 41 #endif // MEDIA_BASE_MOCK_MEDIA_LOG_H_ |
| OLD | NEW |