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

Side by Side Diff: webrtc/video/stats_counter_unittest.cc

Issue 2307913002: Update AvgCounter to have the ability to include last period metric for subsequent intervals withou… (Closed)
Patch Set: address comments 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
« webrtc/call/call.cc ('K') | « webrtc/video/stats_counter.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 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 EXPECT_EQ(0, stats.num_samples); 51 EXPECT_EQ(0, stats.num_samples);
52 EXPECT_EQ(-1, stats.min); 52 EXPECT_EQ(-1, stats.min);
53 EXPECT_EQ(-1, stats.max); 53 EXPECT_EQ(-1, stats.max);
54 EXPECT_EQ(-1, stats.average); 54 EXPECT_EQ(-1, stats.average);
55 } 55 }
56 56
57 SimulatedClock clock_; 57 SimulatedClock clock_;
58 }; 58 };
59 59
60 TEST_F(StatsCounterTest, NoSamples) { 60 TEST_F(StatsCounterTest, NoSamples) {
61 AvgCounter counter(&clock_, nullptr); 61 AvgCounter counter(&clock_, nullptr, false);
62 VerifyStatsIsNotSet(counter.GetStats()); 62 VerifyStatsIsNotSet(counter.GetStats());
63 } 63 }
64 64
65 TEST_F(StatsCounterTest, TestRegisterObserver) { 65 TEST_F(StatsCounterTest, TestRegisterObserver) {
66 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl(); 66 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl();
67 const int kSample = 22; 67 const int kSample = 22;
68 AvgCounter counter(&clock_, observer); 68 AvgCounter counter(&clock_, observer, false);
69 AddSampleAndAdvance(kSample, kProcessIntervalMs, &counter); 69 AddSampleAndAdvance(kSample, kProcessIntervalMs, &counter);
70 // Trigger process (sample included in next interval). 70 // Trigger process (sample included in next interval).
71 counter.Add(111); 71 counter.Add(111);
72 EXPECT_EQ(1, observer->num_calls_); 72 EXPECT_EQ(1, observer->num_calls_);
73 } 73 }
74 74
75 TEST_F(StatsCounterTest, HasSample) { 75 TEST_F(StatsCounterTest, HasSample) {
76 AvgCounter counter(&clock_, nullptr); 76 AvgCounter counter(&clock_, nullptr, false);
77 EXPECT_FALSE(counter.HasSample()); 77 EXPECT_FALSE(counter.HasSample());
78 counter.Add(1); 78 counter.Add(1);
79 EXPECT_TRUE(counter.HasSample()); 79 EXPECT_TRUE(counter.HasSample());
80 } 80 }
81 81
82 TEST_F(StatsCounterTest, VerifyProcessInterval) { 82 TEST_F(StatsCounterTest, VerifyProcessInterval) {
83 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl(); 83 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl();
84 AvgCounter counter(&clock_, observer); 84 AvgCounter counter(&clock_, observer, false);
85 counter.Add(4); 85 counter.Add(4);
86 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs - 1); 86 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs - 1);
87 // Try trigger process (interval has not passed). 87 // Try trigger process (interval has not passed).
88 counter.Add(8); 88 counter.Add(8);
89 EXPECT_EQ(0, observer->num_calls_); 89 EXPECT_EQ(0, observer->num_calls_);
90 VerifyStatsIsNotSet(counter.GetStats()); 90 VerifyStatsIsNotSet(counter.GetStats());
91 // Make process interval pass. 91 // Make process interval pass.
92 clock_.AdvanceTimeMilliseconds(1); 92 clock_.AdvanceTimeMilliseconds(1);
93 // Trigger process (sample included in next interval). 93 // Trigger process (sample included in next interval).
94 counter.Add(111); 94 counter.Add(111);
95 EXPECT_EQ(1, observer->num_calls_); 95 EXPECT_EQ(1, observer->num_calls_);
96 EXPECT_EQ(6, observer->last_sample_); 96 EXPECT_EQ(6, observer->last_sample_);
97 // Aggregated stats. 97 // Aggregated stats.
98 AggregatedStats stats = counter.GetStats(); 98 AggregatedStats stats = counter.GetStats();
99 EXPECT_EQ(1, stats.num_samples); 99 EXPECT_EQ(1, stats.num_samples);
100 } 100 }
101 101
102 TEST_F(StatsCounterTest, TestMetric_AvgCounter) { 102 TEST_F(StatsCounterTest, TestMetric_AvgCounter) {
103 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl(); 103 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl();
104 AvgCounter counter(&clock_, observer); 104 AvgCounter counter(&clock_, observer, false);
105 counter.Add(4); 105 counter.Add(4);
106 counter.Add(8); 106 counter.Add(8);
107 counter.Add(9); 107 counter.Add(9);
108 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs); 108 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs);
109 // Trigger process (sample included in next interval). 109 // Trigger process (sample included in next interval).
110 counter.Add(111); 110 counter.Add(111);
111 // Average per interval. 111 // Average per interval.
112 EXPECT_EQ(1, observer->num_calls_); 112 EXPECT_EQ(1, observer->num_calls_);
113 EXPECT_EQ(7, observer->last_sample_); 113 EXPECT_EQ(7, observer->last_sample_);
114 // Aggregated stats. 114 // Aggregated stats.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 EXPECT_EQ(1, observer->num_calls_); 206 EXPECT_EQ(1, observer->num_calls_);
207 EXPECT_EQ(94, observer->last_sample_); 207 EXPECT_EQ(94, observer->last_sample_);
208 // Aggregated stats. 208 // Aggregated stats.
209 AggregatedStats stats = counter.GetStats(); 209 AggregatedStats stats = counter.GetStats();
210 EXPECT_EQ(1, stats.num_samples); 210 EXPECT_EQ(1, stats.num_samples);
211 EXPECT_EQ(94, stats.min); 211 EXPECT_EQ(94, stats.min);
212 EXPECT_EQ(94, stats.max); 212 EXPECT_EQ(94, stats.max);
213 } 213 }
214 214
215 TEST_F(StatsCounterTest, TestGetStats_MultipleIntervals) { 215 TEST_F(StatsCounterTest, TestGetStats_MultipleIntervals) {
216 AvgCounter counter(&clock_, nullptr); 216 AvgCounter counter(&clock_, nullptr, false);
217 const int kSample1 = 1; 217 const int kSample1 = 1;
218 const int kSample2 = 5; 218 const int kSample2 = 5;
219 const int kSample3 = 8; 219 const int kSample3 = 8;
220 const int kSample4 = 11; 220 const int kSample4 = 11;
221 const int kSample5 = 50; 221 const int kSample5 = 50;
222 AddSampleAndAdvance(kSample1, kProcessIntervalMs, &counter); 222 AddSampleAndAdvance(kSample1, kProcessIntervalMs, &counter);
223 AddSampleAndAdvance(kSample2, kProcessIntervalMs, &counter); 223 AddSampleAndAdvance(kSample2, kProcessIntervalMs, &counter);
224 AddSampleAndAdvance(kSample3, kProcessIntervalMs, &counter); 224 AddSampleAndAdvance(kSample3, kProcessIntervalMs, &counter);
225 AddSampleAndAdvance(kSample4, kProcessIntervalMs, &counter); 225 AddSampleAndAdvance(kSample4, kProcessIntervalMs, &counter);
226 AddSampleAndAdvance(kSample5, kProcessIntervalMs, &counter); 226 AddSampleAndAdvance(kSample5, kProcessIntervalMs, &counter);
227 // Trigger process (sample included in next interval). 227 // Trigger process (sample included in next interval).
228 counter.Add(111); 228 counter.Add(111);
229 AggregatedStats stats = counter.GetStats(); 229 AggregatedStats stats = counter.GetStats();
230 EXPECT_EQ(5, stats.num_samples); 230 EXPECT_EQ(5, stats.num_samples);
231 EXPECT_EQ(kSample1, stats.min); 231 EXPECT_EQ(kSample1, stats.min);
232 EXPECT_EQ(kSample5, stats.max); 232 EXPECT_EQ(kSample5, stats.max);
233 EXPECT_EQ(15, stats.average); 233 EXPECT_EQ(15, stats.average);
234 } 234 }
235 235
236 TEST_F(StatsCounterTest, TestGetStatsTwice) { 236 TEST_F(StatsCounterTest, TestGetStatsTwice) {
237 const int kSample1 = 4; 237 const int kSample1 = 4;
238 const int kSample2 = 7; 238 const int kSample2 = 7;
239 AvgCounter counter(&clock_, nullptr); 239 AvgCounter counter(&clock_, nullptr, false);
240 AddSampleAndAdvance(kSample1, kProcessIntervalMs, &counter); 240 AddSampleAndAdvance(kSample1, kProcessIntervalMs, &counter);
241 // Trigger process (sample included in next interval). 241 // Trigger process (sample included in next interval).
242 counter.Add(kSample2); 242 counter.Add(kSample2);
243 AggregatedStats stats = counter.GetStats(); 243 AggregatedStats stats = counter.GetStats();
244 EXPECT_EQ(1, stats.num_samples); 244 EXPECT_EQ(1, stats.num_samples);
245 EXPECT_EQ(kSample1, stats.min); 245 EXPECT_EQ(kSample1, stats.min);
246 EXPECT_EQ(kSample1, stats.max); 246 EXPECT_EQ(kSample1, stats.max);
247 // Trigger process (sample included in next interval). 247 // Trigger process (sample included in next interval).
248 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs); 248 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs);
249 counter.Add(111); 249 counter.Add(111);
(...skipping 20 matching lines...) Expand all
270 EXPECT_EQ(2, observer->num_calls_); 270 EXPECT_EQ(2, observer->num_calls_);
271 EXPECT_EQ(300, observer->last_sample_); 271 EXPECT_EQ(300, observer->last_sample_);
272 // Aggregated stats. 272 // Aggregated stats.
273 AggregatedStats stats = counter.GetStats(); 273 AggregatedStats stats = counter.GetStats();
274 EXPECT_EQ(2, stats.num_samples); 274 EXPECT_EQ(2, stats.num_samples);
275 EXPECT_EQ(100, stats.min); 275 EXPECT_EQ(100, stats.min);
276 EXPECT_EQ(300, stats.max); 276 EXPECT_EQ(300, stats.max);
277 EXPECT_EQ(200, stats.average); 277 EXPECT_EQ(200, stats.average);
278 } 278 }
279 279
280 TEST_F(StatsCounterTest, TestAvgCounter_IntervalsWithoutSamplesIgnored) { 280 TEST_F(StatsCounterTest, TestAvgCounter_IntervalsWithoutSamplesIncluded) {
281 // Samples: | 6 | x | x | 8 | // x: empty interval
282 // Stats: | 6 | 6 | 6 | 8 | // x -> last value reported
281 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl(); 283 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl();
282 AvgCounter counter(&clock_, observer); 284 AvgCounter counter(&clock_, observer, true);
283 AddSampleAndAdvance(6, kProcessIntervalMs * 4 - 1, &counter); 285 AddSampleAndAdvance(6, kProcessIntervalMs * 4 - 1, &counter);
284 // Trigger process (sample included in next interval). 286 // Trigger process (sample included in next interval).
285 counter.Add(8); 287 counter.Add(8);
286 // [6:1], two intervals without samples passed. 288 // [6:3], 3 intervals passed (2 without samples -> last value reported).
287 EXPECT_EQ(1, observer->num_calls_); 289 AggregatedStats stats = counter.ProcessAndGetStats();
290 EXPECT_EQ(3, stats.num_samples);
291 EXPECT_EQ(6, stats.min);
292 EXPECT_EQ(6, stats.max);
293 // Make next interval pass and verify stats: [6:3],[8:1]
294 clock_.AdvanceTimeMilliseconds(1);
295 counter.ProcessAndGetStats();
296 EXPECT_EQ(4, observer->num_calls_);
297 EXPECT_EQ(8, observer->last_sample_);
298 }
299
300 TEST_F(StatsCounterTest, TestAvgCounter_WithPause) {
301 // Samples: | 6 | x | x | x | - | 22 | x | // x: empty interval, -: paused
302 // Stats: | 6 | 6 | 6 | 6 | - | 22 | 22 | // x -> last value reported
303 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl();
304 AvgCounter counter(&clock_, observer, true);
305 // Add sample and advance 3 intervals (2 w/o samples -> last value reported).
306 AddSampleAndAdvance(6, kProcessIntervalMs * 4 - 1, &counter);
307 // Trigger process and verify stats: [6:3]
308 counter.ProcessAndGetStats();
309 EXPECT_EQ(3, observer->num_calls_);
288 EXPECT_EQ(6, observer->last_sample_); 310 EXPECT_EQ(6, observer->last_sample_);
289 // Make last interval pass. 311 // Make next interval pass (1 without samples).
312 // Process and pause. Verify stats: [6:4].
290 clock_.AdvanceTimeMilliseconds(1); 313 clock_.AdvanceTimeMilliseconds(1);
291 counter.Add(111); // Trigger process (sample included in next interval). 314 counter.ProcessAndPause();
292 // [6:1],[8:1] 315 EXPECT_EQ(4, observer->num_calls_); // Last value reported.
293 EXPECT_EQ(2, observer->num_calls_); 316 EXPECT_EQ(6, observer->last_sample_);
294 EXPECT_EQ(8, observer->last_sample_); 317 // Make next interval pass (1 without samples -> ignored while paused).
295 // Aggregated stats. 318 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs * 2 - 1);
296 AggregatedStats stats = counter.GetStats(); 319 counter.Add(22); // Stops pause.
297 EXPECT_EQ(2, stats.num_samples); 320 EXPECT_EQ(4, observer->num_calls_);
298 EXPECT_EQ(6, stats.min); 321 EXPECT_EQ(6, observer->last_sample_);
299 EXPECT_EQ(8, stats.max); 322 // Make next interval pass, [6:4][22:1]
323 clock_.AdvanceTimeMilliseconds(1);
324 counter.ProcessAndGetStats();
325 EXPECT_EQ(5, observer->num_calls_);
326 EXPECT_EQ(22, observer->last_sample_);
327 // Make 1 interval pass (1 w/o samples -> pause stopped, last value reported).
328 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs);
329 counter.ProcessAndGetStats();
330 EXPECT_EQ(6, observer->num_calls_);
331 EXPECT_EQ(22, observer->last_sample_);
300 } 332 }
301 333
302 TEST_F(StatsCounterTest, TestRateCounter_IntervalsWithoutSamplesIgnored) { 334 TEST_F(StatsCounterTest, TestRateCounter_IntervalsWithoutSamplesIgnored) {
335 // Samples: | 50 | x | 20 | // x: empty interval
336 // Stats: | 25 | x | 10 | // x -> ignored
303 const bool kIncludeEmptyIntervals = false; 337 const bool kIncludeEmptyIntervals = false;
304 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl(); 338 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl();
305 const int kSample1 = 50; // 50 / 2 sec 339 const int kSample1 = 50; // 50 / 2 sec
306 const int kSample2 = 20; // 20 / 2 sec 340 const int kSample2 = 20; // 20 / 2 sec
307 RateCounter counter(&clock_, observer, kIncludeEmptyIntervals); 341 RateCounter counter(&clock_, observer, kIncludeEmptyIntervals);
308 counter.Add(kSample1); 342 counter.Add(kSample1);
309 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs * 3 - 1); 343 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs * 3 - 1);
310 // Trigger process (sample included in next interval). 344 // Trigger process (sample included in next interval).
311 counter.Add(kSample2); 345 counter.Add(kSample2);
312 // [25:1], one interval without samples passed. 346 // [25:1], 2 intervals passed (1 without samples -> ignored).
313 EXPECT_EQ(1, observer->num_calls_); 347 EXPECT_EQ(1, observer->num_calls_);
314 EXPECT_EQ(25, observer->last_sample_); 348 EXPECT_EQ(25, observer->last_sample_);
315 // Make last interval pass. 349 // Make next interval pass and verify stats: [10:1],[25:1]
316 clock_.AdvanceTimeMilliseconds(1); 350 clock_.AdvanceTimeMilliseconds(1);
317 counter.Add(111); // Trigger process (sample included in next interval). 351 counter.ProcessAndGetStats();
318 // [10:1],[25:1]
319 EXPECT_EQ(2, observer->num_calls_); 352 EXPECT_EQ(2, observer->num_calls_);
320 EXPECT_EQ(10, observer->last_sample_); 353 EXPECT_EQ(10, observer->last_sample_);
321 // Aggregated stats.
322 AggregatedStats stats = counter.GetStats();
323 EXPECT_EQ(2, stats.num_samples);
324 EXPECT_EQ(10, stats.min);
325 EXPECT_EQ(25, stats.max);
326 } 354 }
327 355
328 TEST_F(StatsCounterTest, TestRateCounter_IntervalsWithoutSamplesIncluded) { 356 TEST_F(StatsCounterTest, TestRateCounter_IntervalsWithoutSamplesIncluded) {
357 // Samples: | 50 | x | 20 | // x: empty interval
358 // Stats: | 25 | 0 | 10 | // x -> zero reported
329 const bool kIncludeEmptyIntervals = true; 359 const bool kIncludeEmptyIntervals = true;
330 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl(); 360 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl();
331 const int kSample1 = 50; // 50 / 2 sec 361 const int kSample1 = 50; // 50 / 2 sec
332 const int kSample2 = 20; // 20 / 2 sec 362 const int kSample2 = 20; // 20 / 2 sec
333 RateCounter counter(&clock_, observer, kIncludeEmptyIntervals); 363 RateCounter counter(&clock_, observer, kIncludeEmptyIntervals);
334 counter.Add(kSample1); 364 counter.Add(kSample1);
335 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs * 3 - 1); 365 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs * 3 - 1);
336 // Trigger process (sample included in next interval). 366 // Trigger process (sample included in next interval).
337 counter.Add(kSample2); 367 counter.Add(kSample2);
338 // [0:1],[25:1], one interval without samples passed. 368 // [0:1],[25:1], 2 intervals passed (1 without samples -> zero reported).
339 EXPECT_EQ(2, observer->num_calls_); 369 EXPECT_EQ(2, observer->num_calls_);
340 EXPECT_EQ(25, observer->last_sample_); 370 EXPECT_EQ(0, observer->last_sample_);
341 // Make last interval pass. 371 // Make last interval pass and verify stats: [0:1],[10:1],[25:1]
342 clock_.AdvanceTimeMilliseconds(1); 372 clock_.AdvanceTimeMilliseconds(1);
343 counter.Add(111); // Trigger process (sample included in next interval). 373 AggregatedStats stats = counter.ProcessAndGetStats();
344 // [0:1],[10:1],[25:1] 374 EXPECT_EQ(25, stats.max);
345 EXPECT_EQ(3, observer->num_calls_); 375 EXPECT_EQ(3, observer->num_calls_);
346 EXPECT_EQ(10, observer->last_sample_); 376 EXPECT_EQ(10, observer->last_sample_);
347 // Aggregated stats. 377 }
348 AggregatedStats stats = counter.GetStats(); 378
349 EXPECT_EQ(3, stats.num_samples); 379 TEST_F(StatsCounterTest, TestRateAccCounter_IntervalsWithoutSamplesIncluded) {
350 EXPECT_EQ(0, stats.min); 380 // Samples: | 12 | x | x | x | 60 | // x: empty interval
351 EXPECT_EQ(25, stats.max); 381 // Stats: | 6 | 0 | 0 | 0 | 24 | // x -> zero reported
382 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl();
383 RateAccCounter counter(&clock_, observer, true);
384 VerifyStatsIsNotSet(counter.ProcessAndGetStats());
385 // Advance one interval and verify stats.
386 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs);
387 VerifyStatsIsNotSet(counter.ProcessAndGetStats());
388 // Add sample and advance 3 intervals (2 w/o samples -> zero reported).
389 counter.Set(12);
390 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs * 4 - 1);
391 // Trigger process and verify stats: [0:2][6:1]
392 counter.ProcessAndGetStats();
393 EXPECT_EQ(3, observer->num_calls_);
394 EXPECT_EQ(0, observer->last_sample_);
395 // Make next interval pass (1 w/o samples -> zero reported), [0:3][6:1]
396 clock_.AdvanceTimeMilliseconds(1);
397 counter.ProcessAndGetStats();
398 EXPECT_EQ(4, observer->num_calls_);
399 EXPECT_EQ(0, observer->last_sample_);
400 // Insert sample and advance non-complete interval, no change, [0:3][6:1]
401 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs - 1);
402 counter.Set(60);
403 EXPECT_EQ(4, observer->num_calls_);
404 // Make next interval pass, [0:3][6:1][24:1]
405 clock_.AdvanceTimeMilliseconds(1);
406 AggregatedStats stats = counter.ProcessAndGetStats();
407 EXPECT_EQ(5, observer->num_calls_);
408 EXPECT_EQ(24, observer->last_sample_);
409 EXPECT_EQ(6, stats.average);
410 }
411
412 TEST_F(StatsCounterTest, TestRateAccCounter_IntervalsWithoutSamplesIgnored) {
413 // Samples: | 12 | x | x | x | 60 | // x: empty interval
414 // Stats: | 6 | x | x | x | 24 | // x -> ignored
415 StatsCounterObserverImpl* observer = new StatsCounterObserverImpl();
416 RateAccCounter counter(&clock_, observer, false);
417 // Add sample and advance 3 intervals (2 w/o samples -> ignored).
418 counter.Set(12);
419 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs * 4 - 1);
420 // Trigger process and verify stats: [6:1]
421 counter.ProcessAndGetStats();
422 EXPECT_EQ(1, observer->num_calls_);
423 EXPECT_EQ(6, observer->last_sample_);
424 // Make next interval pass (1 w/o samples -> ignored), [6:1]
425 clock_.AdvanceTimeMilliseconds(1);
426 counter.ProcessAndGetStats();
427 EXPECT_EQ(1, observer->num_calls_);
428 // Insert sample and advance non-complete interval, no change, [6:1]
429 clock_.AdvanceTimeMilliseconds(kProcessIntervalMs - 1);
430 counter.Set(60);
431 counter.ProcessAndGetStats();
432 EXPECT_EQ(1, observer->num_calls_);
433 // Make next interval pass, [6:1][24:1]
434 clock_.AdvanceTimeMilliseconds(1);
435 counter.ProcessAndGetStats();
436 EXPECT_EQ(2, observer->num_calls_);
437 EXPECT_EQ(24, observer->last_sample_);
352 } 438 }
353 439
354 } // namespace webrtc 440 } // namespace webrtc
OLDNEW
« webrtc/call/call.cc ('K') | « webrtc/video/stats_counter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698