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

Side by Side Diff: media/filters/fake_video_decoder_unittest.cc

Issue 16297002: Update media/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/fake_video_decoder.cc ('k') | media/filters/ffmpeg_audio_decoder.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "media/base/decoder_buffer.h" 8 #include "media/base/decoder_buffer.h"
9 #include "media/base/mock_filters.h" 9 #include "media/base/mock_filters.h"
10 #include "media/base/test_helpers.h" 10 #include "media/base/test_helpers.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Callback for VideoDecoder::Read(). 46 // Callback for VideoDecoder::Read().
47 void FrameReady(VideoDecoder::Status status, 47 void FrameReady(VideoDecoder::Status status,
48 const scoped_refptr<VideoFrame>& frame) { 48 const scoped_refptr<VideoFrame>& frame) {
49 DCHECK(is_read_pending_); 49 DCHECK(is_read_pending_);
50 ASSERT_EQ(VideoDecoder::kOk, status); 50 ASSERT_EQ(VideoDecoder::kOk, status);
51 51
52 is_read_pending_ = false; 52 is_read_pending_ = false;
53 frame_read_ = frame; 53 frame_read_ = frame;
54 54
55 if (frame && !frame->IsEndOfStream()) 55 if (frame.get() && !frame->IsEndOfStream())
56 num_decoded_frames_++; 56 num_decoded_frames_++;
57 } 57 }
58 58
59 enum CallbackResult { 59 enum CallbackResult {
60 PENDING, 60 PENDING,
61 OK, 61 OK,
62 ABROTED, 62 ABROTED,
63 EOS 63 EOS
64 }; 64 };
65 65
66 void ExpectReadResult(CallbackResult result) { 66 void ExpectReadResult(CallbackResult result) {
67 switch (result) { 67 switch (result) {
68 case PENDING: 68 case PENDING:
69 EXPECT_TRUE(is_read_pending_); 69 EXPECT_TRUE(is_read_pending_);
70 ASSERT_FALSE(frame_read_); 70 ASSERT_FALSE(frame_read_.get());
71 break; 71 break;
72 case OK: 72 case OK:
73 EXPECT_FALSE(is_read_pending_); 73 EXPECT_FALSE(is_read_pending_);
74 ASSERT_TRUE(frame_read_); 74 ASSERT_TRUE(frame_read_.get());
75 EXPECT_FALSE(frame_read_->IsEndOfStream()); 75 EXPECT_FALSE(frame_read_->IsEndOfStream());
76 break; 76 break;
77 case ABROTED: 77 case ABROTED:
78 EXPECT_FALSE(is_read_pending_); 78 EXPECT_FALSE(is_read_pending_);
79 EXPECT_FALSE(frame_read_); 79 EXPECT_FALSE(frame_read_.get());
80 break; 80 break;
81 case EOS: 81 case EOS:
82 EXPECT_FALSE(is_read_pending_); 82 EXPECT_FALSE(is_read_pending_);
83 ASSERT_TRUE(frame_read_); 83 ASSERT_TRUE(frame_read_.get());
84 EXPECT_TRUE(frame_read_->IsEndOfStream()); 84 EXPECT_TRUE(frame_read_->IsEndOfStream());
85 break; 85 break;
86 } 86 }
87 } 87 }
88 88
89 void ReadOneFrame() { 89 void ReadOneFrame() {
90 frame_read_ = NULL; 90 frame_read_ = NULL;
91 is_read_pending_ = true; 91 is_read_pending_ = true;
92 decoder_->Read( 92 decoder_->Read(
93 base::Bind(&FakeVideoDecoderTest::FrameReady, base::Unretained(this))); 93 base::Bind(&FakeVideoDecoderTest::FrameReady, base::Unretained(this)));
94 message_loop_.RunUntilIdle(); 94 message_loop_.RunUntilIdle();
95 } 95 }
96 96
97 void ReadUntilEOS() { 97 void ReadUntilEOS() {
98 do { 98 do {
99 ReadOneFrame(); 99 ReadOneFrame();
100 } while (frame_read_ && !frame_read_->IsEndOfStream()); 100 } while (frame_read_.get() && !frame_read_->IsEndOfStream());
101 } 101 }
102 102
103 void EnterPendingReadState() { 103 void EnterPendingReadState() {
104 decoder_->HoldNextRead(); 104 decoder_->HoldNextRead();
105 ReadOneFrame(); 105 ReadOneFrame();
106 ExpectReadResult(PENDING); 106 ExpectReadResult(PENDING);
107 } 107 }
108 108
109 void SatisfyRead() { 109 void SatisfyRead() {
110 decoder_->SatisfyRead(); 110 decoder_->SatisfyRead();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 Initialize(); 425 Initialize();
426 EnterPendingReadState(); 426 EnterPendingReadState();
427 EnterPendingResetState(); 427 EnterPendingResetState();
428 EnterPendingStopState(); 428 EnterPendingStopState();
429 SatisfyRead(); 429 SatisfyRead();
430 SatisfyReset(); 430 SatisfyReset();
431 SatisfyStop(); 431 SatisfyStop();
432 } 432 }
433 433
434 } // namespace media 434 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/fake_video_decoder.cc ('k') | media/filters/ffmpeg_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698