| 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 |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "webrtc/p2p/base/stunserver.h" | 14 #include "webrtc/p2p/base/stunserver.h" |
| 14 #include "webrtc/base/gunit.h" | 15 #include "webrtc/base/gunit.h" |
| 15 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
| 16 #include "webrtc/base/physicalsocketserver.h" | 17 #include "webrtc/base/physicalsocketserver.h" |
| 17 #include "webrtc/base/testclient.h" | 18 #include "webrtc/base/testclient.h" |
| 18 #include "webrtc/base/thread.h" | 19 #include "webrtc/base/thread.h" |
| 19 #include "webrtc/base/virtualsocketserver.h" | 20 #include "webrtc/base/virtualsocketserver.h" |
| 20 | 21 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 client_->NextPacket(rtc::TestClient::kTimeoutMs); | 56 client_->NextPacket(rtc::TestClient::kTimeoutMs); |
| 56 if (packet) { | 57 if (packet) { |
| 57 rtc::ByteBufferReader buf(packet->buf, packet->size); | 58 rtc::ByteBufferReader buf(packet->buf, packet->size); |
| 58 msg = new StunMessage(); | 59 msg = new StunMessage(); |
| 59 msg->Read(&buf); | 60 msg->Read(&buf); |
| 60 delete packet; | 61 delete packet; |
| 61 } | 62 } |
| 62 return msg; | 63 return msg; |
| 63 } | 64 } |
| 64 private: | 65 private: |
| 65 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; | 66 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
| 66 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; | 67 std::unique_ptr<rtc::VirtualSocketServer> ss_; |
| 67 rtc::Thread worker_; | 68 rtc::Thread worker_; |
| 68 rtc::scoped_ptr<StunServer> server_; | 69 std::unique_ptr<StunServer> server_; |
| 69 rtc::scoped_ptr<rtc::TestClient> client_; | 70 std::unique_ptr<rtc::TestClient> client_; |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 // Disable for TSan v2, see | 73 // Disable for TSan v2, see |
| 73 // https://code.google.com/p/webrtc/issues/detail?id=2517 for details. | 74 // https://code.google.com/p/webrtc/issues/detail?id=2517 for details. |
| 74 #if !defined(THREAD_SANITIZER) | 75 #if !defined(THREAD_SANITIZER) |
| 75 | 76 |
| 76 TEST_F(StunServerTest, TestGood) { | 77 TEST_F(StunServerTest, TestGood) { |
| 77 StunMessage req; | 78 StunMessage req; |
| 78 std::string transaction_id = "0123456789ab"; | 79 std::string transaction_id = "0123456789ab"; |
| 79 req.SetType(STUN_BINDING_REQUEST); | 80 req.SetType(STUN_BINDING_REQUEST); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 103 #endif // if !defined(THREAD_SANITIZER) | 104 #endif // if !defined(THREAD_SANITIZER) |
| 104 | 105 |
| 105 TEST_F(StunServerTest, TestBad) { | 106 TEST_F(StunServerTest, TestBad) { |
| 106 const char* bad = "this is a completely nonsensical message whose only " | 107 const char* bad = "this is a completely nonsensical message whose only " |
| 107 "purpose is to make the parser go 'ack'. it doesn't " | 108 "purpose is to make the parser go 'ack'. it doesn't " |
| 108 "look anything like a normal stun message"; | 109 "look anything like a normal stun message"; |
| 109 Send(bad, static_cast<int>(strlen(bad))); | 110 Send(bad, static_cast<int>(strlen(bad))); |
| 110 | 111 |
| 111 ASSERT_TRUE(ReceiveFails()); | 112 ASSERT_TRUE(ReceiveFails()); |
| 112 } | 113 } |
| OLD | NEW |