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/wall_clock_time_source_unittest.cc

Issue 1129323003: Allow callers of TimeSource::GetWallClockTime() to suspend time. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 years, 7 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') | media/filters/video_renderer_algorithm.h » ('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 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/test/simple_test_tick_clock.h" 5 #include "base/test/simple_test_tick_clock.h"
6 #include "media/base/wall_clock_time_source.h" 6 #include "media/base/wall_clock_time_source.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 int CurrentMediaTimeInSeconds() { 24 int CurrentMediaTimeInSeconds() {
25 return time_source_.CurrentMediaTime().InSeconds(); 25 return time_source_.CurrentMediaTime().InSeconds();
26 } 26 }
27 27
28 void SetMediaTimeInSeconds(int seconds) { 28 void SetMediaTimeInSeconds(int seconds) {
29 return time_source_.SetMediaTime(base::TimeDelta::FromSeconds(seconds)); 29 return time_source_.SetMediaTime(base::TimeDelta::FromSeconds(seconds));
30 } 30 }
31 31
32 bool IsWallClockNowForMediaTimeInSeconds(int seconds) { 32 bool IsWallClockNowForMediaTimeInSeconds(int seconds) {
33 return tick_clock_->NowTicks() == 33 return tick_clock_->NowTicks() ==
34 time_source_.GetWallClockTime(base::TimeDelta::FromSeconds(seconds)); 34 time_source_.GetWallClockTime(base::TimeDelta::FromSeconds(seconds),
35 TimeSource::SINGLE_TIMESTAMP);
35 } 36 }
36 37
37 bool IsWallClockNullForMediaTimeInSeconds(int seconds) { 38 bool IsWallClockNullForMediaTimeInSeconds(int seconds) {
38 return time_source_.GetWallClockTime(base::TimeDelta::FromSeconds(seconds)) 39 return time_source_.GetWallClockTime(base::TimeDelta::FromSeconds(seconds),
40 TimeSource::SINGLE_TIMESTAMP)
39 .is_null(); 41 .is_null();
40 } 42 }
41 43
42 protected: 44 protected:
43 WallClockTimeSource time_source_; 45 WallClockTimeSource time_source_;
44 base::SimpleTestTickClock* tick_clock_; // Owned by |time_source_|. 46 base::SimpleTestTickClock* tick_clock_; // Owned by |time_source_|.
45 47
46 DISALLOW_COPY_AND_ASSIGN(WallClockTimeSourceTest); 48 DISALLOW_COPY_AND_ASSIGN(WallClockTimeSourceTest);
47 }; 49 };
48 50
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 EXPECT_TRUE(IsWallClockNowForMediaTimeInSeconds(10)); 107 EXPECT_TRUE(IsWallClockNowForMediaTimeInSeconds(10));
106 108
107 time_source_.StopTicking(); 109 time_source_.StopTicking();
108 110
109 AdvanceTimeInSeconds(10); 111 AdvanceTimeInSeconds(10);
110 EXPECT_EQ(10, CurrentMediaTimeInSeconds()); 112 EXPECT_EQ(10, CurrentMediaTimeInSeconds());
111 EXPECT_TRUE(IsWallClockNullForMediaTimeInSeconds(10)); 113 EXPECT_TRUE(IsWallClockNullForMediaTimeInSeconds(10));
112 } 114 }
113 115
114 } // namespace media 116 } // namespace media
OLDNEW
« no previous file with comments | « media/base/wall_clock_time_source.cc ('k') | media/filters/video_renderer_algorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698