Home | History | Annotate | Download | only in tests
      1 // Copyright 2013 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 #ifndef PAPPI_TESTS_TEST_TCP_SOCKET_H_
      6 #define PAPPI_TESTS_TEST_TCP_SOCKET_H_
      7 
      8 #include <string>
      9 
     10 #include "ppapi/c/pp_stdint.h"
     11 #include "ppapi/c/ppb_tcp_socket.h"
     12 #include "ppapi/cpp/net_address.h"
     13 #include "ppapi/tests/test_case.h"
     14 
     15 namespace pp {
     16 class TCPSocket;
     17 }
     18 
     19 class TestTCPSocket: public TestCase {
     20  public:
     21   explicit TestTCPSocket(TestingInstance* instance);
     22 
     23   // TestCase implementation.
     24   virtual bool Init();
     25   virtual void RunTests(const std::string& filter);
     26 
     27  private:
     28   std::string TestConnect();
     29   std::string TestReadWrite();
     30   std::string TestSetOption();
     31   std::string TestListen();
     32   std::string TestBacklog();
     33   std::string TestInterface_1_0();
     34 
     35   std::string ReadFirstLineFromSocket(pp::TCPSocket* socket, std::string* s);
     36   std::string ReadFirstLineFromSocket_1_0(PP_Resource socket,
     37                                           std::string* s);
     38   std::string ReadFromSocket(pp::TCPSocket* socket,
     39                              char* buffer,
     40                              size_t num_bytes);
     41   std::string WriteToSocket(pp::TCPSocket* socket, const std::string& s);
     42   std::string WriteToSocket_1_0(PP_Resource socket, const std::string& s);
     43 
     44   std::string GetAddressToBind(pp::NetAddress* address);
     45   std::string StartListen(pp::TCPSocket* socket, int32_t backlog);
     46 
     47   pp::NetAddress addr_;
     48 
     49   const PPB_TCPSocket_1_0* socket_interface_1_0_;
     50 };
     51 
     52 #endif  // PAPPI_TESTS_TEST_TCP_SOCKET_H_
     53