fake_host_extension.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2014 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 REMOTING_HOST_FAKE_HOST_EXTENSION_H_
  5. #define REMOTING_HOST_FAKE_HOST_EXTENSION_H_
  6. #include <string>
  7. #include "remoting/host/host_extension.h"
  8. namespace remoting {
  9. class ClientSessionDetails;
  10. class HostExtensionSession;
  11. namespace protocol {
  12. class ClientStub;
  13. }
  14. // |HostExtension| implementation that can report a specified capability, and
  15. // reports messages matching a specified type as having been handled.
  16. class FakeExtension : public HostExtension {
  17. public:
  18. FakeExtension(const std::string& message_type,
  19. const std::string& capability);
  20. FakeExtension(const FakeExtension&) = delete;
  21. FakeExtension& operator=(const FakeExtension&) = delete;
  22. ~FakeExtension() override;
  23. // HostExtension interface.
  24. std::string capability() const override;
  25. std::unique_ptr<HostExtensionSession> CreateExtensionSession(
  26. ClientSessionDetails* client_session_details,
  27. protocol::ClientStub* client_stub) override;
  28. // Accessors for testing.
  29. bool has_handled_message() const { return has_handled_message_; }
  30. bool was_instantiated() const { return was_instantiated_; }
  31. private:
  32. class Session;
  33. friend class Session;
  34. // The type name of extension messages that this fake consumes.
  35. std::string message_type_;
  36. // The capability this fake reports, and requires clients to support, if any.
  37. std::string capability_;
  38. // True if a message of |message_type_| has been processed by this extension.
  39. bool has_handled_message_ = false;
  40. // True if CreateExtensionSession() was called on this extension.
  41. bool was_instantiated_ = false;
  42. };
  43. } // namespace remoting
  44. #endif // REMOTING_HOST_FAKE_HOST_EXTENSION_H_