| Index: net/base/network_change_notifier_unittest.cc
|
| diff --git a/net/base/network_change_notifier_unittest.cc b/net/base/network_change_notifier_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..db6301763999491cbc2e557213847572981c14e8
|
| --- /dev/null
|
| +++ b/net/base/network_change_notifier_unittest.cc
|
| @@ -0,0 +1,68 @@
|
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "net/base/net_util.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace net {
|
| +
|
| +class NetworkChangeNotifierTest : public testing::Test {
|
| + public:
|
| + NetworkChangeNotifierTest() {}
|
| + virtual ~NetworkChangeNotifierTest() {}
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierTest);
|
| +};
|
| +
|
| +TEST_F(NetworkChangeNotifierTest, InterfacesToConnectionType) {
|
| + NetworkInterfaceList list;
|
| +
|
| + // Test empty list.
|
| + EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
|
| + NetworkChangeNotifier::CONNECTION_UNKNOWN);
|
| +
|
| + NetworkInterface interface;
|
| + for (int i = NetworkChangeNotifier::CONNECTION_UNKNOWN;
|
| + i < NetworkChangeNotifier::CONNECTION_LAST;
|
| + i++) {
|
| + // Check individual types.
|
| + list.clear();
|
| + interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i);
|
| + list.push_back(interface);
|
| + EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), i);
|
| + // Check two types.
|
| + for (int j = NetworkChangeNotifier::CONNECTION_UNKNOWN;
|
| + j < NetworkChangeNotifier::CONNECTION_LAST;
|
| + j++) {
|
| + list.clear();
|
| + interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i);
|
| + list.push_back(interface);
|
| + interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(j);
|
| + list.push_back(interface);
|
| + EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
|
| + i == j ? i : NetworkChangeNotifier::CONNECTION_UNKNOWN);
|
| + }
|
| + }
|
| +
|
| +#if defined(OS_WIN)
|
| + // Ignore fake teredo interface.
|
| + list.clear();
|
| + interface.type = NetworkChangeNotifier::CONNECTION_4G;
|
| + interface.friendly_name = "Teredo Tunneling Pseudo-Interface";
|
| + list.push_back(interface);
|
| + EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
|
| + NetworkChangeNotifier::CONNECTION_UNKNOWN);
|
| + interface.type = NetworkChangeNotifier::CONNECTION_3G;
|
| + interface.friendly_name = "";
|
| + list.push_back(interface);
|
| + EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
|
| + NetworkChangeNotifier::CONNECTION_3G);
|
| + list.reverse();
|
| + EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
|
| + NetworkChangeNotifier::CONNECTION_3G);
|
| +#endif
|
| +}
|
| +
|
| +} // namespace net
|
|
|