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

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

Issue 1146913008: Revert of media: 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));
31 MOCK_METHOD1(RunWithStatus, void(PipelineStatus)); 30 MOCK_METHOD1(RunWithStatus, void(PipelineStatus));
32 31
33 protected: 32 protected:
34 friend class base::RefCountedThreadSafe<MockCallback>; 33 friend class base::RefCountedThreadSafe<MockCallback>;
35 virtual ~MockCallback(); 34 virtual ~MockCallback();
36 35
37 private: 36 private:
38 DISALLOW_COPY_AND_ASSIGN(MockCallback); 37 DISALLOW_COPY_AND_ASSIGN(MockCallback);
39 }; 38 };
40 39
41 MockCallback::MockCallback() {} 40 MockCallback::MockCallback() {}
42 MockCallback::~MockCallback() {} 41 MockCallback::~MockCallback() {}
43 42
44 base::Closure NewExpectedClosure() { 43 base::Closure NewExpectedClosure() {
45 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>(); 44 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>();
46 EXPECT_CALL(*callback, Run()); 45 EXPECT_CALL(*callback, Run());
47 return base::Bind(&MockCallback::Run, callback); 46 return base::Bind(&MockCallback::Run, callback);
48 } 47 }
49 48
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
56 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status) { 49 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status) {
57 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>(); 50 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>();
58 EXPECT_CALL(*callback, RunWithStatus(status)); 51 EXPECT_CALL(*callback, RunWithStatus(status));
59 return base::Bind(&MockCallback::RunWithStatus, callback); 52 return base::Bind(&MockCallback::RunWithStatus, callback);
60 } 53 }
61 54
62 WaitableMessageLoopEvent::WaitableMessageLoopEvent() 55 WaitableMessageLoopEvent::WaitableMessageLoopEvent()
63 : message_loop_(base::MessageLoop::current()), 56 : message_loop_(base::MessageLoop::current()),
64 signaled_(false), 57 signaled_(false),
65 status_(PIPELINE_OK) { 58 status_(PIPELINE_OK) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 expecting_b_ = false; 266 expecting_b_ = false;
274 } 267 }
275 268
276 void AddLogEntryForTest(MediaLog::MediaLogLevel level, 269 void AddLogEntryForTest(MediaLog::MediaLogLevel level,
277 const std::string& message) { 270 const std::string& message) {
278 DVLOG(1) << "Media log (" << MediaLog::MediaLogLevelToString(level) 271 DVLOG(1) << "Media log (" << MediaLog::MediaLogLevelToString(level)
279 << "): " << message; 272 << "): " << message;
280 } 273 }
281 274
282 } // namespace media 275 } // 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