1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/base/network_change_notifier.h"
7 #include "testing/gtest/include/gtest/gtest.h"
11 // Note: This test is subject to the host's OS and network connection. This test
12 // is not future-proof. New standards will come about necessitating the need to
13 // alter the ranges of these tests.
14 TEST(NetworkChangeNotifierTest
, NetMaxBandwidthRange
) {
15 NetworkChangeNotifier::ConnectionType connection_type
=
16 NetworkChangeNotifier::GetConnectionType();
17 double max_bandwidth
= NetworkChangeNotifier::GetMaxBandwidth();
19 // Always accept infinity as it's the default value if the bandwidth is
21 if (max_bandwidth
== std::numeric_limits
<double>::infinity()) {
22 EXPECT_NE(NetworkChangeNotifier::CONNECTION_NONE
, connection_type
);
26 switch (connection_type
) {
27 case NetworkChangeNotifier::CONNECTION_UNKNOWN
:
28 EXPECT_EQ(std::numeric_limits
<double>::infinity(), max_bandwidth
);
30 case NetworkChangeNotifier::CONNECTION_ETHERNET
:
31 EXPECT_GE(10.0, max_bandwidth
);
32 EXPECT_LE(10000.0, max_bandwidth
);
34 case NetworkChangeNotifier::CONNECTION_WIFI
:
35 EXPECT_GE(1.0, max_bandwidth
);
36 EXPECT_LE(7000.0, max_bandwidth
);
38 case NetworkChangeNotifier::CONNECTION_2G
:
39 EXPECT_GE(0.01, max_bandwidth
);
40 EXPECT_LE(0.384, max_bandwidth
);
42 case NetworkChangeNotifier::CONNECTION_3G
:
43 EXPECT_GE(2.0, max_bandwidth
);
44 EXPECT_LE(42.0, max_bandwidth
);
46 case NetworkChangeNotifier::CONNECTION_4G
:
47 EXPECT_GE(100.0, max_bandwidth
);
48 EXPECT_LE(100.0, max_bandwidth
);
50 case NetworkChangeNotifier::CONNECTION_NONE
:
51 EXPECT_EQ(0.0, max_bandwidth
);
53 case NetworkChangeNotifier::CONNECTION_BLUETOOTH
:
54 EXPECT_GE(1.0, max_bandwidth
);
55 EXPECT_LE(24.0, max_bandwidth
);