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/dev/ppb_var_array_buffer_dev.h" | |
12 #include "ppapi/c/dev/ppb_websocket_dev.h" | 11 #include "ppapi/c/dev/ppb_websocket_dev.h" |
13 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
14 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
15 #include "ppapi/c/pp_completion_callback.h" | 14 #include "ppapi/c/pp_completion_callback.h" |
16 #include "ppapi/c/ppb_core.h" | 15 #include "ppapi/c/ppb_core.h" |
17 #include "ppapi/c/ppb_var.h" | 16 #include "ppapi/c/ppb_var.h" |
| 17 #include "ppapi/c/ppb_var_array_buffer.h" |
18 #include "ppapi/cpp/dev/websocket_dev.h" | 18 #include "ppapi/cpp/dev/websocket_dev.h" |
19 #include "ppapi/cpp/instance.h" | 19 #include "ppapi/cpp/instance.h" |
20 #include "ppapi/cpp/module.h" | 20 #include "ppapi/cpp/module.h" |
21 #include "ppapi/tests/test_utils.h" | 21 #include "ppapi/tests/test_utils.h" |
22 #include "ppapi/tests/testing_instance.h" | 22 #include "ppapi/tests/testing_instance.h" |
23 | 23 |
24 const char kEchoServerURL[] = | 24 const char kEchoServerURL[] = |
25 "ws://localhost:8880/websocket/tests/hybi/echo"; | 25 "ws://localhost:8880/websocket/tests/hybi/echo"; |
26 | 26 |
27 const char kCloseServerURL[] = | 27 const char kCloseServerURL[] = |
(...skipping 18 matching lines...) Expand all Loading... |
46 const uint64_t kCloseFrameSize = 6; | 46 const uint64_t kCloseFrameSize = 6; |
47 const uint64_t kMessageFrameOverhead = 6; | 47 const uint64_t kMessageFrameOverhead = 6; |
48 | 48 |
49 REGISTER_TEST_CASE(WebSocket); | 49 REGISTER_TEST_CASE(WebSocket); |
50 | 50 |
51 bool TestWebSocket::Init() { | 51 bool TestWebSocket::Init() { |
52 websocket_interface_ = static_cast<const PPB_WebSocket_Dev*>( | 52 websocket_interface_ = static_cast<const PPB_WebSocket_Dev*>( |
53 pp::Module::Get()->GetBrowserInterface(PPB_WEBSOCKET_DEV_INTERFACE)); | 53 pp::Module::Get()->GetBrowserInterface(PPB_WEBSOCKET_DEV_INTERFACE)); |
54 var_interface_ = static_cast<const PPB_Var*>( | 54 var_interface_ = static_cast<const PPB_Var*>( |
55 pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE)); | 55 pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE)); |
56 arraybuffer_interface_ = static_cast<const PPB_VarArrayBuffer_Dev*>( | 56 arraybuffer_interface_ = static_cast<const PPB_VarArrayBuffer*>( |
57 pp::Module::Get()->GetBrowserInterface( | 57 pp::Module::Get()->GetBrowserInterface( |
58 PPB_VAR_ARRAY_BUFFER_DEV_INTERFACE)); | 58 PPB_VAR_ARRAY_BUFFER_INTERFACE)); |
59 core_interface_ = static_cast<const PPB_Core*>( | 59 core_interface_ = static_cast<const PPB_Core*>( |
60 pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE)); | 60 pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE)); |
61 if (!websocket_interface_ || !var_interface_ || !arraybuffer_interface_ || | 61 if (!websocket_interface_ || !var_interface_ || !arraybuffer_interface_ || |
62 !core_interface_) | 62 !core_interface_) |
63 return false; | 63 return false; |
64 | 64 |
65 return CheckTestingInterface(); | 65 return CheckTestingInterface(); |
66 } | 66 } |
67 | 67 |
68 void TestWebSocket::RunTests(const std::string& filter) { | 68 void TestWebSocket::RunTests(const std::string& filter) { |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); | 625 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); |
626 ASSERT_EQ(true, ws.GetCloseWasClean()); | 626 ASSERT_EQ(true, ws.GetCloseWasClean()); |
627 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); | 627 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); |
628 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); | 628 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); |
629 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, ws.GetReadyState()); | 629 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, ws.GetReadyState()); |
630 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); | 630 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); |
631 ASSERT_EQ(PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV, ws.GetBinaryType()); | 631 ASSERT_EQ(PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV, ws.GetBinaryType()); |
632 | 632 |
633 PASS(); | 633 PASS(); |
634 } | 634 } |
OLD | NEW |