Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 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" | 11 #include "ppapi/c/dev/ppb_var_array_buffer_dev.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 core_interface_ = static_cast<const PPB_Core*>( | 55 core_interface_ = static_cast<const PPB_Core*>( |
| 56 pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE)); | 56 pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE)); |
| 57 if (!websocket_interface_ || !var_interface_ || !arraybuffer_interface_ || | 57 if (!websocket_interface_ || !var_interface_ || !arraybuffer_interface_ || |
| 58 !core_interface_) | 58 !core_interface_) |
| 59 return false; | 59 return false; |
| 60 | 60 |
| 61 return CheckTestingInterface(); | 61 return CheckTestingInterface(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void TestWebSocket::RunTests(const std::string& filter) { | 64 void TestWebSocket::RunTests(const std::string& filter) { |
| 65 RUN_TEST_WITH_REFERENCE_CHECK(Interface_0_1, filter); | |
| 65 RUN_TEST_WITH_REFERENCE_CHECK(IsWebSocket, filter); | 66 RUN_TEST_WITH_REFERENCE_CHECK(IsWebSocket, filter); |
| 66 RUN_TEST_WITH_REFERENCE_CHECK(UninitializedPropertiesAccess, filter); | 67 RUN_TEST_WITH_REFERENCE_CHECK(UninitializedPropertiesAccess, filter); |
| 67 RUN_TEST_WITH_REFERENCE_CHECK(InvalidConnect, filter); | 68 RUN_TEST_WITH_REFERENCE_CHECK(InvalidConnect, filter); |
| 68 RUN_TEST_WITH_REFERENCE_CHECK(Protocols, filter); | 69 RUN_TEST_WITH_REFERENCE_CHECK(Protocols, filter); |
| 69 RUN_TEST_WITH_REFERENCE_CHECK(GetURL, filter); | 70 RUN_TEST_WITH_REFERENCE_CHECK(GetURL, filter); |
| 70 RUN_TEST_WITH_REFERENCE_CHECK(ValidConnect, filter); | 71 RUN_TEST_WITH_REFERENCE_CHECK(ValidConnect, filter); |
| 71 RUN_TEST_WITH_REFERENCE_CHECK(InvalidClose, filter); | 72 RUN_TEST_WITH_REFERENCE_CHECK(InvalidClose, filter); |
| 72 RUN_TEST_WITH_REFERENCE_CHECK(ValidClose, filter); | 73 RUN_TEST_WITH_REFERENCE_CHECK(ValidClose, filter); |
| 73 RUN_TEST_WITH_REFERENCE_CHECK(GetProtocol, filter); | 74 RUN_TEST_WITH_REFERENCE_CHECK(GetProtocol, filter); |
| 74 RUN_TEST_WITH_REFERENCE_CHECK(TextSendReceive, filter); | 75 RUN_TEST_WITH_REFERENCE_CHECK(TextSendReceive, filter); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 ws, url_var, protocols, protocol_count, | 133 ws, url_var, protocols, protocol_count, |
| 133 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); | 134 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); |
| 134 ReleaseVar(url_var); | 135 ReleaseVar(url_var); |
| 135 if (protocol) | 136 if (protocol) |
| 136 ReleaseVar(protocols[0]); | 137 ReleaseVar(protocols[0]); |
| 137 if (*result == PP_OK_COMPLETIONPENDING) | 138 if (*result == PP_OK_COMPLETIONPENDING) |
| 138 *result = callback.WaitForResult(); | 139 *result = callback.WaitForResult(); |
| 139 return ws; | 140 return ws; |
| 140 } | 141 } |
| 141 | 142 |
| 143 std::string TestWebSocket::TestInterface_0_1() { | |
| 144 const PPB_WebSocket_Dev_0_1* interface = | |
| 145 static_cast<const PPB_WebSocket_Dev_0_1*>( | |
| 146 pp::Module::Get()->GetBrowserInterface(PPB_WEBSOCKET_DEV_INTERFACE)); | |
|
dmichael (off chromium)
2012/01/11 04:53:41
I don't think you really need to support backwards
Takashi Toyoshima
2012/01/11 05:25:49
OK, I remove this test.
| |
| 147 ASSERT_TRUE(interface); | |
| 148 PASS(); | |
| 149 } | |
| 150 | |
| 142 std::string TestWebSocket::TestIsWebSocket() { | 151 std::string TestWebSocket::TestIsWebSocket() { |
| 143 // Test that a NULL resource isn't a websocket. | 152 // Test that a NULL resource isn't a websocket. |
| 144 pp::Resource null_resource; | 153 pp::Resource null_resource; |
| 145 PP_Bool result = | 154 PP_Bool result = |
| 146 websocket_interface_->IsWebSocket(null_resource.pp_resource()); | 155 websocket_interface_->IsWebSocket(null_resource.pp_resource()); |
| 147 ASSERT_FALSE(result); | 156 ASSERT_FALSE(result); |
| 148 | 157 |
| 149 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); | 158 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); |
| 150 ASSERT_TRUE(ws); | 159 ASSERT_TRUE(ws); |
| 151 | 160 |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 ASSERT_EQ(kCloseCodeNormalClosure, ws.GetCloseCode()); | 558 ASSERT_EQ(kCloseCodeNormalClosure, ws.GetCloseCode()); |
| 550 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); | 559 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); |
| 551 ASSERT_EQ(true, ws.GetCloseWasClean()); | 560 ASSERT_EQ(true, ws.GetCloseWasClean()); |
| 552 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); | 561 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); |
| 553 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); | 562 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); |
| 554 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, ws.GetReadyState()); | 563 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, ws.GetReadyState()); |
| 555 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); | 564 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); |
| 556 | 565 |
| 557 PASS(); | 566 PASS(); |
| 558 } | 567 } |
| OLD | NEW |