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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "media/base/media_log.h" | 12 #include "media/base/media_log.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 | 14 |
15 // Helper macros to reduce boilerplate when verifying media log entries. | 15 // Helper macros to reduce boilerplate when verifying media log entries. |
16 // |outer| is the std::string searched for substring |sub|. | 16 // |outer| is the std::string searched for substring |sub|. |
17 #define CONTAINS_STRING(outer, sub) (std::string::npos != (outer).find(sub)) | 17 #define CONTAINS_STRING(outer, sub) (std::string::npos != (outer).find(sub)) |
18 | 18 |
19 // "media_log_" is expected to be a scoped_refptr<MockMediaLog>, optionally a | 19 // "media_log_" is expected to be a MockMediaLog, optionally a StrictMock, in |
20 // StrictMock, in scope of the usage of this macro. | 20 // scope of the usage of this macro. |
21 #define EXPECT_MEDIA_LOG(x) EXPECT_CALL(*media_log_, DoAddEventLogString((x))) | 21 #define EXPECT_MEDIA_LOG(x) EXPECT_CALL(media_log_, DoAddEventLogString((x))) |
22 | 22 |
23 namespace media { | 23 namespace media { |
24 | 24 |
25 class MockMediaLog : public MediaLog { | 25 class MockMediaLog : public MediaLog { |
26 public: | 26 public: |
27 MockMediaLog(); | 27 MockMediaLog(); |
| 28 ~MockMediaLog() override; |
28 | 29 |
29 MOCK_METHOD1(DoAddEventLogString, void(const std::string& event)); | 30 MOCK_METHOD1(DoAddEventLogString, void(const std::string& event)); |
30 | 31 |
31 // Trampoline method to workaround GMOCK problems with std::unique_ptr<>. | 32 // Trampoline method to workaround GMOCK problems with std::unique_ptr<>. |
32 // Also simplifies tests to be able to string match on the log string | 33 // Also simplifies tests to be able to string match on the log string |
33 // representation on the added event. | 34 // representation on the added event. |
34 void AddEvent(std::unique_ptr<MediaLogEvent> event) override { | 35 void AddEvent(std::unique_ptr<MediaLogEvent> event) override { |
35 DoAddEventLogString(MediaEventToLogString(*event)); | 36 DoAddEventLogString(MediaEventToLogString(*event)); |
36 } | 37 } |
37 | 38 |
38 protected: | |
39 virtual ~MockMediaLog(); | |
40 | |
41 private: | 39 private: |
42 DISALLOW_COPY_AND_ASSIGN(MockMediaLog); | 40 DISALLOW_COPY_AND_ASSIGN(MockMediaLog); |
43 }; | 41 }; |
44 | 42 |
45 } // namespace media | 43 } // namespace media |
46 | 44 |
47 #endif // MEDIA_BASE_MOCK_MEDIA_LOG_H_ | 45 #endif // MEDIA_BASE_MOCK_MEDIA_LOG_H_ |
OLD | NEW |