fake_tpm_manager_client.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2020 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 CHROMEOS_DBUS_TPM_MANAGER_FAKE_TPM_MANAGER_CLIENT_H_
  5. #define CHROMEOS_DBUS_TPM_MANAGER_FAKE_TPM_MANAGER_CLIENT_H_
  6. #include "chromeos/dbus/tpm_manager/tpm_manager_client.h"
  7. #include "base/component_export.h"
  8. #include "base/observer_list.h"
  9. #include "chromeos/dbus/tpm_manager/tpm_manager.pb.h"
  10. namespace chromeos {
  11. class COMPONENT_EXPORT(CHROMEOS_DBUS_TPM_MANAGER) FakeTpmManagerClient
  12. : public TpmManagerClient,
  13. public TpmManagerClient::TestInterface {
  14. public:
  15. FakeTpmManagerClient();
  16. ~FakeTpmManagerClient() override;
  17. // Not copyable or movable.
  18. FakeTpmManagerClient(const FakeTpmManagerClient&) = delete;
  19. FakeTpmManagerClient& operator=(const FakeTpmManagerClient&) = delete;
  20. FakeTpmManagerClient(FakeTpmManagerClient&&) = delete;
  21. FakeTpmManagerClient& operator=(FakeTpmManagerClient&&) = delete;
  22. // TpmManagerClient:
  23. void GetTpmNonsensitiveStatus(
  24. const ::tpm_manager::GetTpmNonsensitiveStatusRequest& request,
  25. GetTpmNonsensitiveStatusCallback callback) override;
  26. void GetVersionInfo(const ::tpm_manager::GetVersionInfoRequest& request,
  27. GetVersionInfoCallback callback) override;
  28. void GetSupportedFeatures(
  29. const ::tpm_manager::GetSupportedFeaturesRequest& request,
  30. GetSupportedFeaturesCallback callback) override;
  31. void GetDictionaryAttackInfo(
  32. const ::tpm_manager::GetDictionaryAttackInfoRequest& request,
  33. GetDictionaryAttackInfoCallback callback) override;
  34. void TakeOwnership(const ::tpm_manager::TakeOwnershipRequest& request,
  35. TakeOwnershipCallback callback) override;
  36. void ClearStoredOwnerPassword(
  37. const ::tpm_manager::ClearStoredOwnerPasswordRequest& request,
  38. ClearStoredOwnerPasswordCallback callback) override;
  39. void AddObserver(Observer* observer) override;
  40. void RemoveObserver(Observer* observer) override;
  41. TpmManagerClient::TestInterface* GetTestInterface() override;
  42. // TpmManagerClient::TestInterface:
  43. ::tpm_manager::GetTpmNonsensitiveStatusReply*
  44. mutable_nonsensitive_status_reply() override;
  45. void set_non_nonsensitive_status_dbus_error_count(int count) override;
  46. ::tpm_manager::GetVersionInfoReply* mutable_version_info_reply() override;
  47. ::tpm_manager::GetSupportedFeaturesReply* mutable_supported_features_reply()
  48. override;
  49. ::tpm_manager::GetDictionaryAttackInfoReply*
  50. mutable_dictionary_attack_info_reply() override;
  51. int take_ownership_count() const override;
  52. int clear_stored_owner_password_count() const override;
  53. void EmitOwnershipTakenSignal() override;
  54. private:
  55. ::tpm_manager::GetTpmNonsensitiveStatusReply nonsensitive_status_reply_;
  56. int nonsensitive_status_dbus_error_count_ = 0;
  57. ::tpm_manager::GetVersionInfoReply version_info_reply_;
  58. ::tpm_manager::GetSupportedFeaturesReply supported_features_reply_;
  59. ::tpm_manager::GetDictionaryAttackInfoReply dictionary_attack_info_reply_;
  60. int take_ownership_count_ = 0;
  61. int clear_stored_owner_password_count_ = 0;
  62. // The observer list of ownership taken signal.
  63. base::ObserverList<Observer> observer_list_;
  64. };
  65. } // namespace chromeos
  66. #endif // CHROMEOS_DBUS_TPM_MANAGER_FAKE_TPM_MANAGER_CLIENT_H_