mock_login_screen_client.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // Copyright 2017 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_LOGIN_MOCK_LOGIN_SCREEN_CLIENT_H_
  5. #define ASH_LOGIN_MOCK_LOGIN_SCREEN_CLIENT_H_
  6. #include "ash/public/cpp/child_accounts/parent_access_controller.h"
  7. #include "ash/public/cpp/login_screen_client.h"
  8. #include "base/time/time.h"
  9. #include "components/password_manager/core/browser/hash_password_manager.h"
  10. #include "testing/gmock/include/gmock/gmock.h"
  11. namespace ash {
  12. class MockLoginScreenClient : public LoginScreenClient {
  13. public:
  14. MockLoginScreenClient();
  15. MockLoginScreenClient(const MockLoginScreenClient&) = delete;
  16. MockLoginScreenClient& operator=(const MockLoginScreenClient&) = delete;
  17. ~MockLoginScreenClient() override;
  18. MOCK_METHOD(void,
  19. AuthenticateUserWithPasswordOrPin_,
  20. (const AccountId& account_id,
  21. const std::string& password,
  22. bool authenticated_by_pin,
  23. base::OnceCallback<void(bool)>& callback));
  24. MOCK_METHOD(void,
  25. AuthenticateUserWithChallengeResponse_,
  26. (const AccountId& account_id,
  27. base::OnceCallback<void(bool)>& callback));
  28. MOCK_METHOD(ParentCodeValidationResult,
  29. ValidateParentAccessCode_,
  30. (const AccountId& account_id,
  31. const std::string& access_code,
  32. base::Time validation_time));
  33. // Set the result that should be passed to |callback| in
  34. // |AuthenticateUserWithPasswordOrPin|.
  35. void set_authenticate_user_callback_result(bool value) {
  36. authenticate_user_callback_result_ = value;
  37. }
  38. // Sets the result that should be passed to |callback| in
  39. // |ValidateParentAccessCode|.
  40. void set_validate_parent_access_code_result(
  41. ParentCodeValidationResult value) {
  42. validate_parent_access_code_result_ = value;
  43. }
  44. // If set to non-null, when |AuthenticateUser| is called the callback will be
  45. // stored in |storage| instead of being executed.
  46. void set_authenticate_user_with_password_or_pin_callback_storage(
  47. base::OnceCallback<void(bool)>* storage) {
  48. authenticate_user_with_password_or_pin_callback_storage_ = storage;
  49. }
  50. // LoginScreenClient:
  51. void AuthenticateUserWithPasswordOrPin(
  52. const AccountId& account_id,
  53. const std::string& password,
  54. bool authenticated_by_pin,
  55. base::OnceCallback<void(bool)> callback) override;
  56. void AuthenticateUserWithChallengeResponse(
  57. const AccountId& account_id,
  58. base::OnceCallback<void(bool)> callback) override;
  59. ParentCodeValidationResult ValidateParentAccessCode(
  60. const AccountId& account_id,
  61. const std::string& code,
  62. base::Time validation_time) override;
  63. MOCK_METHOD(void,
  64. AuthenticateUserWithEasyUnlock,
  65. (const AccountId& account_id),
  66. (override));
  67. MOCK_METHOD(void, HardlockPod, (const AccountId& account_id), (override));
  68. MOCK_METHOD(void, OnFocusPod, (const AccountId& account_id), (override));
  69. MOCK_METHOD(void, OnNoPodFocused, (), (override));
  70. MOCK_METHOD(void, LoadWallpaper, (const AccountId& account_id), (override));
  71. MOCK_METHOD(void, SignOutUser, (), (override));
  72. MOCK_METHOD(void, CancelAddUser, (), (override));
  73. MOCK_METHOD(void, LoginAsGuest, (), (override));
  74. MOCK_METHOD(void, ShowGuestTosScreen, (), (override));
  75. MOCK_METHOD(void,
  76. OnMaxIncorrectPasswordAttempted,
  77. (const AccountId& account_id),
  78. (override));
  79. MOCK_METHOD(void, FocusLockScreenApps, (bool reverse), (override));
  80. MOCK_METHOD(void,
  81. ShowGaiaSignin,
  82. (const AccountId& prefilled_account),
  83. (override));
  84. MOCK_METHOD(void, ShowOsInstallScreen, (), (override));
  85. MOCK_METHOD(void, OnRemoveUserWarningShown, (), (override));
  86. MOCK_METHOD(void, RemoveUser, (const AccountId& account_id), (override));
  87. MOCK_METHOD(void,
  88. LaunchPublicSession,
  89. (const AccountId& account_id,
  90. const std::string& locale,
  91. const std::string& input_method),
  92. (override));
  93. MOCK_METHOD(void,
  94. RequestPublicSessionKeyboardLayouts,
  95. (const AccountId& account_id, const std::string& locale),
  96. (override));
  97. MOCK_METHOD(void,
  98. HandleAccelerator,
  99. (ash::LoginAcceleratorAction action),
  100. (override));
  101. MOCK_METHOD(void, ShowAccountAccessHelpApp, (gfx::NativeWindow), (override));
  102. MOCK_METHOD(void, ShowParentAccessHelpApp, (), (override));
  103. MOCK_METHOD(void, ShowLockScreenNotificationSettings, (), (override));
  104. MOCK_METHOD(void, FocusOobeDialog, (), (override));
  105. MOCK_METHOD(void, OnFocusLeavingSystemTray, (bool reverse), (override));
  106. MOCK_METHOD(void, OnUserActivity, (), (override));
  107. MOCK_METHOD(void, OnLoginScreenShown, (), (override));
  108. MOCK_METHOD(void, OnSystemTrayBubbleShown, (), (override));
  109. MOCK_METHOD(views::Widget*, GetLoginWindowWidget, (), (override));
  110. private:
  111. bool authenticate_user_callback_result_ = true;
  112. ParentCodeValidationResult validate_parent_access_code_result_ =
  113. ParentCodeValidationResult::kValid;
  114. base::OnceCallback<void(bool)>*
  115. authenticate_user_with_password_or_pin_callback_storage_ = nullptr;
  116. };
  117. } // namespace ash
  118. #endif // ASH_LOGIN_MOCK_LOGIN_SCREEN_CLIENT_H_