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

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

Issue 9015015: Take advantage of the new Pass() machinery on scoped_ptr{,_malloc}. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | media/base/test_data_util.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/threading/simple_thread.h" 10 #include "base/threading/simple_thread.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 // But some tests require different statuses in build & Start. 199 // But some tests require different statuses in build & Start.
200 void InitializePipeline(PipelineStatus build_status, 200 void InitializePipeline(PipelineStatus build_status,
201 PipelineStatus start_status) { 201 PipelineStatus start_status) {
202 // Expect an initialization callback. 202 // Expect an initialization callback.
203 EXPECT_CALL(callbacks_, OnStart(start_status)); 203 EXPECT_CALL(callbacks_, OnStart(start_status));
204 204
205 pipeline_->Start(mocks_->filter_collection(true, 205 pipeline_->Start(mocks_->filter_collection(true,
206 true, 206 true,
207 true, 207 true,
208 build_status), 208 build_status).Pass(),
209 "", 209 "",
210 base::Bind(&CallbackHelper::OnStart, 210 base::Bind(&CallbackHelper::OnStart,
211 base::Unretained(&callbacks_))); 211 base::Unretained(&callbacks_)));
212 212
213 message_loop_.RunAllPending(); 213 message_loop_.RunAllPending();
214 } 214 }
215 215
216 void CreateAudioStream() { 216 void CreateAudioStream() {
217 audio_stream_ = CreateStream(DemuxerStream::AUDIO); 217 audio_stream_ = CreateStream(DemuxerStream::AUDIO);
218 } 218 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 EXPECT_EQ(0, size.height()); 321 EXPECT_EQ(0, size.height());
322 } 322 }
323 323
324 TEST_F(PipelineImplTest, NeverInitializes) { 324 TEST_F(PipelineImplTest, NeverInitializes) {
325 // This test hangs during initialization by never calling 325 // This test hangs during initialization by never calling
326 // InitializationComplete(). StrictMock<> will ensure that the callback is 326 // InitializationComplete(). StrictMock<> will ensure that the callback is
327 // never executed. 327 // never executed.
328 pipeline_->Start(mocks_->filter_collection(false, 328 pipeline_->Start(mocks_->filter_collection(false,
329 false, 329 false,
330 true, 330 true,
331 PIPELINE_OK), 331 PIPELINE_OK).Pass(),
332 "", 332 "",
333 base::Bind(&CallbackHelper::OnStart, 333 base::Bind(&CallbackHelper::OnStart,
334 base::Unretained(&callbacks_))); 334 base::Unretained(&callbacks_)));
335 message_loop_.RunAllPending(); 335 message_loop_.RunAllPending();
336 336
337 EXPECT_FALSE(pipeline_->IsInitialized()); 337 EXPECT_FALSE(pipeline_->IsInitialized());
338 338
339 // Because our callback will get executed when the test tears down, we'll 339 // Because our callback will get executed when the test tears down, we'll
340 // verify that nothing has been called, then set our expectation for the call 340 // verify that nothing has been called, then set our expectation for the call
341 // made during tear down. 341 // made during tear down.
342 Mock::VerifyAndClear(&callbacks_); 342 Mock::VerifyAndClear(&callbacks_);
343 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); 343 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK));
344 } 344 }
345 345
346 TEST_F(PipelineImplTest, RequiredFilterMissing) { 346 TEST_F(PipelineImplTest, RequiredFilterMissing) {
347 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); 347 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING));
348 348
349 // Sets up expectations on the callback and initializes the pipeline. Called 349 // Sets up expectations on the callback and initializes the pipeline. Called
350 // after tests have set expectations any filters they wish to use. 350 // after tests have set expectations any filters they wish to use.
351 // Expect an initialization callback. 351 // Expect an initialization callback.
352 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); 352 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING));
353 353
354 // Create a filter collection with missing filter. 354 // Create a filter collection with missing filter.
355 FilterCollection* collection = 355 scoped_ptr<FilterCollection> collection(mocks_->filter_collection(
356 mocks_->filter_collection(false, 356 false, true, true, PIPELINE_ERROR_REQUIRED_FILTER_MISSING));
357 true, 357 pipeline_->Start(collection.Pass(), "",
358 true,
359 PIPELINE_ERROR_REQUIRED_FILTER_MISSING);
360 pipeline_->Start(collection, "",
361 base::Bind(&CallbackHelper::OnStart, 358 base::Bind(&CallbackHelper::OnStart,
362 base::Unretained(&callbacks_))); 359 base::Unretained(&callbacks_)));
363 message_loop_.RunAllPending(); 360 message_loop_.RunAllPending();
364 361
365 EXPECT_FALSE(pipeline_->IsInitialized()); 362 EXPECT_FALSE(pipeline_->IsInitialized());
366 } 363 }
367 364
368 TEST_F(PipelineImplTest, URLNotFound) { 365 TEST_F(PipelineImplTest, URLNotFound) {
369 // TODO(acolwell,fischman): Since OnStart() is getting called with an error 366 // TODO(acolwell,fischman): Since OnStart() is getting called with an error
370 // code already, OnError() doesn't also need to get called. Fix the pipeline 367 // code already, OnError() doesn't also need to get called. Fix the pipeline
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 TestPipelineStatusNotification(0); 916 TestPipelineStatusNotification(0);
920 } 917 }
921 918
922 // Test that different-thread, some-delay callback (the expected common case) 919 // Test that different-thread, some-delay callback (the expected common case)
923 // works correctly. 920 // works correctly.
924 TEST(PipelineStatusNotificationTest, DelayedCallback) { 921 TEST(PipelineStatusNotificationTest, DelayedCallback) {
925 TestPipelineStatusNotification(20); 922 TestPipelineStatusNotification(20);
926 } 923 }
927 924
928 } // namespace media 925 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | media/base/test_data_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698