fake_host_status_observer.h 1.6 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 ASH_SERVICES_MULTIDEVICE_SETUP_FAKE_HOST_STATUS_OBSERVER_H_
  5. #define ASH_SERVICES_MULTIDEVICE_SETUP_FAKE_HOST_STATUS_OBSERVER_H_
  6. #include "ash/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
  7. #include "mojo/public/cpp/bindings/pending_remote.h"
  8. #include "mojo/public/cpp/bindings/receiver_set.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. namespace ash {
  11. namespace multidevice_setup {
  12. // Fake mojom::HostStatusObserver implementation for tests.
  13. class FakeHostStatusObserver : public mojom::HostStatusObserver {
  14. public:
  15. FakeHostStatusObserver();
  16. FakeHostStatusObserver(const FakeHostStatusObserver&) = delete;
  17. FakeHostStatusObserver& operator=(const FakeHostStatusObserver&) = delete;
  18. ~FakeHostStatusObserver() override;
  19. mojo::PendingRemote<mojom::HostStatusObserver> GenerateRemote();
  20. const std::vector<
  21. std::pair<mojom::HostStatus, absl::optional<multidevice::RemoteDevice>>>&
  22. host_status_updates() const {
  23. return host_status_updates_;
  24. }
  25. private:
  26. // mojom::HostStatusObserver:
  27. void OnHostStatusChanged(
  28. mojom::HostStatus host_status,
  29. const absl::optional<multidevice::RemoteDevice>& host_device) override;
  30. std::vector<
  31. std::pair<mojom::HostStatus, absl::optional<multidevice::RemoteDevice>>>
  32. host_status_updates_;
  33. mojo::ReceiverSet<mojom::HostStatusObserver> receivers_;
  34. };
  35. } // namespace multidevice_setup
  36. } // namespace ash
  37. #endif // ASH_SERVICES_MULTIDEVICE_SETUP_FAKE_HOST_STATUS_OBSERVER_H_