Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: ppapi/tests/test_websocket.cc

Issue 8571002: WebSocket Pepper API: in process API base implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unreleased WebKit feature depends Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698