summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_udp_socket.h
blob: 7c8721ee20c81efa4f2ba0b299c4f7cb5cbc0fcc (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
// Copyright 2013 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 PPAPI_TESTS_TEST_UDP_SOCKET_H_
#define PPAPI_TESTS_TEST_UDP_SOCKET_H_

#include <string>

#include "ppapi/c/pp_stdint.h"
#include "ppapi/cpp/net_address.h"
#include "ppapi/tests/test_case.h"

namespace pp {
class UDPSocket;
}

class TestUDPSocket: public TestCase {
 public:
  explicit TestUDPSocket(TestingInstance* instance);

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

 private:
  std::string GetLocalAddress(pp::NetAddress* address);
  std::string SetBroadcastOptions(pp::UDPSocket* socket);
  std::string BindUDPSocket(pp::UDPSocket* socket,
                            const pp::NetAddress& address);
  std::string LookupPortAndBindUDPSocket(pp::UDPSocket* socket,
                                         pp::NetAddress* address);
  std::string ReadSocket(pp::UDPSocket* socket,
                         pp::NetAddress* address,
                         size_t size,
                         std::string* message);
  std::string PassMessage(pp::UDPSocket* target,
                          pp::UDPSocket* source,
                          const pp::NetAddress& target_address,
                          const std::string& message,
                          pp::NetAddress* recvfrom_address);

  std::string TestReadWrite();
  std::string TestBroadcast();
  std::string TestSetOption();

  pp::NetAddress address_;
};

#endif  // PPAPI_TESTS_TEST_UDP_SOCKET_H_