Chromium Code Reviews| Index: ppapi/tests/test_websocket.cc |
| diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eb83f60fbb76067469a32b209a84e94e3296a777 |
| --- /dev/null |
| +++ b/ppapi/tests/test_websocket.cc |
| @@ -0,0 +1,44 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ppapi/tests/test_websocket.h" |
| + |
| +#include "ppapi/c/dev/ppb_websocket_dev.h" |
| +#include "ppapi/cpp/instance.h" |
| +#include "ppapi/cpp/module.h" |
| +#include "ppapi/tests/testing_instance.h" |
| + |
| +REGISTER_TEST_CASE(WebSocket); |
| + |
| +bool TestWebSocket::Init() { |
| + websocket_interface_ = reinterpret_cast<PPB_WebSocket_Dev const*>( |
|
dmichael (off chromium)
2011/11/18 16:22:21
static_cast (okay to do in next CL)
Takashi Toyoshima
2011/11/19 00:01:19
Fixed in http://codereview.chromium.org/8558017/.
|
| + pp::Module::Get()->GetBrowserInterface(PPB_WEBSOCKET_DEV_INTERFACE)); |
| + return !!websocket_interface_; |
| +} |
| + |
| +void TestWebSocket::RunTests(const std::string& filter) { |
| + instance_->LogTest("Create", TestCreate()); |
| + instance_->LogTest("IsWebSocket", TestIsWebSocket()); |
| +} |
| + |
| +std::string TestWebSocket::TestCreate() { |
| + PP_Resource rsrc = websocket_interface_->Create(instance_->pp_instance()); |
| + if (!rsrc) |
| + return "Could not create websocket via C interface"; |
|
dmichael (off chromium)
2011/11/18 16:22:21
For what it's worth, we usually just user the 'ASS
Takashi Toyoshima
2011/11/19 00:01:19
Also fixed in http://codereview.chromium.org/85580
|
| + |
| + PASS(); |
| +} |
| + |
| +std::string TestWebSocket::TestIsWebSocket() { |
| + // Test that a NULL resource isn't a websocket. |
| + pp::Resource null_resource; |
| + if (websocket_interface_->IsWebSocket(null_resource.pp_resource())) |
| + return "Null resource was reported as a valid websocket"; |
| + |
| + PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); |
| + if (!websocket_interface_->IsWebSocket(ws)) |
| + return "websocket was reported as an invalid websocket"; |
| + |
| + PASS(); |
| +} |