| 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/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 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1942 std::string connection_type_name = | 1942 std::string connection_type_name = |
| 1943 std::string(NetworkQualityEstimator::GetNameForEffectiveConnectionType( | 1943 std::string(NetworkQualityEstimator::GetNameForEffectiveConnectionType( |
| 1944 effective_connection_type)); | 1944 effective_connection_type)); |
| 1945 EXPECT_FALSE(connection_type_name.empty()); | 1945 EXPECT_FALSE(connection_type_name.empty()); |
| 1946 EXPECT_EQ(effective_connection_type, | 1946 EXPECT_EQ(effective_connection_type, |
| 1947 NetworkQualityEstimator::GetEffectiveConnectionTypeForName( | 1947 NetworkQualityEstimator::GetEffectiveConnectionTypeForName( |
| 1948 connection_type_name)); | 1948 connection_type_name)); |
| 1949 } | 1949 } |
| 1950 } | 1950 } |
| 1951 | 1951 |
| 1952 TEST(NetworkQualityEstimatorTest, TestRecordNetworkIDAvailability) { |
| 1953 base::HistogramTester histogram_tester; |
| 1954 std::map<std::string, std::string> variation_params; |
| 1955 TestNetworkQualityEstimator estimator(variation_params); |
| 1956 |
| 1957 // The NetworkID is recorded as available on Wi-Fi connection. |
| 1958 estimator.SimulateNetworkChangeTo( |
| 1959 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); |
| 1960 histogram_tester.ExpectUniqueSample("NQE.NetworkIdAvailable", 1, 1); |
| 1961 |
| 1962 // The histogram is not recorded on an unknown connection. |
| 1963 estimator.SimulateNetworkChangeTo( |
| 1964 NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN, ""); |
| 1965 histogram_tester.ExpectTotalCount("NQE.NetworkIdAvailable", 1); |
| 1966 |
| 1967 // The NetworkID is recorded as not being available on a Wi-Fi connection |
| 1968 // with an empty SSID. |
| 1969 estimator.SimulateNetworkChangeTo( |
| 1970 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, ""); |
| 1971 histogram_tester.ExpectBucketCount("NQE.NetworkIdAvailable", 0, 1); |
| 1972 histogram_tester.ExpectTotalCount("NQE.NetworkIdAvailable", 2); |
| 1973 |
| 1974 // The NetworkID is recorded as being available on a Wi-Fi connection. |
| 1975 estimator.SimulateNetworkChangeTo( |
| 1976 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); |
| 1977 histogram_tester.ExpectBucketCount("NQE.NetworkIdAvailable", 1, 2); |
| 1978 histogram_tester.ExpectTotalCount("NQE.NetworkIdAvailable", 3); |
| 1979 |
| 1980 // The NetworkID is recorded as being available on a cellular connection. |
| 1981 estimator.SimulateNetworkChangeTo( |
| 1982 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-1"); |
| 1983 histogram_tester.ExpectBucketCount("NQE.NetworkIdAvailable", 1, 3); |
| 1984 histogram_tester.ExpectTotalCount("NQE.NetworkIdAvailable", 4); |
| 1985 } |
| 1986 |
| 1952 } // namespace net | 1987 } // namespace net |
| OLD | NEW |