Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_websocket.h" | 5 #include "ppapi/tests/test_websocket.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ppapi/c/dev/ppb_testing_dev.h" | 10 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 11 #include "ppapi/c/pp_errors.h" | 11 #include "ppapi/c/pp_errors.h" |
| 12 #include "ppapi/c/pp_var.h" | 12 #include "ppapi/c/pp_var.h" |
| 13 #include "ppapi/c/pp_completion_callback.h" | 13 #include "ppapi/c/pp_completion_callback.h" |
| 14 #include "ppapi/c/ppb_core.h" | 14 #include "ppapi/c/ppb_core.h" |
| 15 #include "ppapi/c/ppb_var.h" | 15 #include "ppapi/c/ppb_var.h" |
| 16 #include "ppapi/c/ppb_var_array_buffer.h" | 16 #include "ppapi/c/ppb_var_array_buffer.h" |
| 17 #include "ppapi/c/ppb_websocket.h" | 17 #include "ppapi/c/ppb_websocket.h" |
| 18 #include "ppapi/cpp/instance.h" | 18 #include "ppapi/cpp/instance.h" |
| 19 #include "ppapi/cpp/module.h" | 19 #include "ppapi/cpp/module.h" |
| 20 #include "ppapi/cpp/var_array_buffer.h" | 20 #include "ppapi/cpp/var_array_buffer.h" |
| 21 #include "ppapi/cpp/websocket.h" | 21 #include "ppapi/cpp/websocket.h" |
| 22 #include "ppapi/tests/test_utils.h" | 22 #include "ppapi/tests/test_utils.h" |
| 23 #include "ppapi/tests/testing_instance.h" | 23 #include "ppapi/tests/testing_instance.h" |
| 24 #include "ppapi/utility/websocket/websocket_api.h" | 24 #include "ppapi/utility/websocket/websocket_api.h" |
| 25 | 25 |
| 26 // These servers are provided by pywebsocket server side handlers in | 26 // These servers are provided by pywebsocket server side handlers in |
| 27 // LayoutTests/http/tests/websocket/tests/hybi/*_wsh. | 27 // LayoutTests/http/tests/websocket/tests/hybi/*_wsh. |
| 28 // pywebsocket server itself is launched in ppapi_ui_test.cc. | 28 // pywebsocket server itself is launched in ppapi_ui_test.cc. |
| 29 const char kEchoServerURL[] = | 29 const char kEchoServerURL[] = |
| 30 "ws://localhost:8880/websocket/tests/hybi/echo"; | 30 "ws://localhost:8880/websocket/tests/hybi/echo"; |
|
Takashi Toyoshima
2012/03/09 18:46:15
This URL will be changed to ".../hybi/echo-with-no
| |
| 31 | 31 |
| 32 const char kCloseServerURL[] = | 32 const char kCloseServerURL[] = |
| 33 "ws://localhost:8880/websocket/tests/hybi/close"; | 33 "ws://localhost:8880/websocket/tests/hybi/close"; |
| 34 | 34 |
| 35 const char kProtocolTestServerURL[] = | 35 const char kProtocolTestServerURL[] = |
| 36 "ws://localhost:8880/websocket/tests/hybi/protocol-test?protocol="; | 36 "ws://localhost:8880/websocket/tests/hybi/protocol-test?protocol="; |
| 37 | 37 |
| 38 const char* const kInvalidURLs[] = { | 38 const char* const kInvalidURLs[] = { |
| 39 "http://www.google.com/invalid_scheme", | 39 "http://www.google.com/invalid_scheme", |
| 40 "ws://www.google.com/invalid#fragment", | 40 "ws://www.google.com/invalid#fragment", |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, pp::Var(reason), close_callback); | 741 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, pp::Var(reason), close_callback); |
| 742 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); | 742 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); |
| 743 result = close_callback.WaitForResult(); | 743 result = close_callback.WaitForResult(); |
| 744 ASSERT_EQ(PP_OK, result); | 744 ASSERT_EQ(PP_OK, result); |
| 745 | 745 |
| 746 // Check initialized properties access. | 746 // Check initialized properties access. |
| 747 ASSERT_EQ(0, ws.GetBufferedAmount()); | 747 ASSERT_EQ(0, ws.GetBufferedAmount()); |
| 748 ASSERT_EQ(PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, ws.GetCloseCode()); | 748 ASSERT_EQ(PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, ws.GetCloseCode()); |
| 749 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); | 749 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); |
| 750 ASSERT_EQ(true, ws.GetCloseWasClean()); | 750 ASSERT_EQ(true, ws.GetCloseWasClean()); |
| 751 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); | 751 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), |
| 752 "x-webkit-deflate-frame")); | |
|
dmichael (off chromium)
2012/03/09 18:27:16
What's the extension do? Is there a way for a PPAP
Takashi Toyoshima
2012/03/09 18:46:15
Extensions is defined in RFC for WebSocket.
This m
| |
| 752 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); | 753 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); |
| 753 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED, ws.GetReadyState()); | 754 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED, ws.GetReadyState()); |
| 754 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); | 755 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); |
| 755 | 756 |
| 756 PASS(); | 757 PASS(); |
| 757 } | 758 } |
| 758 | 759 |
| 759 std::string TestWebSocket::TestUtilityInvalidConnect() { | 760 std::string TestWebSocket::TestUtilityInvalidConnect() { |
| 760 const pp::Var protocols[] = { pp::Var() }; | 761 const pp::Var protocols[] = { pp::Var() }; |
| 761 | 762 |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1085 size_t last_event = events_on_closed - 1; | 1086 size_t last_event = events_on_closed - 1; |
| 1086 for (uint32_t i = 1; i < last_event; ++i) { | 1087 for (uint32_t i = 1; i < last_event; ++i) { |
| 1087 ASSERT_EQ(WebSocketEvent::EVENT_MESSAGE, events[i].event_type); | 1088 ASSERT_EQ(WebSocketEvent::EVENT_MESSAGE, events[i].event_type); |
| 1088 ASSERT_TRUE(AreEqualWithString(events[i].var.pp_var(), message_char)); | 1089 ASSERT_TRUE(AreEqualWithString(events[i].var.pp_var(), message_char)); |
| 1089 } | 1090 } |
| 1090 ASSERT_EQ(WebSocketEvent::EVENT_CLOSE, events[last_event].event_type); | 1091 ASSERT_EQ(WebSocketEvent::EVENT_CLOSE, events[last_event].event_type); |
| 1091 ASSERT_TRUE(events[last_event].was_clean); | 1092 ASSERT_TRUE(events[last_event].was_clean); |
| 1092 | 1093 |
| 1093 PASS(); | 1094 PASS(); |
| 1094 } | 1095 } |
| OLD | NEW |