test_tcp_socket_private_crash.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2018 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. #include "ppapi/tests/test_tcp_socket_private_crash.h"
  5. #include <stddef.h>
  6. #include <stdlib.h>
  7. #include <new>
  8. #include "ppapi/cpp/private/tcp_socket_private.h"
  9. #include "ppapi/tests/test_utils.h"
  10. #include "ppapi/tests/testing_instance.h"
  11. REGISTER_TEST_CASE(TCPSocketPrivateCrash);
  12. TestTCPSocketPrivateCrash::TestTCPSocketPrivateCrash(TestingInstance* instance)
  13. : TestCase(instance) {}
  14. bool TestTCPSocketPrivateCrash::Init() {
  15. return pp::TCPSocketPrivate::IsAvailable();
  16. }
  17. void TestTCPSocketPrivateCrash::RunTests(const std::string& filter) {
  18. // No need to run this test with the various callback types since that's
  19. // orthogonal from the functionality being tested. It would also make the
  20. // test more complicated because it would have to keep watching the network
  21. // process restart and telling it to crash again on crash.com.
  22. RUN_TEST(Resolve, filter);
  23. }
  24. std::string TestTCPSocketPrivateCrash::TestResolve() {
  25. pp::TCPSocketPrivate socket(instance_);
  26. TestCompletionCallback cb(instance_->pp_instance(), callback_type());
  27. std::string host("crash.com");
  28. cb.WaitForResult(socket.Connect(host.c_str(), 80, cb.GetCallback()));
  29. ASSERT_EQ(PP_ERROR_FAILED, cb.result());
  30. socket.Disconnect();
  31. PASS();
  32. }