OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 #if defined(WEBRTC_WIN) | 170 #if defined(WEBRTC_WIN) |
171 closesocket(fd); | 171 closesocket(fd); |
172 #else | 172 #else |
173 close(fd); | 173 close(fd); |
174 #endif | 174 #endif |
175 } | 175 } |
176 delete (*it); | 176 delete (*it); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 // Test StartUpdating() and StopUpdating(). network_permission_state starts with | 180 // Test that UpdateNetworks succeeds. |
181 // ALLOWED. | |
182 TEST_F(NetworkTest, TestUpdateNetworks) { | 181 TEST_F(NetworkTest, TestUpdateNetworks) { |
183 BasicNetworkManager manager; | 182 BasicNetworkManager manager; |
184 manager.SignalNetworksChanged.connect( | 183 manager.SignalNetworksChanged.connect( |
185 static_cast<NetworkTest*>(this), &NetworkTest::OnNetworksChanged); | 184 static_cast<NetworkTest*>(this), &NetworkTest::OnNetworksChanged); |
186 EXPECT_EQ(manager.enumeration_permission(), | |
187 NetworkManager::kEnumerationAllowed); | |
188 manager.StartUpdating(); | 185 manager.StartUpdating(); |
189 Thread::Current()->ProcessMessages(0); | 186 Thread::Current()->ProcessMessages(0); |
190 EXPECT_TRUE(callback_called_); | 187 EXPECT_TRUE(callback_called_); |
191 callback_called_ = false; | 188 callback_called_ = false; |
192 // Callback should be triggered immediately when StartUpdating | 189 // Callback should be triggered immediately when StartUpdating |
193 // is called, after network update signal is already sent. | 190 // is called, after network update signal is already sent. |
194 manager.StartUpdating(); | 191 manager.StartUpdating(); |
195 EXPECT_TRUE(manager.started()); | 192 EXPECT_TRUE(manager.started()); |
196 Thread::Current()->ProcessMessages(0); | 193 Thread::Current()->ProcessMessages(0); |
197 EXPECT_TRUE(callback_called_); | 194 EXPECT_TRUE(callback_called_); |
198 manager.StopUpdating(); | 195 manager.StopUpdating(); |
199 EXPECT_TRUE(manager.started()); | 196 EXPECT_TRUE(manager.started()); |
200 manager.StopUpdating(); | 197 manager.StopUpdating(); |
201 EXPECT_EQ(manager.enumeration_permission(), | |
202 NetworkManager::kEnumerationAllowed); | |
203 EXPECT_FALSE(manager.started()); | 198 EXPECT_FALSE(manager.started()); |
204 manager.StopUpdating(); | 199 manager.StopUpdating(); |
205 EXPECT_FALSE(manager.started()); | 200 EXPECT_FALSE(manager.started()); |
206 callback_called_ = false; | 201 callback_called_ = false; |
207 // Callback should be triggered immediately after StartUpdating is called | 202 // Callback should be triggered immediately after StartUpdating is called |
208 // when start_count_ is reset to 0. | 203 // when start_count_ is reset to 0. |
209 manager.StartUpdating(); | 204 manager.StartUpdating(); |
210 Thread::Current()->ProcessMessages(0); | 205 Thread::Current()->ProcessMessages(0); |
211 EXPECT_TRUE(callback_called_); | 206 EXPECT_TRUE(callback_called_); |
212 } | 207 } |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 EXPECT_EQ(ipv6_network.GetBestIP(), static_cast<IPAddress>(ip)); | 773 EXPECT_EQ(ipv6_network.GetBestIP(), static_cast<IPAddress>(ip)); |
779 | 774 |
780 // Add global dynamic temporary one. | 775 // Add global dynamic temporary one. |
781 ipstr = "2401:fa00:4:1000:be30:5bff:fee5:c6"; | 776 ipstr = "2401:fa00:4:1000:be30:5bff:fee5:c6"; |
782 ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_TEMPORARY, &ip)); | 777 ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_TEMPORARY, &ip)); |
783 ipv6_network.AddIP(ip); | 778 ipv6_network.AddIP(ip); |
784 EXPECT_EQ(ipv6_network.GetBestIP(), static_cast<IPAddress>(ip)); | 779 EXPECT_EQ(ipv6_network.GetBestIP(), static_cast<IPAddress>(ip)); |
785 } | 780 } |
786 | 781 |
787 } // namespace rtc | 782 } // namespace rtc |
OLD | NEW |