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

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

Issue 9225001: Remove two static initializers (media/base/{buffers,media_log}.cc) (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
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 "media/base/pts_stream.h" 5 #include "media/base/pts_stream.h"
6 #include "media/base/video_frame.h" 6 #include "media/base/video_frame.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace media { 9 namespace media {
10 10
(...skipping 13 matching lines...) Expand all
24 PtsStream pts_stream_; 24 PtsStream pts_stream_;
25 scoped_refptr<VideoFrame> video_frame_; 25 scoped_refptr<VideoFrame> video_frame_;
26 26
27 private: 27 private:
28 DISALLOW_COPY_AND_ASSIGN(PtsStreamTest); 28 DISALLOW_COPY_AND_ASSIGN(PtsStreamTest);
29 }; 29 };
30 30
31 TEST_F(PtsStreamTest, NoTimestamp) { 31 TEST_F(PtsStreamTest, NoTimestamp) {
32 // Simulate an uninitialized |video_frame| where we cannot determine a 32 // Simulate an uninitialized |video_frame| where we cannot determine a
33 // timestamp at all. 33 // timestamp at all.
34 video_frame_->SetTimestamp(kNoTimestamp); 34 video_frame_->SetTimestamp(kNoTimestamp());
35 video_frame_->SetDuration(kNoTimestamp); 35 video_frame_->SetDuration(kNoTimestamp());
36 pts_stream_.UpdatePtsAndDuration(video_frame_); 36 pts_stream_.UpdatePtsAndDuration(video_frame_);
37 EXPECT_EQ(0, pts_stream_.current_pts().InMicroseconds()); 37 EXPECT_EQ(0, pts_stream_.current_pts().InMicroseconds());
38 EXPECT_EQ(40000, pts_stream_.current_duration().InMicroseconds()); 38 EXPECT_EQ(40000, pts_stream_.current_duration().InMicroseconds());
39 } 39 }
40 40
41 TEST_F(PtsStreamTest, LastKnownTimestamp) { 41 TEST_F(PtsStreamTest, LastKnownTimestamp) {
42 // Setup the last known pts to be at 100 microseconds with 16 microsecond 42 // Setup the last known pts to be at 100 microseconds with 16 microsecond
43 // duration. 43 // duration.
44 video_frame_->SetTimestamp(base::TimeDelta::FromMicroseconds(100)); 44 video_frame_->SetTimestamp(base::TimeDelta::FromMicroseconds(100));
45 video_frame_->SetDuration(base::TimeDelta::FromMicroseconds(16)); 45 video_frame_->SetDuration(base::TimeDelta::FromMicroseconds(16));
46 pts_stream_.UpdatePtsAndDuration(video_frame_); 46 pts_stream_.UpdatePtsAndDuration(video_frame_);
47 47
48 // Simulate an uninitialized |video_frame| where last known pts will be used 48 // Simulate an uninitialized |video_frame| where last known pts will be used
49 // to generate a timestamp and |frame_duration| will be used to generate a 49 // to generate a timestamp and |frame_duration| will be used to generate a
50 // duration. 50 // duration.
51 video_frame_->SetTimestamp(kNoTimestamp); 51 video_frame_->SetTimestamp(kNoTimestamp());
52 video_frame_->SetDuration(kNoTimestamp); 52 video_frame_->SetDuration(kNoTimestamp());
53 pts_stream_.UpdatePtsAndDuration(video_frame_); 53 pts_stream_.UpdatePtsAndDuration(video_frame_);
54 EXPECT_EQ(116, pts_stream_.current_pts().InMicroseconds()); 54 EXPECT_EQ(116, pts_stream_.current_pts().InMicroseconds());
55 EXPECT_EQ(40000, pts_stream_.current_duration().InMicroseconds()); 55 EXPECT_EQ(40000, pts_stream_.current_duration().InMicroseconds());
56 } 56 }
57 57
58 TEST_F(PtsStreamTest, TimestampIsZero) { 58 TEST_F(PtsStreamTest, TimestampIsZero) {
59 // Test that having pts == 0 in the frame also behaves like the pts is not 59 // Test that having pts == 0 in the frame also behaves like the pts is not
60 // provided. This is because FFmpeg set the pts to zero when there is no 60 // provided. This is because FFmpeg set the pts to zero when there is no
61 // data for the frame, which means that value is useless to us. 61 // data for the frame, which means that value is useless to us.
62 // 62 //
(...skipping 29 matching lines...) Expand all
92 pts_stream_.EnqueuePts(video_frame_); 92 pts_stream_.EnqueuePts(video_frame_);
93 93
94 video_frame_->SetTimestamp(base::TimeDelta::FromMicroseconds(0)); 94 video_frame_->SetTimestamp(base::TimeDelta::FromMicroseconds(0));
95 video_frame_->SetDuration(base::TimeDelta::FromMicroseconds(789)); 95 video_frame_->SetDuration(base::TimeDelta::FromMicroseconds(789));
96 pts_stream_.UpdatePtsAndDuration(video_frame_); 96 pts_stream_.UpdatePtsAndDuration(video_frame_);
97 EXPECT_EQ(456, pts_stream_.current_pts().InMicroseconds()); 97 EXPECT_EQ(456, pts_stream_.current_pts().InMicroseconds());
98 EXPECT_EQ(789, pts_stream_.current_duration().InMicroseconds()); 98 EXPECT_EQ(789, pts_stream_.current_duration().InMicroseconds());
99 } 99 }
100 100
101 } // namespace media 101 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698