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