OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ppapi/tests/test_websocket.h" |
| 6 |
| 7 #include "ppapi/c/dev/ppb_websocket_dev.h" |
| 8 #include "ppapi/cpp/instance.h" |
| 9 #include "ppapi/cpp/module.h" |
| 10 #include "ppapi/tests/testing_instance.h" |
| 11 |
| 12 REGISTER_TEST_CASE(WebSocket); |
| 13 |
| 14 bool TestWebSocket::Init() { |
| 15 websocket_interface_ = reinterpret_cast<PPB_WebSocket_Dev const*>( |
| 16 pp::Module::Get()->GetBrowserInterface(PPB_WEBSOCKET_DEV_INTERFACE)); |
| 17 return !!websocket_interface_; |
| 18 } |
| 19 |
| 20 void TestWebSocket::RunTests(const std::string& filter) { |
| 21 instance_->LogTest("Create", TestCreate()); |
| 22 instance_->LogTest("IsWebSocket", TestIsWebSocket()); |
| 23 } |
| 24 |
| 25 std::string TestWebSocket::TestCreate() { |
| 26 PP_Resource rsrc = websocket_interface_->Create(instance_->pp_instance()); |
| 27 if (!rsrc) |
| 28 return "Could not create websocket via C interface"; |
| 29 |
| 30 PASS(); |
| 31 } |
| 32 |
| 33 std::string TestWebSocket::TestIsWebSocket() { |
| 34 // Test that a NULL resource isn't a websocket. |
| 35 pp::Resource null_resource; |
| 36 if (websocket_interface_->IsWebSocket(null_resource.pp_resource())) |
| 37 return "Null resource was reported as a valid websocket"; |
| 38 |
| 39 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); |
| 40 if (!websocket_interface_->IsWebSocket(ws)) |
| 41 return "websocket was reported as an invalid websocket"; |
| 42 |
| 43 PASS(); |
| 44 } |
OLD | NEW |