OLD | NEW |
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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 28 matching lines...) Expand all Loading... |
39 TestNetworkQualityEstimator( | 39 TestNetworkQualityEstimator( |
40 const std::map<std::string, std::string>& variation_params, | 40 const std::map<std::string, std::string>& variation_params, |
41 scoped_ptr<net::ExternalEstimateProvider> external_estimate_provider) | 41 scoped_ptr<net::ExternalEstimateProvider> external_estimate_provider) |
42 : NetworkQualityEstimator(external_estimate_provider.Pass(), | 42 : NetworkQualityEstimator(external_estimate_provider.Pass(), |
43 variation_params, | 43 variation_params, |
44 true, | 44 true, |
45 true) { | 45 true) { |
46 // Set up embedded test server. | 46 // Set up embedded test server. |
47 embedded_test_server_.ServeFilesFromDirectory( | 47 embedded_test_server_.ServeFilesFromDirectory( |
48 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); | 48 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); |
49 EXPECT_TRUE(embedded_test_server_.InitializeAndWaitUntilReady()); | 49 EXPECT_TRUE(embedded_test_server_.Start()); |
50 embedded_test_server_.RegisterRequestHandler(base::Bind( | 50 embedded_test_server_.RegisterRequestHandler(base::Bind( |
51 &TestNetworkQualityEstimator::HandleRequest, base::Unretained(this))); | 51 &TestNetworkQualityEstimator::HandleRequest, base::Unretained(this))); |
52 } | 52 } |
53 | 53 |
54 explicit TestNetworkQualityEstimator( | 54 explicit TestNetworkQualityEstimator( |
55 const std::map<std::string, std::string>& variation_params) | 55 const std::map<std::string, std::string>& variation_params) |
56 : TestNetworkQualityEstimator( | 56 : TestNetworkQualityEstimator( |
57 variation_params, | 57 variation_params, |
58 scoped_ptr<net::ExternalEstimateProvider>()) {} | 58 scoped_ptr<net::ExternalEstimateProvider>()) {} |
59 | 59 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // id (instead of invoking platform APIs). | 92 // id (instead of invoking platform APIs). |
93 NetworkQualityEstimator::NetworkID GetCurrentNetworkID() const override { | 93 NetworkQualityEstimator::NetworkID GetCurrentNetworkID() const override { |
94 return NetworkQualityEstimator::NetworkID(current_network_type_, | 94 return NetworkQualityEstimator::NetworkID(current_network_type_, |
95 current_network_id_); | 95 current_network_id_); |
96 } | 96 } |
97 | 97 |
98 net::NetworkChangeNotifier::ConnectionType current_network_type_; | 98 net::NetworkChangeNotifier::ConnectionType current_network_type_; |
99 std::string current_network_id_; | 99 std::string current_network_id_; |
100 | 100 |
101 // Embedded server used for testing. | 101 // Embedded server used for testing. |
102 net::test_server::EmbeddedTestServer embedded_test_server_; | 102 net::EmbeddedTestServer embedded_test_server_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(TestNetworkQualityEstimator); | 104 DISALLOW_COPY_AND_ASSIGN(TestNetworkQualityEstimator); |
105 }; | 105 }; |
106 | 106 |
107 class TestRTTObserver : public net::NetworkQualityEstimator::RTTObserver { | 107 class TestRTTObserver : public net::NetworkQualityEstimator::RTTObserver { |
108 public: | 108 public: |
109 struct Observation { | 109 struct Observation { |
110 Observation(int32_t ms, | 110 Observation(int32_t ms, |
111 const base::TimeTicks& ts, | 111 const base::TimeTicks& ts, |
112 net::NetworkQualityEstimator::ObservationSource src) | 112 net::NetworkQualityEstimator::ObservationSource src) |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 EXPECT_EQ(NetworkQualityEstimator::URL_REQUEST, observation.source); | 1054 EXPECT_EQ(NetworkQualityEstimator::URL_REQUEST, observation.source); |
1055 } | 1055 } |
1056 for (auto observation : throughput_observer.observations()) { | 1056 for (auto observation : throughput_observer.observations()) { |
1057 EXPECT_LE(0, observation.throughput_kbps); | 1057 EXPECT_LE(0, observation.throughput_kbps); |
1058 EXPECT_LE(0, (observation.timestamp - then).InMilliseconds()); | 1058 EXPECT_LE(0, (observation.timestamp - then).InMilliseconds()); |
1059 EXPECT_EQ(NetworkQualityEstimator::URL_REQUEST, observation.source); | 1059 EXPECT_EQ(NetworkQualityEstimator::URL_REQUEST, observation.source); |
1060 } | 1060 } |
1061 } | 1061 } |
1062 | 1062 |
1063 } // namespace net | 1063 } // namespace net |
OLD | NEW |