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

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

Issue 2322393002: Clear reference time after SetMediaTime in video-only time source. (Closed)
Patch Set: Created 4 years, 3 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/wall_clock_time_source.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <memory> 5 #include <memory>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "media/base/wall_clock_time_source.h" 9 #include "media/base/wall_clock_time_source.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 EXPECT_EQ(100, CurrentMediaTimeInSeconds()); 82 EXPECT_EQ(100, CurrentMediaTimeInSeconds());
83 EXPECT_TRUE(IsWallClockNowForMediaTimeInSeconds(100)); 83 EXPECT_TRUE(IsWallClockNowForMediaTimeInSeconds(100));
84 } 84 }
85 85
86 TEST_F(WallClockTimeSourceTest, SetMediaTime) { 86 TEST_F(WallClockTimeSourceTest, SetMediaTime) {
87 EXPECT_EQ(0, CurrentMediaTimeInSeconds()); 87 EXPECT_EQ(0, CurrentMediaTimeInSeconds());
88 EXPECT_TRUE(IsTimeStopped()); 88 EXPECT_TRUE(IsTimeStopped());
89 SetMediaTimeInSeconds(10); 89 SetMediaTimeInSeconds(10);
90 EXPECT_EQ(10, CurrentMediaTimeInSeconds()); 90 EXPECT_EQ(10, CurrentMediaTimeInSeconds());
91 EXPECT_TRUE(IsTimeStopped()); 91 EXPECT_TRUE(IsTimeStopped());
92 std::vector<base::TimeTicks> wall_clock_times;
93 time_source_.GetWallClockTimes(std::vector<base::TimeDelta>(),
94 &wall_clock_times);
95 EXPECT_EQ(base::TimeTicks(), wall_clock_times[0]);
92 } 96 }
93 97
94 TEST_F(WallClockTimeSourceTest, SetPlaybackRate) { 98 TEST_F(WallClockTimeSourceTest, SetPlaybackRate) {
95 time_source_.StartTicking(); 99 time_source_.StartTicking();
96 100
97 time_source_.SetPlaybackRate(0.5); 101 time_source_.SetPlaybackRate(0.5);
98 EXPECT_EQ(0, CurrentMediaTimeInSeconds()); 102 EXPECT_EQ(0, CurrentMediaTimeInSeconds());
99 EXPECT_TRUE(IsWallClockNowForMediaTimeInSeconds(0)); 103 EXPECT_TRUE(IsWallClockNowForMediaTimeInSeconds(0));
100 AdvanceTimeInSeconds(10); 104 AdvanceTimeInSeconds(10);
101 EXPECT_EQ(5, CurrentMediaTimeInSeconds()); 105 EXPECT_EQ(5, CurrentMediaTimeInSeconds());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 std::vector<base::TimeDelta>(), &wall_clock_times); 160 std::vector<base::TimeDelta>(), &wall_clock_times);
157 EXPECT_TRUE(is_time_moving); 161 EXPECT_TRUE(is_time_moving);
158 EXPECT_EQ(tick_clock_->NowTicks(), wall_clock_times[0]); 162 EXPECT_EQ(tick_clock_->NowTicks(), wall_clock_times[0]);
159 163
160 wall_clock_times.clear(); 164 wall_clock_times.clear();
161 time_source_.StopTicking(); 165 time_source_.StopTicking();
162 is_time_moving = time_source_.GetWallClockTimes( 166 is_time_moving = time_source_.GetWallClockTimes(
163 std::vector<base::TimeDelta>(), &wall_clock_times); 167 std::vector<base::TimeDelta>(), &wall_clock_times);
164 EXPECT_FALSE(is_time_moving); 168 EXPECT_FALSE(is_time_moving);
165 EXPECT_EQ(tick_clock_->NowTicks(), wall_clock_times[0]); 169 EXPECT_EQ(tick_clock_->NowTicks(), wall_clock_times[0]);
170
171 // Setting media time should clear reference time.
172 SetMediaTimeInSeconds(5);
173 wall_clock_times.clear();
174 is_time_moving = time_source_.GetWallClockTimes(
175 std::vector<base::TimeDelta>(), &wall_clock_times);
176 EXPECT_FALSE(is_time_moving);
177 EXPECT_EQ(base::TimeTicks(), wall_clock_times[0]);
166 } 178 }
167 179
168 } // namespace media 180 } // namespace media
OLDNEW
« no previous file with comments | « media/base/wall_clock_time_source.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698