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

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

Issue 2648353003: Add effective connection type to throughput mapping (Closed)
Patch Set: ryansturm comments Created 3 years, 10 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
« no previous file with comments | « net/nqe/network_quality_estimator_params.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/nqe/network_quality_estimator.h" 5 #include "net/nqe/network_quality_estimator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 2692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 histogram_tester.ExpectUniqueSample("NQE.Prefs.ReadSize", read_prefs.size(), 2703 histogram_tester.ExpectUniqueSample("NQE.Prefs.ReadSize", read_prefs.size(),
2704 1); 2704 1);
2705 2705
2706 // Taken from network_quality_estimator_params.cc. 2706 // Taken from network_quality_estimator_params.cc.
2707 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1800), 2707 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1800),
2708 rtt_observer.last_rtt( 2708 rtt_observer.last_rtt(
2709 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE)); 2709 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE));
2710 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500), 2710 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500),
2711 rtt_observer.last_rtt( 2711 rtt_observer.last_rtt(
2712 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE)); 2712 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE));
2713 EXPECT_EQ(0u, throughput_observer.observations().size()); 2713 EXPECT_EQ(1u, throughput_observer.observations().size());
2714 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1800), 2714 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1800),
2715 rtt_throughput_observer.http_rtt()); 2715 rtt_throughput_observer.http_rtt());
2716 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500), 2716 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500),
2717 rtt_throughput_observer.transport_rtt()); 2717 rtt_throughput_observer.transport_rtt());
2718 EXPECT_EQ(nqe::internal::kInvalidThroughput, 2718 EXPECT_EQ(75, rtt_throughput_observer.downstream_throughput_kbps());
2719 rtt_throughput_observer.downstream_throughput_kbps());
2720 EXPECT_LE( 2719 EXPECT_LE(
2721 1u, 2720 1u,
2722 effective_connection_type_observer.effective_connection_types().size()); 2721 effective_connection_type_observer.effective_connection_types().size());
2723 // Compare the ECT stored in prefs with the observer's last entry. 2722 // Compare the ECT stored in prefs with the observer's last entry.
2724 EXPECT_EQ( 2723 EXPECT_EQ(
2725 read_prefs[nqe::internal::NetworkID( 2724 read_prefs[nqe::internal::NetworkID(
2726 NetworkChangeNotifier::CONNECTION_WIFI, network_name)] 2725 NetworkChangeNotifier::CONNECTION_WIFI, network_name)]
2727 .effective_connection_type(), 2726 .effective_connection_type(),
2728 effective_connection_type_observer.effective_connection_types().back()); 2727 effective_connection_type_observer.effective_connection_types().back());
2729 2728
2730 // Change to a different connection type. 2729 // Change to a different connection type.
2731 network_name = "test_ect_slow_2g"; 2730 network_name = "test_ect_slow_2g";
2732 estimator.SimulateNetworkChange( 2731 estimator.SimulateNetworkChange(
2733 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, network_name); 2732 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, network_name);
2734 2733
2735 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3600), 2734 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3600),
2736 rtt_observer.last_rtt( 2735 rtt_observer.last_rtt(
2737 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE)); 2736 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE));
2738 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3000), 2737 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3000),
2739 rtt_observer.last_rtt( 2738 rtt_observer.last_rtt(
2740 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE)); 2739 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE));
2741 EXPECT_EQ(0u, throughput_observer.observations().size()); 2740 EXPECT_EQ(2U, throughput_observer.observations().size());
2742 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3600), 2741 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3600),
2743 rtt_throughput_observer.http_rtt()); 2742 rtt_throughput_observer.http_rtt());
2744 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3000), 2743 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3000),
2745 rtt_throughput_observer.transport_rtt()); 2744 rtt_throughput_observer.transport_rtt());
2746 EXPECT_EQ(nqe::internal::kInvalidThroughput, 2745 EXPECT_EQ(40, rtt_throughput_observer.downstream_throughput_kbps());
2747 rtt_throughput_observer.downstream_throughput_kbps());
2748 EXPECT_LE( 2746 EXPECT_LE(
2749 2u, 2747 2u,
2750 effective_connection_type_observer.effective_connection_types().size()); 2748 effective_connection_type_observer.effective_connection_types().size());
2751 // Compare with the last entry. 2749 // Compare with the last entry.
2752 EXPECT_EQ( 2750 EXPECT_EQ(
2753 read_prefs[nqe::internal::NetworkID( 2751 read_prefs[nqe::internal::NetworkID(
2754 NetworkChangeNotifier::CONNECTION_WIFI, network_name)] 2752 NetworkChangeNotifier::CONNECTION_WIFI, network_name)]
2755 .effective_connection_type(), 2753 .effective_connection_type(),
2756 effective_connection_type_observer.effective_connection_types().back()); 2754 effective_connection_type_observer.effective_connection_types().back());
2757 2755
2758 // Cleanup. 2756 // Cleanup.
2759 estimator.RemoveRTTObserver(&rtt_observer); 2757 estimator.RemoveRTTObserver(&rtt_observer);
2760 estimator.RemoveThroughputObserver(&throughput_observer); 2758 estimator.RemoveThroughputObserver(&throughput_observer);
2761 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); 2759 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer);
2762 estimator.RemoveEffectiveConnectionTypeObserver( 2760 estimator.RemoveEffectiveConnectionTypeObserver(
2763 &effective_connection_type_observer); 2761 &effective_connection_type_observer);
2764 } 2762 }
2765 2763
2766 } // namespace net 2764 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator_params.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698