OLD | NEW |
---|---|
(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 | |
mmenke
2014/06/20 15:18:57
nit: #include "network_change_notifier.h", one li
pauljensen
2014/06/20 19:22:31
Done.
| |
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) { | |
mmenke
2014/06/20 15:18:57
nit: Can we get rid of the test fixture, and just
pauljensen
2014/06/20 19:22:32
Done. I forgot you could friend functions.
| |
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. | |
mmenke
2014/06/20 15:18:57
nit: I believe Teredo should be capitalized.
pauljensen
2014/06/20 19:22:32
Done.
| |
51 list.clear(); | |
52 interface.type = NetworkChangeNotifier::CONNECTION_4G; | |
53 interface.friendly_name = "Teredo Tunneling Pseudo-Interface"; | |
54 list.push_back(interface); | |
55 // Verify we ignore teredo element type. | |
mmenke
2014/06/20 15:18:57
nit: Don't use "we" in comments.
pauljensen
2014/06/20 19:22:32
Done.
| |
56 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), | |
57 NetworkChangeNotifier::CONNECTION_UNKNOWN); | |
58 // Verify we take type of non-teredo element. | |
mmenke
2014/06/20 15:18:57
nit: Don't use "we" in comments.
pauljensen
2014/06/20 19:22:32
Done.
| |
59 interface.type = NetworkChangeNotifier::CONNECTION_3G; | |
60 interface.friendly_name = ""; | |
61 list.push_back(interface); | |
62 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), | |
63 NetworkChangeNotifier::CONNECTION_3G); | |
64 // Reverse elements. | |
65 list[2] = list[0]; | |
66 list.erase(list.begin()); | |
67 EXPECT_EQ(NetworkChangeNotifier::ConnectionTypeFromInterfaceList(list), | |
68 NetworkChangeNotifier::CONNECTION_3G); | |
69 #endif | |
70 } | |
71 | |
72 } // namespace net | |
OLD | NEW |