| Index: content/browser/download/download_stats_unittest.cc
|
| diff --git a/content/browser/download/download_stats_unittest.cc b/content/browser/download/download_stats_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..042c113db42480e5bd240394ad9917c93f8f3e3e
|
| --- /dev/null
|
| +++ b/content/browser/download/download_stats_unittest.cc
|
| @@ -0,0 +1,48 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/browser/download/download_stats.h"
|
| +
|
| +#include "base/test/histogram_tester.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace content {
|
| +
|
| +namespace {
|
| +
|
| +void VerfiyParallelizableAverageStats(int64_t bytes_downloaded,
|
| + const base::TimeDelta& time_span,
|
| + const std::string& expected_suffix) {
|
| + base::HistogramTester histogram_tester;
|
| + int64_t expected_bandwidth = bytes_downloaded / time_span.InSeconds();
|
| +
|
| + RecordParallelizableDownloadAverageStats(bytes_downloaded, time_span);
|
| + histogram_tester.ExpectBucketCount("Download.ParallelizableDownloadBandwidth",
|
| + expected_bandwidth, 1);
|
| + histogram_tester.ExpectBucketCount("Download.Parallelizable.DownloadTime",
|
| + time_span.InMilliseconds(), 1);
|
| + histogram_tester.ExpectBucketCount("Download.Parallelizable.FileSize",
|
| + bytes_downloaded / 1024, 1);
|
| + histogram_tester.ExpectBucketCount(
|
| + "Download.ParallelizableDownloadBandwidth." + expected_suffix,
|
| + expected_bandwidth, 1);
|
| + histogram_tester.ExpectBucketCount(
|
| + "Download.Parallelizable.DownloadTime." + expected_suffix,
|
| + time_span.InMilliseconds(), 1);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +TEST(DownloadStatsTest, ParallelizableAverageStatsSmall) {
|
| + // Lowest bucket of the file size suffix.
|
| + VerfiyParallelizableAverageStats(1, base::TimeDelta::FromSeconds(1), "0.5MB");
|
| + VerfiyParallelizableAverageStats(1024 * 1024 * 20,
|
| + base::TimeDelta::FromSeconds(10), "50MB");
|
| + // Overflow bucket of the file size suffix.
|
| + VerfiyParallelizableAverageStats(1024 * 1024 * 1024,
|
| + base::TimeDelta::FromSeconds(1), "GT50MB");
|
| +}
|
| +
|
| +} // namespace content
|
|
|