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 PPAPI_TESTS_TEST_HOST_RESOLVER_H_ 6 #define PPAPI_TESTS_TEST_HOST_RESOLVER_H_ 7 8 #include <string> 9 10 #include "ppapi/c/ppb_host_resolver.h" 11 #include "ppapi/tests/test_case.h" 12 13 namespace pp { 14 class HostResolver; 15 class NetAddress; 16 class TCPSocket; 17 } // namespace pp 18 19 class TestHostResolver : public TestCase { 20 public: 21 explicit TestHostResolver(TestingInstance* instance); 22 23 // TestCase implementation. 24 virtual bool Init(); 25 virtual void RunTests(const std::string& filter); 26 27 private: 28 std::string SyncConnect(pp::TCPSocket* socket, 29 const pp::NetAddress& address); 30 std::string SyncRead(pp::TCPSocket* socket, 31 char* buffer, 32 int32_t num_bytes, 33 int32_t* bytes_read); 34 std::string SyncWrite(pp::TCPSocket* socket, 35 const char* buffer, 36 int32_t num_bytes, 37 int32_t* bytes_written); 38 std::string CheckHTTPResponse(pp::TCPSocket* socket, 39 const std::string& request, 40 const std::string& response); 41 std::string SyncResolve(pp::HostResolver* host_resolver, 42 const std::string& host, 43 uint16_t port, 44 const PP_HostResolver_Hint& hint); 45 std::string ParameterizedTestResolve(const PP_HostResolver_Hint& hint); 46 47 std::string TestEmpty(); 48 std::string TestResolve(); 49 std::string TestResolveIPv4(); 50 51 std::string host_; 52 uint16_t port_; 53 }; 54 55 #endif // PPAPI_TESTS_TEST_HOST_RESOLVER_H_ 56