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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "network_change_notifier.h"
6
7 #include "net/base/net_util.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace net {
11
12 TEST(NetworkChangeNotifierTest, InterfacesToConnectionType) {
13 NetworkInterfaceList list;
14
15 // Test empty list.
16 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
17 NetworkChangeNotifier::CONNECTION_UNKNOWN);
18
19 NetworkInterface interface;
20 for (int i = NetworkChangeNotifier::CONNECTION_UNKNOWN;
21 i < NetworkChangeNotifier::CONNECTION_LAST;
22 i++) {
23 // Check individual types.
24 list.clear();
25 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i);
26 list.push_back(interface);
27 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), i);
28 // Check two types.
29 for (int j = NetworkChangeNotifier::CONNECTION_UNKNOWN;
30 j < NetworkChangeNotifier::CONNECTION_LAST;
31 j++) {
32 list.clear();
33 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i);
34 list.push_back(interface);
35 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(j);
36 list.push_back(interface);
37 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
38 i == j ? i : NetworkChangeNotifier::CONNECTION_UNKNOWN);
39 }
40 }
41
42 #if defined(OS_WIN)
43 // Ignore fake Teredo interface.
44 list.clear();
45 interface.type = NetworkChangeNotifier::CONNECTION_4G;
46 interface.friendly_name = "Teredo Tunneling Pseudo-Interface";
47 list.push_back(interface);
48 // Verify Teredo interface type ignored.
49 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
50 NetworkChangeNotifier::CONNECTION_UNKNOWN);
51 // Verify type of non-Teredo interface used.
52 interface.type = NetworkChangeNotifier::CONNECTION_3G;
53 interface.friendly_name = "";
54 list.push_back(interface);
55 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
56 NetworkChangeNotifier::CONNECTION_3G);
57 // Reverse elements.
58 list.push_back(list[0]);
59 list.erase(list.begin());
60 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
61 NetworkChangeNotifier::CONNECTION_3G);
62 #endif
63 }
64
65 } // namespace net
OLDNEW
« 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