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

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

Issue 2239243002: Interpolate media time for mojo rendering pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/test/simple_test_tick_clock.h" 6 #include "base/test/simple_test_tick_clock.h"
7 #include "media/base/time_delta_interpolator.h" 7 #include "media/base/time_delta_interpolator.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 AdvanceSystemTime(kPlayDuration); 120 AdvanceSystemTime(kPlayDuration);
121 EXPECT_EQ(kExpectedSecondPause, interpolator_.StopInterpolating()); 121 EXPECT_EQ(kExpectedSecondPause, interpolator_.StopInterpolating());
122 EXPECT_EQ(kExpectedSecondPause, interpolator_.GetInterpolatedTime()); 122 EXPECT_EQ(kExpectedSecondPause, interpolator_.GetInterpolatedTime());
123 } 123 }
124 124
125 TEST_F(TimeDeltaInterpolatorTest, SetBounds_Stopped) { 125 TEST_F(TimeDeltaInterpolatorTest, SetBounds_Stopped) {
126 const base::TimeDelta kFirstTime = base::TimeDelta::FromSeconds(4); 126 const base::TimeDelta kFirstTime = base::TimeDelta::FromSeconds(4);
127 const base::TimeDelta kSecondTime = base::TimeDelta::FromSeconds(16); 127 const base::TimeDelta kSecondTime = base::TimeDelta::FromSeconds(16);
128 const base::TimeDelta kArbitraryMaxTime = base::TimeDelta::FromSeconds(100); 128 const base::TimeDelta kArbitraryMaxTime = base::TimeDelta::FromSeconds(100);
129 129
130 interpolator_.SetBounds(kFirstTime, kArbitraryMaxTime); 130 interpolator_.SetBounds(kFirstTime, kArbitraryMaxTime,
131 test_tick_clock_.NowTicks());
131 EXPECT_EQ(kFirstTime, interpolator_.GetInterpolatedTime()); 132 EXPECT_EQ(kFirstTime, interpolator_.GetInterpolatedTime());
132 interpolator_.SetBounds(kSecondTime, kArbitraryMaxTime); 133 interpolator_.SetBounds(kSecondTime, kArbitraryMaxTime,
134 test_tick_clock_.NowTicks());
133 EXPECT_EQ(kSecondTime, interpolator_.GetInterpolatedTime()); 135 EXPECT_EQ(kSecondTime, interpolator_.GetInterpolatedTime());
134 } 136 }
135 137
136 TEST_F(TimeDeltaInterpolatorTest, SetBounds_Started) { 138 TEST_F(TimeDeltaInterpolatorTest, SetBounds_Started) {
137 // We'll play for 4 seconds, then set the time to 12, then play for 4 more 139 // We'll play for 4 seconds, then set the time to 12, then play for 4 more
138 // seconds. 140 // seconds.
139 const base::TimeDelta kZero; 141 const base::TimeDelta kZero;
140 const base::TimeDelta kPlayDuration = base::TimeDelta::FromSeconds(4); 142 const base::TimeDelta kPlayDuration = base::TimeDelta::FromSeconds(4);
141 const base::TimeDelta kUpdatedTime = base::TimeDelta::FromSeconds(12); 143 const base::TimeDelta kUpdatedTime = base::TimeDelta::FromSeconds(12);
142 const base::TimeDelta kArbitraryMaxTime = base::TimeDelta::FromSeconds(100); 144 const base::TimeDelta kArbitraryMaxTime = base::TimeDelta::FromSeconds(100);
143 const base::TimeDelta kExpected = kUpdatedTime + kPlayDuration; 145 const base::TimeDelta kExpected = kUpdatedTime + kPlayDuration;
144 146
145 EXPECT_EQ(kZero, interpolator_.StartInterpolating()); 147 EXPECT_EQ(kZero, interpolator_.StartInterpolating());
146 AdvanceSystemTime(kPlayDuration); 148 AdvanceSystemTime(kPlayDuration);
147 149
148 interpolator_.SetBounds(kUpdatedTime, kArbitraryMaxTime); 150 interpolator_.SetBounds(kUpdatedTime, kArbitraryMaxTime,
151 test_tick_clock_.NowTicks());
149 AdvanceSystemTime(kPlayDuration); 152 AdvanceSystemTime(kPlayDuration);
150 EXPECT_EQ(kExpected, interpolator_.GetInterpolatedTime()); 153 EXPECT_EQ(kExpected, interpolator_.GetInterpolatedTime());
151 } 154 }
152 155
153 TEST_F(TimeDeltaInterpolatorTest, SetUpperBound) { 156 TEST_F(TimeDeltaInterpolatorTest, SetUpperBound) {
154 const base::TimeDelta kZero; 157 const base::TimeDelta kZero;
155 const base::TimeDelta kTimeInterval = base::TimeDelta::FromSeconds(4); 158 const base::TimeDelta kTimeInterval = base::TimeDelta::FromSeconds(4);
156 const base::TimeDelta kMaxTime = base::TimeDelta::FromSeconds(6); 159 const base::TimeDelta kMaxTime = base::TimeDelta::FromSeconds(6);
157 160
158 EXPECT_EQ(kZero, interpolator_.StartInterpolating()); 161 EXPECT_EQ(kZero, interpolator_.StartInterpolating());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 EXPECT_EQ(kMaxTime1, interpolator_.GetInterpolatedTime()); 193 EXPECT_EQ(kMaxTime1, interpolator_.GetInterpolatedTime());
191 194
192 AdvanceSystemTime(kTimeInterval); 195 AdvanceSystemTime(kTimeInterval);
193 EXPECT_EQ(kMaxTime1 + kTimeInterval, interpolator_.GetInterpolatedTime()); 196 EXPECT_EQ(kMaxTime1 + kTimeInterval, interpolator_.GetInterpolatedTime());
194 197
195 AdvanceSystemTime(kTimeInterval); 198 AdvanceSystemTime(kTimeInterval);
196 EXPECT_EQ(kMaxTime2, interpolator_.GetInterpolatedTime()); 199 EXPECT_EQ(kMaxTime2, interpolator_.GetInterpolatedTime());
197 } 200 }
198 201
199 } // namespace media 202 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698