Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Side by Side Diff: webrtc/p2p/base/turnserver_unittest.cc

Issue 2883313003: Remove VirtualSocketServer's dependency on PhysicalSocketServer. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/turnport_unittest.cc ('k') | webrtc/p2p/base/udptransport_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 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 "webrtc/base/gunit.h" 11 #include "webrtc/base/gunit.h"
12 #include "webrtc/base/physicalsocketserver.h"
13 #include "webrtc/base/virtualsocketserver.h" 12 #include "webrtc/base/virtualsocketserver.h"
14 #include "webrtc/p2p/base/basicpacketsocketfactory.h" 13 #include "webrtc/p2p/base/basicpacketsocketfactory.h"
15 #include "webrtc/p2p/base/turnserver.h" 14 #include "webrtc/p2p/base/turnserver.h"
16 15
17 // NOTE: This is a work in progress. Currently this file only has tests for 16 // NOTE: This is a work in progress. Currently this file only has tests for
18 // TurnServerConnection, a primitive class used by TurnServer. 17 // TurnServerConnection, a primitive class used by TurnServer.
19 18
20 namespace cricket { 19 namespace cricket {
21 20
22 class TurnServerConnectionTest : public testing::Test { 21 class TurnServerConnectionTest : public testing::Test {
23 public: 22 public:
24 TurnServerConnectionTest() : vss_(&pss_), thread_(&vss_) {} 23 TurnServerConnectionTest() : thread_(&vss_) {}
25 24
26 void ExpectEqual(const TurnServerConnection& a, 25 void ExpectEqual(const TurnServerConnection& a,
27 const TurnServerConnection& b) { 26 const TurnServerConnection& b) {
28 EXPECT_TRUE(a == b); 27 EXPECT_TRUE(a == b);
29 EXPECT_FALSE(a < b); 28 EXPECT_FALSE(a < b);
30 EXPECT_FALSE(b < a); 29 EXPECT_FALSE(b < a);
31 } 30 }
32 31
33 void ExpectNotEqual(const TurnServerConnection& a, 32 void ExpectNotEqual(const TurnServerConnection& a,
34 const TurnServerConnection& b) { 33 const TurnServerConnection& b) {
35 EXPECT_FALSE(a == b); 34 EXPECT_FALSE(a == b);
36 // We don't care which is less than the other, as long as only one is less 35 // We don't care which is less than the other, as long as only one is less
37 // than the other. 36 // than the other.
38 EXPECT_TRUE((a < b) != (b < a)); 37 EXPECT_TRUE((a < b) != (b < a));
39 } 38 }
40 39
41 protected: 40 protected:
42 rtc::PhysicalSocketServer pss_;
43 rtc::VirtualSocketServer vss_; 41 rtc::VirtualSocketServer vss_;
44 rtc::AutoSocketServerThread thread_; 42 rtc::AutoSocketServerThread thread_;
45 // Since this is constructed after |thread_|, it will pick up |threads_|'s 43 // Since this is constructed after |thread_|, it will pick up |threads_|'s
46 // socket server. 44 // socket server.
47 rtc::BasicPacketSocketFactory socket_factory_; 45 rtc::BasicPacketSocketFactory socket_factory_;
48 }; 46 };
49 47
50 TEST_F(TurnServerConnectionTest, ComparisonOperators) { 48 TEST_F(TurnServerConnectionTest, ComparisonOperators) {
51 std::unique_ptr<rtc::AsyncPacketSocket> socket1( 49 std::unique_ptr<rtc::AsyncPacketSocket> socket1(
52 socket_factory_.CreateUdpSocket(rtc::SocketAddress("1.1.1.1", 1), 0, 0)); 50 socket_factory_.CreateUdpSocket(rtc::SocketAddress("1.1.1.1", 1), 0, 0));
53 std::unique_ptr<rtc::AsyncPacketSocket> socket2( 51 std::unique_ptr<rtc::AsyncPacketSocket> socket2(
54 socket_factory_.CreateUdpSocket(rtc::SocketAddress("2.2.2.2", 2), 0, 0)); 52 socket_factory_.CreateUdpSocket(rtc::SocketAddress("2.2.2.2", 2), 0, 0));
55 TurnServerConnection connection1(socket2->GetLocalAddress(), PROTO_UDP, 53 TurnServerConnection connection1(socket2->GetLocalAddress(), PROTO_UDP,
56 socket1.get()); 54 socket1.get());
57 TurnServerConnection connection2(socket2->GetLocalAddress(), PROTO_UDP, 55 TurnServerConnection connection2(socket2->GetLocalAddress(), PROTO_UDP,
58 socket1.get()); 56 socket1.get());
59 TurnServerConnection connection3(socket1->GetLocalAddress(), PROTO_UDP, 57 TurnServerConnection connection3(socket1->GetLocalAddress(), PROTO_UDP,
60 socket2.get()); 58 socket2.get());
61 TurnServerConnection connection4(socket2->GetLocalAddress(), PROTO_TCP, 59 TurnServerConnection connection4(socket2->GetLocalAddress(), PROTO_TCP,
62 socket1.get()); 60 socket1.get());
63 ExpectEqual(connection1, connection2); 61 ExpectEqual(connection1, connection2);
64 ExpectNotEqual(connection1, connection3); 62 ExpectNotEqual(connection1, connection3);
65 ExpectNotEqual(connection1, connection4); 63 ExpectNotEqual(connection1, connection4);
66 } 64 }
67 65
68 } // namespace cricket 66 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport_unittest.cc ('k') | webrtc/p2p/base/udptransport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698