OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/test/histogram_tester.h" | 12 #include "base/test/histogram_tester.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/io_thread.h" | 14 #include "chrome/browser/io_thread.h" |
15 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h" | 15 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h" |
16 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_factory.h" | 16 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_factory.h" |
17 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_test_util.
h" | 17 #include "chrome/browser/net/nqe/ui_network_quality_estimator_service_test_util.
h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "components/variations/variations_associated_data.h" | 20 #include "components/variations/variations_associated_data.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/test/browser_test.h" | 22 #include "content/public/test/browser_test.h" |
23 #include "net/base/network_change_notifier.h" | 23 #include "net/base/network_change_notifier.h" |
24 #include "net/nqe/cached_network_quality.h" | 24 #include "net/nqe/cached_network_quality.h" |
25 #include "net/nqe/effective_connection_type.h" | 25 #include "net/nqe/effective_connection_type.h" |
| 26 #include "net/nqe/effective_connection_type_observer.h" |
26 #include "net/nqe/network_id.h" | 27 #include "net/nqe/network_id.h" |
27 #include "net/nqe/network_quality_estimator.h" | 28 #include "net/nqe/network_quality_estimator.h" |
| 29 #include "net/nqe/rtt_throughput_estimates_observer.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
29 | 31 |
30 class Profile; | 32 class Profile; |
31 | 33 |
32 namespace { | 34 namespace { |
33 | 35 |
34 class TestEffectiveConnectionTypeObserver | 36 class TestEffectiveConnectionTypeObserver |
35 : public net::NetworkQualityEstimator::EffectiveConnectionTypeObserver { | 37 : public net::EffectiveConnectionTypeObserver { |
36 public: | 38 public: |
37 TestEffectiveConnectionTypeObserver() | 39 TestEffectiveConnectionTypeObserver() |
38 : effective_connection_type_(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {} | 40 : effective_connection_type_(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {} |
39 ~TestEffectiveConnectionTypeObserver() override {} | 41 ~TestEffectiveConnectionTypeObserver() override {} |
40 | 42 |
41 // net::NetworkQualityEstimator::EffectiveConnectionTypeObserver | 43 // net::EffectiveConnectionTypeObserver implementation: |
42 // implementation: | |
43 void OnEffectiveConnectionTypeChanged( | 44 void OnEffectiveConnectionTypeChanged( |
44 net::EffectiveConnectionType type) override { | 45 net::EffectiveConnectionType type) override { |
45 effective_connection_type_ = type; | 46 effective_connection_type_ = type; |
46 } | 47 } |
47 | 48 |
48 // The most recently set EffectiveConnectionType. | 49 // The most recently set EffectiveConnectionType. |
49 net::EffectiveConnectionType effective_connection_type() const { | 50 net::EffectiveConnectionType effective_connection_type() const { |
50 return effective_connection_type_; | 51 return effective_connection_type_; |
51 } | 52 } |
52 | 53 |
53 private: | 54 private: |
54 net::EffectiveConnectionType effective_connection_type_; | 55 net::EffectiveConnectionType effective_connection_type_; |
55 | 56 |
56 DISALLOW_COPY_AND_ASSIGN(TestEffectiveConnectionTypeObserver); | 57 DISALLOW_COPY_AND_ASSIGN(TestEffectiveConnectionTypeObserver); |
57 }; | 58 }; |
58 | 59 |
59 class TestRTTAndThroughputEstimatesObserver | 60 class TestRTTAndThroughputEstimatesObserver |
60 : public net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver { | 61 : public net::RTTAndThroughputEstimatesObserver { |
61 public: | 62 public: |
62 TestRTTAndThroughputEstimatesObserver() | 63 TestRTTAndThroughputEstimatesObserver() |
63 : http_rtt_(base::TimeDelta::FromMilliseconds(-1)), | 64 : http_rtt_(base::TimeDelta::FromMilliseconds(-1)), |
64 transport_rtt_(base::TimeDelta::FromMilliseconds(-1)), | 65 transport_rtt_(base::TimeDelta::FromMilliseconds(-1)), |
65 downstream_throughput_kbps_(-1) {} | 66 downstream_throughput_kbps_(-1) {} |
66 ~TestRTTAndThroughputEstimatesObserver() override {} | 67 ~TestRTTAndThroughputEstimatesObserver() override {} |
67 | 68 |
68 // net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver | 69 // net::RTTAndThroughputEstimatesObserver implementation: |
69 // implementation: | |
70 void OnRTTOrThroughputEstimatesComputed( | 70 void OnRTTOrThroughputEstimatesComputed( |
71 base::TimeDelta http_rtt, | 71 base::TimeDelta http_rtt, |
72 base::TimeDelta transport_rtt, | 72 base::TimeDelta transport_rtt, |
73 int32_t downstream_throughput_kbps) override { | 73 int32_t downstream_throughput_kbps) override { |
74 http_rtt_ = http_rtt; | 74 http_rtt_ = http_rtt; |
75 transport_rtt_ = transport_rtt; | 75 transport_rtt_ = transport_rtt; |
76 downstream_throughput_kbps_ = downstream_throughput_kbps; | 76 downstream_throughput_kbps_ = downstream_throughput_kbps; |
77 } | 77 } |
78 | 78 |
79 base::TimeDelta http_rtt() const { return http_rtt_; } | 79 base::TimeDelta http_rtt() const { return http_rtt_; } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 nqe_service->RemoveRTTAndThroughputEstimatesObserver(&nqe_observer_3); | 296 nqe_service->RemoveRTTAndThroughputEstimatesObserver(&nqe_observer_3); |
297 base::RunLoop().RunUntilIdle(); | 297 base::RunLoop().RunUntilIdle(); |
298 EXPECT_GT(0, nqe_observer_3.http_rtt().InMilliseconds()); | 298 EXPECT_GT(0, nqe_observer_3.http_rtt().InMilliseconds()); |
299 } | 299 } |
300 | 300 |
301 // Verify that prefs are writen and read correctly. | 301 // Verify that prefs are writen and read correctly. |
302 IN_PROC_BROWSER_TEST_F(UINetworkQualityEstimatorServiceBrowserTest, | 302 IN_PROC_BROWSER_TEST_F(UINetworkQualityEstimatorServiceBrowserTest, |
303 WritingReadingToPrefsEnabled) { | 303 WritingReadingToPrefsEnabled) { |
304 VerifyWritingReadingPrefs(); | 304 VerifyWritingReadingPrefs(); |
305 } | 305 } |
OLD | NEW |