| OLD | NEW |
| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return base::Bind(&MockCallback::RunWithBool, callback); | 57 return base::Bind(&MockCallback::RunWithBool, callback); |
| 58 } | 58 } |
| 59 | 59 |
| 60 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status) { | 60 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status) { |
| 61 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>(); | 61 StrictMock<MockCallback>* callback = new StrictMock<MockCallback>(); |
| 62 EXPECT_CALL(*callback, RunWithStatus(status)); | 62 EXPECT_CALL(*callback, RunWithStatus(status)); |
| 63 return base::Bind(&MockCallback::RunWithStatus, callback); | 63 return base::Bind(&MockCallback::RunWithStatus, callback); |
| 64 } | 64 } |
| 65 | 65 |
| 66 WaitableMessageLoopEvent::WaitableMessageLoopEvent() | 66 WaitableMessageLoopEvent::WaitableMessageLoopEvent() |
| 67 : WaitableMessageLoopEvent(TestTimeouts::action_timeout()) {} |
| 68 |
| 69 WaitableMessageLoopEvent::WaitableMessageLoopEvent(base::TimeDelta timeout) |
| 67 : message_loop_(base::MessageLoop::current()), | 70 : message_loop_(base::MessageLoop::current()), |
| 68 signaled_(false), | 71 signaled_(false), |
| 69 status_(PIPELINE_OK) { | 72 status_(PIPELINE_OK), |
| 73 timeout_(timeout) { |
| 70 DCHECK(message_loop_); | 74 DCHECK(message_loop_); |
| 71 } | 75 } |
| 72 | 76 |
| 73 WaitableMessageLoopEvent::~WaitableMessageLoopEvent() {} | 77 WaitableMessageLoopEvent::~WaitableMessageLoopEvent() {} |
| 74 | 78 |
| 75 base::Closure WaitableMessageLoopEvent::GetClosure() { | 79 base::Closure WaitableMessageLoopEvent::GetClosure() { |
| 76 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 80 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
| 77 return BindToCurrentLoop(base::Bind( | 81 return BindToCurrentLoop(base::Bind( |
| 78 &WaitableMessageLoopEvent::OnCallback, base::Unretained(this), | 82 &WaitableMessageLoopEvent::OnCallback, base::Unretained(this), |
| 79 PIPELINE_OK)); | 83 PIPELINE_OK)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 91 | 95 |
| 92 void WaitableMessageLoopEvent::RunAndWaitForStatus(PipelineStatus expected) { | 96 void WaitableMessageLoopEvent::RunAndWaitForStatus(PipelineStatus expected) { |
| 93 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 97 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
| 94 if (signaled_) { | 98 if (signaled_) { |
| 95 EXPECT_EQ(expected, status_); | 99 EXPECT_EQ(expected, status_); |
| 96 return; | 100 return; |
| 97 } | 101 } |
| 98 | 102 |
| 99 run_loop_.reset(new base::RunLoop()); | 103 run_loop_.reset(new base::RunLoop()); |
| 100 base::Timer timer(false, false); | 104 base::Timer timer(false, false); |
| 101 timer.Start(FROM_HERE, TestTimeouts::action_timeout(), base::Bind( | 105 timer.Start( |
| 102 &WaitableMessageLoopEvent::OnTimeout, base::Unretained(this))); | 106 FROM_HERE, timeout_, |
| 107 base::Bind(&WaitableMessageLoopEvent::OnTimeout, base::Unretained(this))); |
| 103 | 108 |
| 104 run_loop_->Run(); | 109 run_loop_->Run(); |
| 105 EXPECT_TRUE(signaled_); | 110 EXPECT_TRUE(signaled_); |
| 106 EXPECT_EQ(expected, status_); | 111 EXPECT_EQ(expected, status_); |
| 107 run_loop_.reset(); | 112 run_loop_.reset(); |
| 108 } | 113 } |
| 109 | 114 |
| 110 void WaitableMessageLoopEvent::OnCallback(PipelineStatus status) { | 115 void WaitableMessageLoopEvent::OnCallback(PipelineStatus status) { |
| 111 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 116 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
| 112 signaled_ = true; | 117 signaled_ = true; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 int width = 0; | 275 int width = 0; |
| 271 int height = 0; | 276 int height = 0; |
| 272 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) && | 277 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) && |
| 273 pickle.ReadInt(&height); | 278 pickle.ReadInt(&height); |
| 274 return (success && header == kFakeVideoBufferHeader && | 279 return (success && header == kFakeVideoBufferHeader && |
| 275 width == config.coded_size().width() && | 280 width == config.coded_size().width() && |
| 276 height == config.coded_size().height()); | 281 height == config.coded_size().height()); |
| 277 } | 282 } |
| 278 | 283 |
| 279 } // namespace media | 284 } // namespace media |
| OLD | NEW |