blob: 555bb2486a6b828b07e20531ccb5b4beb4c536d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright 2018 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 "components/download/public/common/download_stats.h"
#include "base/test/histogram_tester.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace download {
namespace {
void VerfiyParallelizableAverageStats(int64_t bytes_downloaded,
const base::TimeDelta& time_span) {
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);
}
} // namespace
TEST(DownloadStatsTest, ParallelizableAverageStats) {
VerfiyParallelizableAverageStats(1, base::TimeDelta::FromSeconds(1));
VerfiyParallelizableAverageStats(1024 * 1024 * 20,
base::TimeDelta::FromSeconds(10));
VerfiyParallelizableAverageStats(1024 * 1024 * 1024,
base::TimeDelta::FromSeconds(1));
}
} // namespace download
|