Chromium Code Reviews| 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*>( | |
|
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/.
| |
| 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"; | |
|
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
| |
| 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 |