summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_websocket.h
blob: 39775d87cae0b6fc9b70df04856c40887affdb90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PAPPI_TESTS_TEST_WEBSOCKET_H_
#define PAPPI_TESTS_TEST_WEBSOCKET_H_

#include <string>

#include "ppapi/c/ppb_core.h"
#include "ppapi/c/ppb_var.h"
#include "ppapi/c/ppb_var_array_buffer.h"
#include "ppapi/c/ppb_websocket.h"
#include "ppapi/tests/test_case.h"

class TestWebSocket : public TestCase {
 public:
  explicit TestWebSocket(TestingInstance* instance) : TestCase(instance) {}

 private:
  // TestCase implementation.
  virtual bool Init();
  virtual void RunTests(const std::string& filter);

  std::string GetFullURL(const char* url);
  PP_Var CreateVarString(const std::string& string);
  PP_Var CreateVarBinary(const std::vector<uint8_t>& binary);
  void ReleaseVar(const PP_Var& var);
  bool AreEqualWithString(const PP_Var& var, const std::string& string);
  bool AreEqualWithBinary(const PP_Var& var,
                          const std::vector<uint8_t>& binary);

  PP_Resource Connect(const std::string& url,
                      int32_t* result,
                      const std::string& protocol);

  std::string TestIsWebSocket();
  std::string TestUninitializedPropertiesAccess();
  std::string TestInvalidConnect();
  std::string TestProtocols();
  std::string TestGetURL();
  std::string TestValidConnect();
  std::string TestInvalidClose();
  std::string TestValidClose();
  std::string TestGetProtocol();
  std::string TestTextSendReceive();
  std::string TestBinarySendReceive();
  std::string TestStressedSendReceive();
  std::string TestBufferedAmount();
  std::string TestAbortCallsWithCallback();
  std::string TestAbortSendMessageCall();
  std::string TestAbortCloseCall();
  std::string TestAbortReceiveMessageCall();

  std::string TestCcInterfaces();

  std::string TestUtilityInvalidConnect();
  std::string TestUtilityProtocols();
  std::string TestUtilityGetURL();
  std::string TestUtilityValidConnect();
  std::string TestUtilityInvalidClose();
  std::string TestUtilityValidClose();
  std::string TestUtilityGetProtocol();
  std::string TestUtilityTextSendReceive();
  std::string TestUtilityBinarySendReceive();
  std::string TestUtilityBufferedAmount();

  // Keeps Pepper API interfaces. These are used by the tests that access the C
  // API directly.
  const PPB_WebSocket* websocket_interface_;
  const PPB_Var* var_interface_;
  const PPB_VarArrayBuffer* arraybuffer_interface_;
  const PPB_Core* core_interface_;
};

#endif  // PAPPI_TESTS_TEST_WEBSOCKET_H_