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 #ifndef PPAPI_TESTS_TEST_WEBSOCKET_H_
      6 #define PPAPI_TESTS_TEST_WEBSOCKET_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "ppapi/c/ppb_core.h"
     12 #include "ppapi/c/ppb_var.h"
     13 #include "ppapi/c/ppb_var_array_buffer.h"
     14 #include "ppapi/c/ppb_websocket.h"
     15 #include "ppapi/tests/test_case.h"
     16 
     17 class TestWebSocket : public TestCase {
     18  public:
     19   explicit TestWebSocket(TestingInstance* instance) : TestCase(instance) {}
     20 
     21  private:
     22   // TestCase implementation.
     23   virtual bool Init();
     24   virtual void RunTests(const std::string& filter);
     25 
     26   std::string GetFullURL(const char* url);
     27   PP_Var CreateVarString(const std::string& string);
     28   PP_Var CreateVarBinary(const std::vector<uint8_t>& binary);
     29   void ReleaseVar(const PP_Var& var);
     30   bool AreEqualWithString(const PP_Var& var, const std::string& string);
     31   bool AreEqualWithBinary(const PP_Var& var,
     32                           const std::vector<uint8_t>& binary);
     33 
     34   PP_Resource Connect(const std::string& url,
     35                       int32_t* result,
     36                       const std::string& protocol);
     37 
     38   void Send(int32_t result, PP_Resource ws, const std::string& message);
     39 
     40   std::string TestIsWebSocket();
     41   std::string TestUninitializedPropertiesAccess();
     42   std::string TestInvalidConnect();
     43   std::string TestProtocols();
     44   std::string TestGetURL();
     45   std::string TestValidConnect();
     46   std::string TestInvalidClose();
     47   std::string TestValidClose();
     48   std::string TestGetProtocol();
     49   std::string TestTextSendReceive();
     50   std::string TestTextSendReceiveTwice();
     51   std::string TestBinarySendReceive();
     52   std::string TestStressedSendReceive();
     53   std::string TestBufferedAmount();
     54   std::string TestAbortCallsWithCallback();
     55   std::string TestAbortSendMessageCall();
     56   std::string TestAbortCloseCall();
     57   std::string TestAbortReceiveMessageCall();
     58 
     59   std::string TestCcInterfaces();
     60 
     61   std::string TestUtilityInvalidConnect();
     62   std::string TestUtilityProtocols();
     63   std::string TestUtilityGetURL();
     64   std::string TestUtilityValidConnect();
     65   std::string TestUtilityInvalidClose();
     66   std::string TestUtilityValidClose();
     67   std::string TestUtilityGetProtocol();
     68   std::string TestUtilityTextSendReceive();
     69   std::string TestUtilityBinarySendReceive();
     70   std::string TestUtilityBufferedAmount();
     71 
     72   // Keeps Pepper API interfaces. These are used by the tests that access the C
     73   // API directly.
     74   const PPB_WebSocket* websocket_interface_;
     75   const PPB_Var* var_interface_;
     76   const PPB_VarArrayBuffer* arraybuffer_interface_;
     77   const PPB_Core* core_interface_;
     78 };
     79 
     80 #endif  // PPAPI_TESTS_TEST_WEBSOCKET_H_
     81