Add support for multicast in PPB_UDPSocket API
[chromium-blink-merge.git] / ppapi / tests / test_udp_socket.h
blobee3e6722aeae323b38f2112045ed052f3f2a12c1
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.
5 #ifndef PPAPI_TESTS_TEST_UDP_SOCKET_H_
6 #define PPAPI_TESTS_TEST_UDP_SOCKET_H_
8 #include <string>
10 #include "ppapi/c/pp_stdint.h"
11 #include "ppapi/c/ppb_udp_socket.h"
12 #include "ppapi/cpp/net_address.h"
13 #include "ppapi/tests/test_case.h"
15 namespace {
16 typedef int32_t (*UDPSocketSetOption)(PP_Resource udp_socket,
17 PP_UDPSocket_Option name,
18 struct PP_Var value,
19 struct PP_CompletionCallback callback);
22 namespace pp {
23 class UDPSocket;
26 class TestUDPSocket: public TestCase {
27 public:
28 explicit TestUDPSocket(TestingInstance* instance);
30 // TestCase implementation.
31 virtual bool Init();
32 virtual void RunTests(const std::string& filter);
34 private:
35 std::string GetLocalAddress(pp::NetAddress* address);
36 std::string SetBroadcastOptions(pp::UDPSocket* socket);
37 std::string BindUDPSocket(pp::UDPSocket* socket,
38 const pp::NetAddress& address);
39 std::string LookupPortAndBindUDPSocket(pp::UDPSocket* socket,
40 pp::NetAddress* address);
41 std::string ReadSocket(pp::UDPSocket* socket,
42 pp::NetAddress* address,
43 size_t size,
44 std::string* message);
45 std::string PassMessage(pp::UDPSocket* target,
46 pp::UDPSocket* source,
47 const pp::NetAddress& target_address,
48 const std::string& message,
49 pp::NetAddress* recvfrom_address);
50 std::string SetMulticastOptions(pp::UDPSocket* socket);
52 std::string TestReadWrite();
53 std::string TestBroadcast();
54 int32_t SetOptionValue(UDPSocketSetOption func,
55 PP_Resource socket,
56 PP_UDPSocket_Option option,
57 const PP_Var& value);
58 std::string TestSetOption_1_0();
59 std::string TestSetOption_1_1();
60 std::string TestSetOption();
61 std::string TestParallelSend();
62 std::string TestMulticast();
64 pp::NetAddress address_;
66 const PPB_UDPSocket_1_0* socket_interface_1_0_;
67 const PPB_UDPSocket_1_1* socket_interface_1_1_;
70 #endif // PPAPI_TESTS_TEST_UDP_SOCKET_H_