OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/capture/content/smooth_event_sampler.h" | 5 #include "media/capture/content/smooth_event_sampler.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 bool should_capture; | 361 bool should_capture; |
362 double increment_ms; | 362 double increment_ms; |
363 }; | 363 }; |
364 | 364 |
365 void ReplayCheckingSamplerDecisions(const DataPoint* data_points, | 365 void ReplayCheckingSamplerDecisions(const DataPoint* data_points, |
366 size_t num_data_points, | 366 size_t num_data_points, |
367 SmoothEventSampler* sampler) { | 367 SmoothEventSampler* sampler) { |
368 base::TimeTicks t = InitialTestTimeTicks(); | 368 base::TimeTicks t = InitialTestTimeTicks(); |
369 for (size_t i = 0; i < num_data_points; ++i) { | 369 for (size_t i = 0; i < num_data_points; ++i) { |
370 t += base::TimeDelta::FromMicroseconds( | 370 t += base::TimeDelta::FromMicroseconds( |
371 static_cast<int64>(data_points[i].increment_ms * 1000)); | 371 static_cast<int64_t>(data_points[i].increment_ms * 1000)); |
372 ASSERT_EQ(data_points[i].should_capture, | 372 ASSERT_EQ(data_points[i].should_capture, |
373 AddEventAndConsiderSampling(sampler, t)) | 373 AddEventAndConsiderSampling(sampler, t)) |
374 << "at data_points[" << i << ']'; | 374 << "at data_points[" << i << ']'; |
375 if (data_points[i].should_capture) | 375 if (data_points[i].should_capture) |
376 sampler->RecordSample(); | 376 sampler->RecordSample(); |
377 } | 377 } |
378 } | 378 } |
379 | 379 |
380 } // namespace | 380 } // namespace |
381 | 381 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 {true, 33.441}, | 695 {true, 33.441}, |
696 {false, 16.72}, | 696 {false, 16.72}, |
697 {true, 16.72}, | 697 {true, 16.72}, |
698 {true, 50.16}}; | 698 {true, 50.16}}; |
699 | 699 |
700 SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, 3); | 700 SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30, 3); |
701 ReplayCheckingSamplerDecisions(data_points, arraysize(data_points), &sampler); | 701 ReplayCheckingSamplerDecisions(data_points, arraysize(data_points), &sampler); |
702 } | 702 } |
703 | 703 |
704 } // namespace media | 704 } // namespace media |
OLD | NEW |