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

Side by Side Diff: media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Speculative workaround fix for win8_chromium_ng compile error. Created 4 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
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 "media/cast/logging/receiver_time_offset_estimator_impl.h" 5 #include "media/cast/logging/receiver_time_offset_estimator_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // Then the bound after all 3 events have arrived is [130-60=70, 130-20=110]. 55 // Then the bound after all 3 events have arrived is [130-60=70, 130-20=110].
56 TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { 56 TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) {
57 int64_t true_offset_ms = 100; 57 int64_t true_offset_ms = 100;
58 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); 58 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms));
59 59
60 base::TimeDelta lower_bound; 60 base::TimeDelta lower_bound;
61 base::TimeDelta upper_bound; 61 base::TimeDelta upper_bound;
62 62
63 EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); 63 EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound));
64 64
65 RtpTimestamp rtp_timestamp = 0; 65 const RtpTimeTicks rtp_timestamp;
66 uint32_t frame_id = 0; 66 uint32_t frame_id = 0;
67 67
68 AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); 68 AdvanceClocks(base::TimeDelta::FromMilliseconds(20));
69 69
70 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); 70 scoped_ptr<FrameEvent> encode_event(new FrameEvent());
71 encode_event->timestamp = sender_clock_->NowTicks(); 71 encode_event->timestamp = sender_clock_->NowTicks();
72 encode_event->type = FRAME_ENCODED; 72 encode_event->type = FRAME_ENCODED;
73 encode_event->media_type = VIDEO_EVENT; 73 encode_event->media_type = VIDEO_EVENT;
74 encode_event->rtp_timestamp = rtp_timestamp; 74 encode_event->rtp_timestamp = rtp_timestamp;
75 encode_event->frame_id = frame_id; 75 encode_event->frame_id = frame_id;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // event C occurred before event B. 138 // event C occurred before event B.
139 TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { 139 TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) {
140 int64_t true_offset_ms = 100; 140 int64_t true_offset_ms = 100;
141 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); 141 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms));
142 142
143 base::TimeDelta lower_bound; 143 base::TimeDelta lower_bound;
144 base::TimeDelta upper_bound; 144 base::TimeDelta upper_bound;
145 145
146 EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); 146 EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound));
147 147
148 RtpTimestamp rtp_timestamp = 0; 148 const RtpTimeTicks rtp_timestamp;
149 uint32_t frame_id = 0; 149 uint32_t frame_id = 0;
150 150
151 AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); 151 AdvanceClocks(base::TimeDelta::FromMilliseconds(20));
152 152
153 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); 153 scoped_ptr<FrameEvent> encode_event(new FrameEvent());
154 encode_event->timestamp = sender_clock_->NowTicks(); 154 encode_event->timestamp = sender_clock_->NowTicks();
155 encode_event->type = FRAME_ENCODED; 155 encode_event->type = FRAME_ENCODED;
156 encode_event->media_type = VIDEO_EVENT; 156 encode_event->media_type = VIDEO_EVENT;
157 encode_event->rtp_timestamp = rtp_timestamp; 157 encode_event->rtp_timestamp = rtp_timestamp;
158 encode_event->frame_id = frame_id; 158 encode_event->frame_id = frame_id;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 EXPECT_LE(true_offset_ms, upper_bound_ms); 220 EXPECT_LE(true_offset_ms, upper_bound_ms);
221 } 221 }
222 222
223 TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { 223 TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) {
224 int64_t true_offset_ms = 100; 224 int64_t true_offset_ms = 100;
225 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); 225 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms));
226 226
227 base::TimeDelta lower_bound; 227 base::TimeDelta lower_bound;
228 base::TimeDelta upper_bound; 228 base::TimeDelta upper_bound;
229 229
230 RtpTimestamp rtp_timestamp_a = 0; 230 const RtpTimeTicks rtp_timestamp_a;
231 int frame_id_a = 0; 231 int frame_id_a = 0;
232 RtpTimestamp rtp_timestamp_b = 90; 232 const RtpTimeTicks rtp_timestamp_b =
233 rtp_timestamp_a + RtpTimeDelta::FromTicks(90);
233 int frame_id_b = 1; 234 int frame_id_b = 1;
234 RtpTimestamp rtp_timestamp_c = 180; 235 const RtpTimeTicks rtp_timestamp_c =
236 rtp_timestamp_b + RtpTimeDelta::FromTicks(90);
235 int frame_id_c = 2; 237 int frame_id_c = 2;
236 238
237 // Frame 1 times: [20, 30+100, 60] 239 // Frame 1 times: [20, 30+100, 60]
238 // Frame 2 times: [30, 50+100, 55] 240 // Frame 2 times: [30, 50+100, 55]
239 // Frame 3 times: [77, 80+100, 110] 241 // Frame 3 times: [77, 80+100, 110]
240 // Bound should end up at [95, 103] 242 // Bound should end up at [95, 103]
241 // Events times in chronological order: 20, 30 x2, 50, 55, 60, 77, 80, 110 243 // Events times in chronological order: 20, 30 x2, 50, 55, 60, 77, 80, 110
242 AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); 244 AdvanceClocks(base::TimeDelta::FromMilliseconds(20));
243 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); 245 scoped_ptr<FrameEvent> encode_event(new FrameEvent());
244 encode_event->timestamp = sender_clock_->NowTicks(); 246 encode_event->timestamp = sender_clock_->NowTicks();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 int64_t lower_bound_ms = lower_bound.InMilliseconds(); 396 int64_t lower_bound_ms = lower_bound.InMilliseconds();
395 int64_t upper_bound_ms = upper_bound.InMilliseconds(); 397 int64_t upper_bound_ms = upper_bound.InMilliseconds();
396 EXPECT_GT(lower_bound_ms, 90); 398 EXPECT_GT(lower_bound_ms, 90);
397 EXPECT_LE(lower_bound_ms, true_offset_ms); 399 EXPECT_LE(lower_bound_ms, true_offset_ms);
398 EXPECT_LT(upper_bound_ms, 150); 400 EXPECT_LT(upper_bound_ms, 150);
399 EXPECT_GT(upper_bound_ms, true_offset_ms); 401 EXPECT_GT(upper_bound_ms, true_offset_ms);
400 } 402 }
401 403
402 } // namespace cast 404 } // namespace cast
403 } // namespace media 405 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/logging/receiver_time_offset_estimator_impl.cc ('k') | media/cast/logging/simple_event_subscriber_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698