| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 22 matching lines...) Expand all Loading... |
| 33 UdpSocketManager::Return(); | 33 UdpSocketManager::Return(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Creates a socket and adds it to the socket manager, and then removes it | 36 // Creates a socket and adds it to the socket manager, and then removes it |
| 37 // before destroying the socket manager. | 37 // before destroying the socket manager. |
| 38 TEST(UdpSocketManager, AddAndRemoveSocketDoesNotLeakMemory) { | 38 TEST(UdpSocketManager, AddAndRemoveSocketDoesNotLeakMemory) { |
| 39 int32_t id = 42; | 39 int32_t id = 42; |
| 40 uint8_t threads = 1; | 40 uint8_t threads = 1; |
| 41 UdpSocketManager* mgr = UdpSocketManager::Create(id, threads); | 41 UdpSocketManager* mgr = UdpSocketManager::Create(id, threads); |
| 42 UdpSocketWrapper* socket = | 42 UdpSocketWrapper* socket = |
| 43 UdpSocketWrapper::CreateSocket(id, | 43 UdpSocketWrapper::CreateSocket(id, mgr, |
| 44 mgr, | 44 nullptr, // CallbackObj |
| 45 NULL, // CallbackObj | 45 nullptr, // IncomingSocketCallback |
| 46 NULL, // IncomingSocketCallback | 46 false, // ipV6Enable |
| 47 false, // ipV6Enable | 47 false); // disableGQOS |
| 48 false); // disableGQOS | |
| 49 // The constructor will do AddSocket on the manager. | 48 // The constructor will do AddSocket on the manager. |
| 50 // RemoveSocket indirectly calls Delete. | 49 // RemoveSocket indirectly calls Delete. |
| 51 EXPECT_EQ(true, mgr->RemoveSocket(socket)); | 50 EXPECT_EQ(true, mgr->RemoveSocket(socket)); |
| 52 UdpSocketManager::Return(); | 51 UdpSocketManager::Return(); |
| 53 } | 52 } |
| 54 | 53 |
| 55 // Creates a socket and add it to the socket manager, but does not remove it | 54 // Creates a socket and add it to the socket manager, but does not remove it |
| 56 // before destroying the socket manager. | 55 // before destroying the socket manager. |
| 57 // On Posix, this destroys the socket. | 56 // On Posix, this destroys the socket. |
| 58 // On Winsock2 Windows, it enters an infinite wait for all the sockets | 57 // On Winsock2 Windows, it enters an infinite wait for all the sockets |
| 59 // to go away. | 58 // to go away. |
| 60 TEST(UdpSocketManager, UnremovedSocketsGetCollectedAtManagerDeletion) { | 59 TEST(UdpSocketManager, UnremovedSocketsGetCollectedAtManagerDeletion) { |
| 61 #if defined(_WIN32) | 60 #if defined(_WIN32) |
| 62 // It's hard to test an infinite wait, so we don't. | 61 // It's hard to test an infinite wait, so we don't. |
| 63 #else | 62 #else |
| 64 int32_t id = 42; | 63 int32_t id = 42; |
| 65 uint8_t threads = 1; | 64 uint8_t threads = 1; |
| 66 UdpSocketManager* mgr = UdpSocketManager::Create(id, threads); | 65 UdpSocketManager* mgr = UdpSocketManager::Create(id, threads); |
| 67 UdpSocketWrapper* unused_socket = UdpSocketWrapper::CreateSocket( | 66 UdpSocketWrapper* unused_socket = |
| 68 id, | 67 UdpSocketWrapper::CreateSocket(id, mgr, |
| 69 mgr, | 68 nullptr, // CallbackObj |
| 70 NULL, // CallbackObj | 69 nullptr, // IncomingSocketCallback |
| 71 NULL, // IncomingSocketCallback | 70 false, // ipV6Enable |
| 72 false, // ipV6Enable | 71 false); // disableGQOS |
| 73 false); // disableGQOS | |
| 74 // The constructor will do AddSocket on the manager. | 72 // The constructor will do AddSocket on the manager. |
| 75 // Call a member funtion to work around "set but not used" compliation | 73 // Call a member funtion to work around "set but not used" compliation |
| 76 // error on ChromeOS ARM. | 74 // error on ChromeOS ARM. |
| 77 unused_socket->SetEventToNull(); | 75 unused_socket->SetEventToNull(); |
| 78 unused_socket = NULL; | 76 unused_socket = nullptr; |
| 79 UdpSocketManager::Return(); | 77 UdpSocketManager::Return(); |
| 80 #endif | 78 #endif |
| 81 } | 79 } |
| 82 | 80 |
| 83 } // namespace test | 81 } // namespace test |
| 84 } // namespace webrtc | 82 } // namespace webrtc |
| OLD | NEW |