Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / base / mock_media_log.h
blob421c2d2048144311c6b4ba24039c49c18ebb594c
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_
8 #include <string>
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)))
21 namespace media {
23 class MockMediaLog : public MediaLog {
24 public:
25 MockMediaLog();
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));
36 protected:
37 virtual ~MockMediaLog();
39 private:
40 DISALLOW_COPY_AND_ASSIGN(MockMediaLog);
43 } // namespace media
45 #endif // MEDIA_BASE_MOCK_MEDIA_LOG_H_