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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 void SetFailAccept(bool fail) { fail_accept_ = fail; } | 108 void SetFailAccept(bool fail) { fail_accept_ = fail; } |
109 bool FailAccept() const { return fail_accept_; } | 109 bool FailAccept() const { return fail_accept_; } |
110 | 110 |
111 // Maximum size to ::send to a socket. Set to < 0 to disable limiting. | 111 // Maximum size to ::send to a socket. Set to < 0 to disable limiting. |
112 void SetMaxSendSize(int max_size) { max_send_size_ = max_size; } | 112 void SetMaxSendSize(int max_size) { max_send_size_ = max_size; } |
113 int MaxSendSize() const { return max_send_size_; } | 113 int MaxSendSize() const { return max_send_size_; } |
114 | 114 |
115 protected: | 115 protected: |
116 PhysicalSocketTest() | 116 PhysicalSocketTest() |
117 : server_(new FakePhysicalSocketServer(this)), | 117 : server_(new FakePhysicalSocketServer(this)), |
118 scope_(server_.get()), | 118 thread_(server_.get()), |
119 fail_accept_(false), | 119 fail_accept_(false), |
120 max_send_size_(-1) { | 120 max_send_size_(-1) {} |
121 } | |
122 | 121 |
123 void ConnectInternalAcceptError(const IPAddress& loopback); | 122 void ConnectInternalAcceptError(const IPAddress& loopback); |
124 void WritableAfterPartialWrite(const IPAddress& loopback); | 123 void WritableAfterPartialWrite(const IPAddress& loopback); |
125 | 124 |
126 std::unique_ptr<FakePhysicalSocketServer> server_; | 125 std::unique_ptr<FakePhysicalSocketServer> server_; |
127 SocketServerScope scope_; | 126 rtc::AutoSocketServerThread thread_; |
128 bool fail_accept_; | 127 bool fail_accept_; |
129 int max_send_size_; | 128 int max_send_size_; |
130 }; | 129 }; |
131 | 130 |
132 SOCKET FakeSocketDispatcher::DoAccept(SOCKET socket, | 131 SOCKET FakeSocketDispatcher::DoAccept(SOCKET socket, |
133 sockaddr* addr, | 132 sockaddr* addr, |
134 socklen_t* addrlen) { | 133 socklen_t* addrlen) { |
135 FakePhysicalSocketServer* ss = | 134 FakePhysicalSocketServer* ss = |
136 static_cast<FakePhysicalSocketServer*>(socketserver()); | 135 static_cast<FakePhysicalSocketServer*>(socketserver()); |
137 if (ss->GetTest()->FailAccept()) { | 136 if (ss->GetTest()->FailAccept()) { |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 thread->Start(runnable.get()); | 588 thread->Start(runnable.get()); |
590 EXPECT_TRUE(ss_->Wait(1500, true)); | 589 EXPECT_TRUE(ss_->Wait(1500, true)); |
591 EXPECT_TRUE(ExpectSignal(SIGTERM)); | 590 EXPECT_TRUE(ExpectSignal(SIGTERM)); |
592 EXPECT_EQ(Thread::Current(), signaled_thread_); | 591 EXPECT_EQ(Thread::Current(), signaled_thread_); |
593 EXPECT_TRUE(ExpectNone()); | 592 EXPECT_TRUE(ExpectNone()); |
594 } | 593 } |
595 | 594 |
596 #endif | 595 #endif |
597 | 596 |
598 } // namespace rtc | 597 } // namespace rtc |
OLD | NEW |