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

Side by Side Diff: net/base/network_quality_estimator_unittest.cc

Issue 1158923005: Use the exact-width integer types defined in <stdint.h> rather than (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak comments. Exclude mime_sniffer*. Rebase. Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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 "net/base/network_quality_estimator.h" 5 #include "net/base/network_quality_estimator.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 22 matching lines...) Expand all
33 NetworkQualityEstimator estimator(true); 33 NetworkQualityEstimator estimator(true);
34 { 34 {
35 NetworkQuality network_quality = estimator.GetEstimate(); 35 NetworkQuality network_quality = estimator.GetEstimate();
36 EXPECT_EQ(network_quality.fastest_rtt_confidence, 0); 36 EXPECT_EQ(network_quality.fastest_rtt_confidence, 0);
37 EXPECT_EQ(network_quality.peak_throughput_kbps_confidence, 0); 37 EXPECT_EQ(network_quality.peak_throughput_kbps_confidence, 0);
38 } 38 }
39 39
40 TestDelegate d; 40 TestDelegate d;
41 TestURLRequestContext context(false); 41 TestURLRequestContext context(false);
42 42
43 uint64 min_transfer_size_in_bytes = 43 uint64_t min_transfer_size_in_bytes =
44 NetworkQualityEstimator::kMinTransferSizeInBytes; 44 NetworkQualityEstimator::kMinTransferSizeInBytes;
45 base::TimeDelta request_duration = base::TimeDelta::FromMicroseconds( 45 base::TimeDelta request_duration = base::TimeDelta::FromMicroseconds(
46 NetworkQualityEstimator::kMinRequestDurationMicroseconds); 46 NetworkQualityEstimator::kMinRequestDurationMicroseconds);
47 47
48 scoped_ptr<URLRequest> request(context.CreateRequest( 48 scoped_ptr<URLRequest> request(context.CreateRequest(
49 test_server_.GetURL("echo.html"), DEFAULT_PRIORITY, &d)); 49 test_server_.GetURL("echo.html"), DEFAULT_PRIORITY, &d));
50 request->Start(); 50 request->Start();
51 51
52 base::RunLoop().Run(); 52 base::RunLoop().Run();
53 53
(...skipping 10 matching lines...) Expand all
64 } 64 }
65 65
66 // With large transfer, both |fastest_rtt| and |peak_throughput_kbps| will be 66 // With large transfer, both |fastest_rtt| and |peak_throughput_kbps| will be
67 // updated. 67 // updated.
68 estimator.NotifyDataReceived(*(request.get()), min_transfer_size_in_bytes); 68 estimator.NotifyDataReceived(*(request.get()), min_transfer_size_in_bytes);
69 { 69 {
70 NetworkQuality network_quality = estimator.GetEstimate(); 70 NetworkQuality network_quality = estimator.GetEstimate();
71 EXPECT_GT(network_quality.fastest_rtt_confidence, 0); 71 EXPECT_GT(network_quality.fastest_rtt_confidence, 0);
72 EXPECT_GT(network_quality.peak_throughput_kbps_confidence, 0); 72 EXPECT_GT(network_quality.peak_throughput_kbps_confidence, 0);
73 EXPECT_GE(network_quality.fastest_rtt, request_duration); 73 EXPECT_GE(network_quality.fastest_rtt, request_duration);
74 EXPECT_GT(network_quality.peak_throughput_kbps, uint32(0)); 74 EXPECT_GT(network_quality.peak_throughput_kbps, uint32_t(0));
75 EXPECT_LE( 75 EXPECT_LE(
76 network_quality.peak_throughput_kbps, 76 network_quality.peak_throughput_kbps,
77 min_transfer_size_in_bytes * 8.0 / request_duration.InMilliseconds()); 77 min_transfer_size_in_bytes * 8.0 / request_duration.InMilliseconds());
78 } 78 }
79 EXPECT_EQ(estimator.bytes_read_since_last_connection_change_, true); 79 EXPECT_EQ(estimator.bytes_read_since_last_connection_change_, true);
80 80
81 // Check UMA histograms. 81 // Check UMA histograms.
82 base::HistogramTester histogram_tester; 82 base::HistogramTester histogram_tester;
83 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 0); 83 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 0);
84 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 0); 84 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 0);
85 85
86 estimator.OnConnectionTypeChanged( 86 estimator.OnConnectionTypeChanged(
87 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI); 87 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI);
88 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1); 88 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1);
89 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1); 89 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1);
90 { 90 {
91 NetworkQuality network_quality = estimator.GetEstimate(); 91 NetworkQuality network_quality = estimator.GetEstimate();
92 EXPECT_EQ(estimator.current_connection_type_, 92 EXPECT_EQ(estimator.current_connection_type_,
93 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI); 93 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI);
94 EXPECT_EQ(network_quality.fastest_rtt_confidence, 0); 94 EXPECT_EQ(network_quality.fastest_rtt_confidence, 0);
95 EXPECT_EQ(network_quality.peak_throughput_kbps_confidence, 0); 95 EXPECT_EQ(network_quality.peak_throughput_kbps_confidence, 0);
96 } 96 }
97 } 97 }
98 #endif // !defined(OS_IOS) 98 #endif // !defined(OS_IOS)
99 99
100 } // namespace net 100 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698