OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/download/download_stats.h" |
| 6 |
| 7 #include "base/test/histogram_tester.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 namespace { |
| 14 |
| 15 void VerfiyParallelizableAverageStats(int64_t bytes_downloaded, |
| 16 const base::TimeDelta& time_span) { |
| 17 base::HistogramTester histogram_tester; |
| 18 int64_t expected_bandwidth = bytes_downloaded / time_span.InSeconds(); |
| 19 |
| 20 RecordParallelizableDownloadAverageStats(bytes_downloaded, time_span); |
| 21 histogram_tester.ExpectBucketCount("Download.ParallelizableDownloadBandwidth", |
| 22 expected_bandwidth, 1); |
| 23 histogram_tester.ExpectBucketCount("Download.Parallelizable.DownloadTime", |
| 24 time_span.InMilliseconds(), 1); |
| 25 histogram_tester.ExpectBucketCount("Download.Parallelizable.FileSize", |
| 26 bytes_downloaded / 1024, 1); |
| 27 } |
| 28 |
| 29 } // namespace |
| 30 |
| 31 TEST(DownloadStatsTest, ParallelizableAverageStats) { |
| 32 VerfiyParallelizableAverageStats(1, base::TimeDelta::FromSeconds(1)); |
| 33 VerfiyParallelizableAverageStats(1024 * 1024 * 20, |
| 34 base::TimeDelta::FromSeconds(10)); |
| 35 VerfiyParallelizableAverageStats(1024 * 1024 * 1024, |
| 36 base::TimeDelta::FromSeconds(1)); |
| 37 } |
| 38 |
| 39 } // namespace content |
OLD | NEW |