test_host_resolver_crash.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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_host_resolver_crash.h"
  5. #include <stddef.h>
  6. #include "ppapi/cpp/host_resolver.h"
  7. #include "ppapi/tests/test_utils.h"
  8. #include "ppapi/tests/testing_instance.h"
  9. REGISTER_TEST_CASE(HostResolverCrash);
  10. TestHostResolverCrash::TestHostResolverCrash(TestingInstance* instance)
  11. : TestCase(instance) {}
  12. bool TestHostResolverCrash::Init() {
  13. return pp::HostResolver::IsAvailable();
  14. }
  15. void TestHostResolverCrash::RunTests(const std::string& filter) {
  16. // No need to run this test with the various callback types since that's
  17. // orthogonal from the functionality being tested. It would also make the
  18. // test more complicated because it would have to keep watching the network
  19. // process restart and telling it to crash again on crash.com.
  20. RUN_TEST(Basic, filter);
  21. }
  22. std::string TestHostResolverCrash::TestBasic() {
  23. pp::HostResolver host_resolver(instance_);
  24. PP_HostResolver_Hint hint;
  25. hint.family = PP_NETADDRESS_FAMILY_UNSPECIFIED;
  26. hint.flags = PP_HOSTRESOLVER_FLAG_CANONNAME;
  27. TestCompletionCallback callback(instance_->pp_instance(), callback_type());
  28. std::string host("crash.com");
  29. callback.WaitForResult(
  30. host_resolver.Resolve(host.c_str(), 80, hint, callback.GetCallback()));
  31. ASSERT_EQ(PP_ERROR_FAILED, callback.result());
  32. PASS();
  33. }