test_host_resolver.h 1.7 KB

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