Home | History | Annotate | Download | only in tests
      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
      3 // found in the LICENSE file.
      4 
      5 #include "ppapi/tests/test_tcp_socket_private_disallowed.h"
      6 
      7 #include "ppapi/cpp/module.h"
      8 #include "ppapi/tests/test_utils.h"
      9 #include "ppapi/tests/testing_instance.h"
     10 
     11 namespace {
     12 
     13 const char kServerName[] = "www.google.com";
     14 const int kPort = 80;
     15 
     16 }
     17 
     18 REGISTER_TEST_CASE(TCPSocketPrivateDisallowed);
     19 
     20 TestTCPSocketPrivateDisallowed::TestTCPSocketPrivateDisallowed(
     21     TestingInstance* instance)
     22     : TestCase(instance), tcp_socket_private_interface_(NULL) {
     23 }
     24 
     25 bool TestTCPSocketPrivateDisallowed::Init() {
     26   tcp_socket_private_interface_ = static_cast<const PPB_TCPSocket_Private*>(
     27       pp::Module::Get()->GetBrowserInterface(PPB_TCPSOCKET_PRIVATE_INTERFACE));
     28   if (!tcp_socket_private_interface_)
     29     instance_->AppendError("TCPSocketPrivate interface not available");
     30   return tcp_socket_private_interface_ && CheckTestingInterface();
     31 }
     32 
     33 void TestTCPSocketPrivateDisallowed::RunTests(const std::string& filter) {
     34   RUN_TEST(Connect, filter);
     35 }
     36 
     37 std::string TestTCPSocketPrivateDisallowed::TestConnect() {
     38   PP_Resource socket =
     39       tcp_socket_private_interface_->Create(instance_->pp_instance());
     40   if (0 != socket) {
     41     TestCompletionCallback callback(instance_->pp_instance());
     42     callback.WaitForResult(tcp_socket_private_interface_->Connect(
     43         socket, kServerName, kPort,
     44         callback.GetCallback().pp_completion_callback()));
     45     CHECK_CALLBACK_BEHAVIOR(callback);
     46     ASSERT_EQ(PP_ERROR_FAILED, callback.result());
     47   }
     48   PASS();
     49 }
     50