Chromium Code Reviews| Index: ppapi/tests/test_websocket.cc |
| diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc |
| index b2702bf3d8fb87d856390db13f1497e0b09fc935..e0a54aa6aa9c9821d7dc3739e1948a675a3cceb0 100644 |
| --- a/ppapi/tests/test_websocket.cc |
| +++ b/ppapi/tests/test_websocket.cc |
| @@ -224,6 +224,7 @@ void TestWebSocket::RunTests(const std::string& filter) { |
| RUN_TEST_WITH_REFERENCE_CHECK(AbortSendMessageCall, filter); |
| RUN_TEST_WITH_REFERENCE_CHECK(AbortCloseCall, filter); |
| RUN_TEST_WITH_REFERENCE_CHECK(AbortReceiveMessageCall, filter); |
| + RUN_TEST_WITH_REFERENCE_CHECK(ClosedFromServerWhileSending, filter); |
| RUN_TEST_WITH_REFERENCE_CHECK(CcInterfaces, filter); |
| @@ -1158,6 +1159,33 @@ std::string TestWebSocket::TestAbortReceiveMessageCall() { |
| PASS(); |
| } |
| +std::string TestWebSocket::TestClosedFromServerWhileSending() { |
| + // Connect to test echo server. |
| + const pp::Var protocols[] = { pp::Var() }; |
| + TestWebSocketAPI websocket(instance_); |
| + int32_t result = |
| + websocket.Connect(pp::Var(GetFullURL(kEchoServerURL)), protocols, 0U); |
| + ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); |
| + websocket.WaitForConnected(); |
| + |
| + result = websocket.Send(pp::Var("hello")); |
| + ASSERT_EQ(PP_OK, result); |
| + result = websocket.Send(pp::Var("Goodbye")); |
| + // We send many messages so that PepperWebSocketHost::SendText is called |
| + // after PepperWebSocketHost::didClose is called. |
| + // Note: We must not wait for CLOSED event here because |
| + // WebSocketResource::SendMessage doesn't call PepperWebSocketHost::SendText |
| + // when its internal state is CLOSING or CLOSED. We want to test if the |
| + // pepper WebSocket works well when WebSocketResource is OPEN and |
| + // PepperWebSocketHost is CLOSED. |
| + for (size_t i = 0; i < 10000; ++i) { |
|
Adam Rice
2014/08/27 05:58:57
Nit: this test could be flaky. However, I can't se
yhirano
2014/08/27 07:06:32
me neither.
|
| + result = websocket.Send(pp::Var("")); |
| + ASSERT_EQ(PP_OK, result); |
| + } |
| + |
| + PASS(); |
| +} |
| + |
| std::string TestWebSocket::TestCcInterfaces() { |
| // C++ bindings is simple straightforward, then just verifies interfaces work |
| // as a interface bridge fine. |