OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/tests/test_tcp_socket.h" | 5 #include "ppapi/tests/test_tcp_socket.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ppapi/cpp/message_loop.h" | 9 #include "ppapi/cpp/message_loop.h" |
10 #include "ppapi/cpp/tcp_socket.h" | 10 #include "ppapi/cpp/tcp_socket.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 PASS(); | 134 PASS(); |
135 } | 135 } |
136 | 136 |
137 std::string TestTCPSocket::TestSetOption() { | 137 std::string TestTCPSocket::TestSetOption() { |
138 pp::TCPSocket socket(instance_); | 138 pp::TCPSocket socket(instance_); |
139 TestCompletionCallback cb_1(instance_->pp_instance(), callback_type()); | 139 TestCompletionCallback cb_1(instance_->pp_instance(), callback_type()); |
140 TestCompletionCallback cb_2(instance_->pp_instance(), callback_type()); | 140 TestCompletionCallback cb_2(instance_->pp_instance(), callback_type()); |
141 TestCompletionCallback cb_3(instance_->pp_instance(), callback_type()); | 141 TestCompletionCallback cb_3(instance_->pp_instance(), callback_type()); |
142 | 142 |
143 // These options cannot be set before the socket is connected. | 143 // These options can be set even before the socket is connected. |
144 int32_t result_1 = socket.SetOption(PP_TCPSOCKET_OPTION_NO_DELAY, | 144 int32_t result_1 = socket.SetOption(PP_TCPSOCKET_OPTION_NO_DELAY, |
145 true, cb_1.GetCallback()); | 145 true, cb_1.GetCallback()); |
146 int32_t result_2 = socket.SetOption(PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE, | 146 int32_t result_2 = socket.SetOption(PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE, |
147 256, cb_2.GetCallback()); | 147 256, cb_2.GetCallback()); |
148 int32_t result_3 = socket.SetOption(PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE, | 148 int32_t result_3 = socket.SetOption(PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE, |
149 512, cb_3.GetCallback()); | 149 512, cb_3.GetCallback()); |
150 | 150 |
151 cb_1.WaitForResult(result_1); | 151 cb_1.WaitForResult(result_1); |
152 CHECK_CALLBACK_BEHAVIOR(cb_1); | 152 CHECK_CALLBACK_BEHAVIOR(cb_1); |
153 ASSERT_EQ(PP_ERROR_FAILED, cb_1.result()); | 153 ASSERT_EQ(PP_OK, cb_1.result()); |
154 | 154 |
155 cb_2.WaitForResult(result_2); | 155 cb_2.WaitForResult(result_2); |
156 CHECK_CALLBACK_BEHAVIOR(cb_2); | 156 CHECK_CALLBACK_BEHAVIOR(cb_2); |
157 ASSERT_EQ(PP_ERROR_FAILED, cb_2.result()); | 157 ASSERT_EQ(PP_OK, cb_2.result()); |
158 | 158 |
159 cb_3.WaitForResult(result_3); | 159 cb_3.WaitForResult(result_3); |
160 CHECK_CALLBACK_BEHAVIOR(cb_3); | 160 CHECK_CALLBACK_BEHAVIOR(cb_3); |
161 ASSERT_EQ(PP_ERROR_FAILED, cb_3.result()); | 161 ASSERT_EQ(PP_OK, cb_3.result()); |
162 | 162 |
163 cb_1.WaitForResult(socket.Connect(addr_, cb_1.GetCallback())); | 163 cb_1.WaitForResult(socket.Connect(addr_, cb_1.GetCallback())); |
164 CHECK_CALLBACK_BEHAVIOR(cb_1); | 164 CHECK_CALLBACK_BEHAVIOR(cb_1); |
165 ASSERT_EQ(PP_OK, cb_1.result()); | 165 ASSERT_EQ(PP_OK, cb_1.result()); |
166 | 166 |
167 result_1 = socket.SetOption(PP_TCPSOCKET_OPTION_NO_DELAY, | 167 result_1 = socket.SetOption(PP_TCPSOCKET_OPTION_NO_DELAY, |
168 false, cb_1.GetCallback()); | 168 false, cb_1.GetCallback()); |
169 result_2 = socket.SetOption(PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE, | 169 result_2 = socket.SetOption(PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE, |
170 512, cb_2.GetCallback()); | 170 512, cb_2.GetCallback()); |
171 result_3 = socket.SetOption(PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE, | 171 result_3 = socket.SetOption(PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE, |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 CHECK_CALLBACK_BEHAVIOR(callback); | 451 CHECK_CALLBACK_BEHAVIOR(callback); |
452 ASSERT_EQ(PP_OK, callback.result()); | 452 ASSERT_EQ(PP_OK, callback.result()); |
453 | 453 |
454 callback.WaitForResult( | 454 callback.WaitForResult( |
455 socket->Listen(backlog, callback.GetCallback())); | 455 socket->Listen(backlog, callback.GetCallback())); |
456 CHECK_CALLBACK_BEHAVIOR(callback); | 456 CHECK_CALLBACK_BEHAVIOR(callback); |
457 ASSERT_EQ(PP_OK, callback.result()); | 457 ASSERT_EQ(PP_OK, callback.result()); |
458 | 458 |
459 PASS(); | 459 PASS(); |
460 } | 460 } |
461 | |
OLD | NEW |