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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_MOCK_MEDIA_LOG_H_
6 #define MEDIA_BASE_MOCK_MEDIA_LOG_H_
10 #include "media/base/media_log.h"
11 #include "testing/gmock/include/gmock/gmock.h"
13 // Helper macros to reduce boilerplate when verifying media log entries.
14 // |outer| is the std::string searched for substring |sub|.
15 #define CONTAINS_STRING(outer, sub) (std::string::npos != (outer).find(sub))
17 // "media_log_" is expected to be a scoped_refptr<MockMediaLog>, optionally a
18 // StrictMock, in scope of the usage of this macro.
19 #define EXPECT_MEDIA_LOG(x) EXPECT_CALL(*media_log_, DoAddEventLogString((x)))
23 class MockMediaLog
: public MediaLog
{
27 MOCK_METHOD1(DoAddEventLogString
, void(const std::string
& event
));
29 // Trampoline method to workaround GMOCK problems with scoped_ptr<>.
30 // Also simplifies tests to be able to string match on the log string
31 // representation on the added event.
32 void AddEvent(scoped_ptr
<MediaLogEvent
> event
) override
{
33 DoAddEventLogString(MediaEventToLogString(*event
));
37 virtual ~MockMediaLog();
40 DISALLOW_COPY_AND_ASSIGN(MockMediaLog
);
45 #endif // MEDIA_BASE_MOCK_MEDIA_LOG_H_