Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: media/base/test_helpers.cc

Issue 1143223007: media: Reland "Simplify {Audio|Video}Decoder initialization callback." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/test_helpers.h ('k') | media/base/video_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "media/base/test_helpers.h" 5 #include "media/base/test_helpers.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/test/test_timeouts.h" 12 #include "base/test/test_timeouts.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "media/base/audio_buffer.h" 15 #include "media/base/audio_buffer.h"
16 #include "media/base/bind_to_current_loop.h" 16 #include "media/base/bind_to_current_loop.h"
17 #include "media/base/decoder_buffer.h" 17 #include "media/base/decoder_buffer.h"
18 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
19 19
20 using ::testing::_; 20 using ::testing::_;
21 using ::testing::StrictMock; 21 using ::testing::StrictMock;
22 22
23 namespace media { 23 namespace media {
24 24
25 // Utility mock for testing methods expecting Closures and PipelineStatusCBs. 25 // Utility mock for testing methods expecting Closures and PipelineStatusCBs.
26 class MockCallback : public base::RefCountedThreadSafe<MockCallback> { 26 class MockCallback : public base::RefCountedThreadSafe<MockCallback> {
27 public: 27 public:
28 MockCallback(); 28 MockCallback();
29 MOCK_METHOD0(Run, void()); 29 MOCK_METHOD0(Run, void());
30 MOCK_METHOD1(RunWithBool, void(bool));
30 MOCK_METHOD1(RunWithStatus, void(PipelineStatus)); 31 MOCK_METHOD1(RunWithStatus, void(PipelineStatus));
31 32
32 protected: 33 protected:
33 friend class base::RefCountedThreadSafe<MockCallback>; 34 friend class base::RefCountedThreadSafe<MockCallback>;
34 virtual ~MockCallback(); 35 virtual ~MockCallback();
35 36
36 private: 37 private:
37 DISALLOW_COPY_AND_ASSIGN(MockCallback); 38 DISALLOW_COPY_AND_ASSIGN(MockCallback);
38 }; 39 };
39 40
40 MockCallback::MockCallback() {} 41 MockCallback::MockCallback() {}
41 MockCallback::~MockCallback() {} 42 MockCallback::~MockCallback() {}
42 43
43 base::Closure NewExpectedClosure() { 44 base::Closure NewExpectedClosure() {
44 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>(); 45 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>();
45 EXPECT_CALL(*callback, Run()); 46 EXPECT_CALL(*callback, Run());
46 return base::Bind(&MockCallback::Run, callback); 47 return base::Bind(&MockCallback::Run, callback);
47 } 48 }
48 49
50 base::Callback<void(bool)> NewExpectedBoolCB(bool success) {
51 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>();
52 EXPECT_CALL(*callback, RunWithBool(success));
53 return base::Bind(&MockCallback::RunWithBool, callback);
54 }
55
49 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status) { 56 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status) {
50 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>(); 57 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>();
51 EXPECT_CALL(*callback, RunWithStatus(status)); 58 EXPECT_CALL(*callback, RunWithStatus(status));
52 return base::Bind(&MockCallback::RunWithStatus, callback); 59 return base::Bind(&MockCallback::RunWithStatus, callback);
53 } 60 }
54 61
55 WaitableMessageLoopEvent::WaitableMessageLoopEvent() 62 WaitableMessageLoopEvent::WaitableMessageLoopEvent()
56 : message_loop_(base::MessageLoop::current()), 63 : message_loop_(base::MessageLoop::current()),
57 signaled_(false), 64 signaled_(false),
58 status_(PIPELINE_OK) { 65 status_(PIPELINE_OK) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 expecting_b_ = false; 273 expecting_b_ = false;
267 } 274 }
268 275
269 void AddLogEntryForTest(MediaLog::MediaLogLevel level, 276 void AddLogEntryForTest(MediaLog::MediaLogLevel level,
270 const std::string& message) { 277 const std::string& message) {
271 DVLOG(1) << "Media log (" << MediaLog::MediaLogLevelToString(level) 278 DVLOG(1) << "Media log (" << MediaLog::MediaLogLevelToString(level)
272 << "): " << message; 279 << "): " << message;
273 } 280 }
274 281
275 } // namespace media 282 } // namespace media
OLDNEW
« no previous file with comments | « media/base/test_helpers.h ('k') | media/base/video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698