service_directory_test_base.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef BASE_FUCHSIA_SERVICE_DIRECTORY_TEST_BASE_H_
  5. #define BASE_FUCHSIA_SERVICE_DIRECTORY_TEST_BASE_H_
  6. #include <lib/sys/cpp/outgoing_directory.h>
  7. #include <lib/sys/cpp/service_directory.h>
  8. #include <zircon/types.h>
  9. #include <memory>
  10. #include "base/fuchsia/scoped_service_binding.h"
  11. #include "base/fuchsia/test_interface_impl.h"
  12. #include "base/test/scoped_run_loop_timeout.h"
  13. #include "base/test/task_environment.h"
  14. #include "base/testfidl/cpp/fidl.h"
  15. #include "testing/gtest/include/gtest/gtest.h"
  16. namespace base {
  17. class ServiceDirectoryTestBase : public testing::Test {
  18. public:
  19. ServiceDirectoryTestBase();
  20. ServiceDirectoryTestBase(const ServiceDirectoryTestBase&) = delete;
  21. ServiceDirectoryTestBase& operator=(const ServiceDirectoryTestBase&) = delete;
  22. ~ServiceDirectoryTestBase() override;
  23. void VerifyTestInterface(fidl::InterfacePtr<testfidl::TestInterface>* stub,
  24. zx_status_t expected_error);
  25. protected:
  26. const test::ScopedRunLoopTimeout run_timeout_;
  27. base::test::SingleThreadTaskEnvironment task_environment_{
  28. base::test::SingleThreadTaskEnvironment::MainThreadType::IO};
  29. std::unique_ptr<sys::OutgoingDirectory> outgoing_directory_;
  30. TestInterfaceImpl test_service_;
  31. std::unique_ptr<ScopedServiceBinding<testfidl::TestInterface>>
  32. service_binding_;
  33. std::shared_ptr<sys::ServiceDirectory> public_service_directory_;
  34. std::unique_ptr<sys::ServiceDirectory> debug_service_directory_;
  35. std::unique_ptr<sys::ServiceDirectory> root_service_directory_;
  36. };
  37. } // namespace base
  38. #endif // BASE_FUCHSIA_SERVICE_DIRECTORY_TEST_BASE_H_