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

Unified Diff: content/browser/download/download_stats_unittest.cc

Issue 2885793004: Parallelizable download metrics. (Closed)
Patch Set: Some change according to meeting. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/download/download_stats.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..290cd81a8fcf55feea9a1f0d8024e96a4c806997
--- /dev/null
+++ b/content/browser/download/download_stats_unittest.cc
@@ -0,0 +1,39 @@
+// 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) {
+ 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 content
« no previous file with comments | « content/browser/download/download_stats.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698