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

Unified Diff: net/base/network_change_notifier_unittest.cc

Issue 298023005: Infer network connection type from network interface type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid std::vector operator[] element creation Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/network_change_notifier.cc ('k') | net/base/network_change_notifier_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8aaf7e61744bf660631685389a4b46d05281b7d1
--- /dev/null
+++ b/net/base/network_change_notifier_unittest.cc
@@ -0,0 +1,65 @@
+// 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 "network_change_notifier.h"
+
+#include "net/base/net_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+TEST(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);
+ // Verify Teredo interface type ignored.
+ EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
+ NetworkChangeNotifier::CONNECTION_UNKNOWN);
+ // Verify type of non-Teredo interface used.
+ interface.type = NetworkChangeNotifier::CONNECTION_3G;
+ interface.friendly_name = "";
+ list.push_back(interface);
+ EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
+ NetworkChangeNotifier::CONNECTION_3G);
+ // Reverse elements.
+ list.push_back(list[0]);
+ list.erase(list.begin());
+ EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
+ NetworkChangeNotifier::CONNECTION_3G);
+#endif
+}
+
+} // namespace net
« no previous file with comments | « net/base/network_change_notifier.cc ('k') | net/base/network_change_notifier_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698