OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/tests/test_network_monitor.h" | 5 #include "ppapi/tests/test_network_monitor.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
10 #include "ppapi/cpp/instance_handle.h" | 10 #include "ppapi/cpp/instance_handle.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 std::string TestNetworkMonitor::VerifyNetworkList( | 57 std::string TestNetworkMonitor::VerifyNetworkList( |
58 const pp::NetworkList& network_list) { | 58 const pp::NetworkList& network_list) { |
59 // Verify that there is at least one network interface. | 59 // Verify that there is at least one network interface. |
60 size_t count = network_list.GetCount(); | 60 size_t count = network_list.GetCount(); |
61 ASSERT_TRUE(count >= 1U); | 61 ASSERT_TRUE(count >= 1U); |
62 | 62 |
63 // Iterate over all interfaces and verify their properties. | 63 // Iterate over all interfaces and verify their properties. |
64 for (size_t iface = 0; iface < count; ++iface) { | 64 for (size_t iface = 0; iface < count; ++iface) { |
65 // Verify that the first interface has at least one address. | 65 // Verify that the first interface has at least one address. |
66 std::vector<pp::NetAddress> addresses; | 66 std::vector<pp::NetAddress> addresses; |
67 network_list.GetIpAddresses(iface, &addresses); | 67 network_list.GetIpAddresses(static_cast<uint32_t>(iface), &addresses); |
68 ASSERT_TRUE(addresses.size() >= 1U); | 68 ASSERT_TRUE(addresses.size() >= 1U); |
69 // Verify that the addresses are valid. | 69 // Verify that the addresses are valid. |
70 for (size_t i = 0; i < addresses.size(); ++i) { | 70 for (size_t i = 0; i < addresses.size(); ++i) { |
71 PP_NetAddress_Family family = addresses[i].GetFamily(); | 71 PP_NetAddress_Family family = addresses[i].GetFamily(); |
72 | 72 |
73 switch (family) { | 73 switch (family) { |
74 case PP_NETADDRESS_FAMILY_IPV4: { | 74 case PP_NETADDRESS_FAMILY_IPV4: { |
75 PP_NetAddress_IPv4 ipv4; | 75 PP_NetAddress_IPv4 ipv4; |
76 ASSERT_TRUE(addresses[i].DescribeAsIPv4Address(&ipv4)); | 76 ASSERT_TRUE(addresses[i].DescribeAsIPv4Address(&ipv4)); |
77 | 77 |
(...skipping 30 matching lines...) Expand all Loading... |
108 ASSERT_TRUE(ipv6.port == 0); | 108 ASSERT_TRUE(ipv6.port == 0); |
109 break; | 109 break; |
110 } | 110 } |
111 | 111 |
112 default: | 112 default: |
113 ASSERT_TRUE(false); | 113 ASSERT_TRUE(false); |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 // Verify that each interface has a unique name and a display name. | 117 // Verify that each interface has a unique name and a display name. |
118 ASSERT_FALSE(network_list.GetName(iface).empty()); | 118 ASSERT_FALSE(network_list.GetName(static_cast<uint32_t>(iface)).empty()); |
119 ASSERT_FALSE(network_list.GetDisplayName(iface).empty()); | 119 ASSERT_FALSE(network_list.GetDisplayName( |
| 120 static_cast<uint32_t>(iface)).empty()); |
120 | 121 |
121 PP_NetworkList_Type type = network_list.GetType(iface); | 122 PP_NetworkList_Type type = |
| 123 network_list.GetType(static_cast<uint32_t>(iface)); |
122 ASSERT_TRUE(type >= PP_NETWORKLIST_TYPE_UNKNOWN); | 124 ASSERT_TRUE(type >= PP_NETWORKLIST_TYPE_UNKNOWN); |
123 ASSERT_TRUE(type <= PP_NETWORKLIST_TYPE_CELLULAR); | 125 ASSERT_TRUE(type <= PP_NETWORKLIST_TYPE_CELLULAR); |
124 | 126 |
125 PP_NetworkList_State state = network_list.GetState(iface); | 127 PP_NetworkList_State state = |
| 128 network_list.GetState(static_cast<uint32_t>(iface)); |
126 ASSERT_TRUE(state >= PP_NETWORKLIST_STATE_DOWN); | 129 ASSERT_TRUE(state >= PP_NETWORKLIST_STATE_DOWN); |
127 ASSERT_TRUE(state <= PP_NETWORKLIST_STATE_UP); | 130 ASSERT_TRUE(state <= PP_NETWORKLIST_STATE_UP); |
128 } | 131 } |
129 | 132 |
130 PASS(); | 133 PASS(); |
131 } | 134 } |
132 | 135 |
133 std::string TestNetworkMonitor::TestBasic() { | 136 std::string TestNetworkMonitor::TestBasic() { |
134 TestCompletionCallbackWithOutput<pp::NetworkList> test_callback( | 137 TestCompletionCallbackWithOutput<pp::NetworkList> test_callback( |
135 instance_->pp_instance()); | 138 instance_->pp_instance()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 instance_->pp_instance()); | 176 instance_->pp_instance()); |
174 test_callback.SetDelegate(&deletion_delegate); | 177 test_callback.SetDelegate(&deletion_delegate); |
175 test_callback.WaitForResult( | 178 test_callback.WaitForResult( |
176 network_monitor->UpdateNetworkList(test_callback.GetCallback())); | 179 network_monitor->UpdateNetworkList(test_callback.GetCallback())); |
177 | 180 |
178 ASSERT_EQ(PP_OK, test_callback.result()); | 181 ASSERT_EQ(PP_OK, test_callback.result()); |
179 ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(test_callback.output())); | 182 ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(test_callback.output())); |
180 | 183 |
181 PASS(); | 184 PASS(); |
182 } | 185 } |
OLD | NEW |