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

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: Add tests 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
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 "net/base/net_util.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace net {
9
10 class NetworkChangeNotifierTest : public testing::Test {
11 public:
12 NetworkChangeNotifierTest() {}
13 virtual ~NetworkChangeNotifierTest() {}
14
15 private:
16 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierTest);
17 };
18
19 TEST_F(NetworkChangeNotifierTest, InterfacesToConnectionType) {
20 NetworkInterfaceList list;
21
22 // Test empty list.
23 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
24 NetworkChangeNotifier::CONNECTION_UNKNOWN);
25
26 NetworkInterface interface;
27 for (int i = NetworkChangeNotifier::CONNECTION_UNKNOWN;
28 i < NetworkChangeNotifier::CONNECTION_LAST;
29 i++) {
30 // Check individual types.
31 list.clear();
32 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i);
33 list.push_back(interface);
34 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), i);
35 // Check two types.
36 for (int j = NetworkChangeNotifier::CONNECTION_UNKNOWN;
37 j < NetworkChangeNotifier::CONNECTION_LAST;
38 j++) {
39 list.clear();
40 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(i);
41 list.push_back(interface);
42 interface.type = static_cast<NetworkChangeNotifier::ConnectionType>(j);
43 list.push_back(interface);
44 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
45 i == j ? i : NetworkChangeNotifier::CONNECTION_UNKNOWN);
46 }
47 }
48
49 #if defined(OS_WIN)
50 // Ignore fake teredo interface.
51 list.clear();
52 interface.type = NetworkChangeNotifier::CONNECTION_4G;
53 interface.friendly_name = "Teredo Tunneling Pseudo-Interface";
54 list.push_back(interface);
55 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
56 NetworkChangeNotifier::CONNECTION_UNKNOWN);
57 interface.type = NetworkChangeNotifier::CONNECTION_3G;
58 interface.friendly_name = "";
59 list.push_back(interface);
60 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
61 NetworkChangeNotifier::CONNECTION_3G);
62 list.reverse();
63 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list),
64 NetworkChangeNotifier::CONNECTION_3G);
65 #endif
66 }
67
68 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698