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. namespace fuchsia {
  18. class ServiceDirectoryTestBase : public testing::Test {
  19. public:
  20. ServiceDirectoryTestBase();
  21. ~ServiceDirectoryTestBase() override;
  22. void VerifyTestInterface(fidl::InterfacePtr<testfidl::TestInterface>* stub,
  23. zx_status_t expected_error);
  24. protected:
  25. const test::ScopedRunLoopTimeout run_timeout_;
  26. base::test::SingleThreadTaskEnvironment task_environment_{
  27. base::test::SingleThreadTaskEnvironment::MainThreadType::IO};
  28. std::unique_ptr<sys::OutgoingDirectory> outgoing_directory_;
  29. TestInterfaceImpl test_service_;
  30. std::unique_ptr<ScopedServiceBinding<testfidl::TestInterface>>
  31. service_binding_;
  32. std::unique_ptr<sys::ServiceDirectory> public_service_directory_;
  33. std::unique_ptr<sys::ServiceDirectory> debug_service_directory_;
  34. std::unique_ptr<sys::ServiceDirectory> root_service_directory_;
  35. DISALLOW_COPY_AND_ASSIGN(ServiceDirectoryTestBase);
  36. };
  37. } // namespace fuchsia
  38. } // namespace base
  39. #endif // BASE_FUCHSIA_SERVICE_DIRECTORY_TEST_BASE_H_