Commit b9bb8005 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Convert manage_passwords_state_unittest to use mocked PasswordFormManager.

Bug: 998496
Change-Id: I57223f7c0b0923ff84ede9fdff18772e23423c04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1827400
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700245}
parent 363b8d6f
......@@ -129,7 +129,6 @@ void ManagePasswordsState::OnAutomaticPasswordSave(
std::unique_ptr<PasswordFormManagerForUI> form_manager) {
ClearData();
form_manager_ = std::move(form_manager);
local_credentials_forms_.reserve(form_manager_->GetBestMatches().size());
for (const auto& form : form_manager_->GetBestMatches()) {
if (form.second->is_public_suffix_match)
continue;
......
......@@ -405,6 +405,8 @@ jumbo_static_library("test_support") {
"fake_form_fetcher.h",
"mock_password_feature_manager.cc",
"mock_password_feature_manager.h",
"mock_password_form_manager_for_ui.cc",
"mock_password_form_manager_for_ui.h",
"mock_password_store.cc",
"mock_password_store.h",
"password_manager_test_utils.cc",
......
......@@ -54,7 +54,7 @@ void CredentialManagerPasswordFormManager::OnFetchCompleted() {
}
metrics_util::CredentialSourceType
CredentialManagerPasswordFormManager::GetCredentialSource() {
CredentialManagerPasswordFormManager::GetCredentialSource() const {
return metrics_util::CredentialSourceType::kCredentialManagementAPI;
}
......
......@@ -49,7 +49,7 @@ class CredentialManagerPasswordFormManager : public PasswordFormManager {
void OnFetchCompleted() override;
// PasswordFormManagerForUI:
metrics_util::CredentialSourceType GetCredentialSource() override;
metrics_util::CredentialSourceType GetCredentialSource() const override;
private:
// Calls OnProvisionalSaveComplete on |delegate_|.
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/password_manager/core/browser/mock_password_form_manager_for_ui.h"
namespace password_manager {
MockPasswordFormManagerForUI::MockPasswordFormManagerForUI() = default;
MockPasswordFormManagerForUI::~MockPasswordFormManagerForUI() = default;
} // namespace password_manager
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_MOCK_PASSWORD_FORM_MANAGER_FOR_UI_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_MOCK_PASSWORD_FORM_MANAGER_FOR_UI_H_
#include "base/macros.h"
#include "components/password_manager/core/browser/password_form_manager_for_ui.h"
#include "components/password_manager/core/browser/statistics_table.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace password_manager {
class MockPasswordFormManagerForUI : public PasswordFormManagerForUI {
public:
MockPasswordFormManagerForUI();
~MockPasswordFormManagerForUI() override;
MOCK_CONST_METHOD0(GetOrigin, const GURL&());
MOCK_CONST_METHOD0(
GetBestMatches,
const std::map<base::string16, const autofill::PasswordForm*>&());
MOCK_CONST_METHOD0(GetFederatedMatches,
std::vector<const autofill::PasswordForm*>());
MOCK_CONST_METHOD0(GetPendingCredentials, const autofill::PasswordForm&());
MOCK_CONST_METHOD0(GetCredentialSource, metrics_util::CredentialSourceType());
MOCK_METHOD0(GetMetricsRecorder, PasswordFormMetricsRecorder*());
MOCK_CONST_METHOD0(GetInteractionsStats,
base::span<const InteractionsStats>());
MOCK_CONST_METHOD0(IsBlacklisted, bool());
MOCK_METHOD0(Save, void());
MOCK_METHOD1(Update,
void(const autofill::PasswordForm& credentials_to_update));
MOCK_METHOD1(UpdateUsername, void(const base::string16& new_username));
MOCK_METHOD1(UpdatePasswordValue, void(const base::string16& new_password));
MOCK_METHOD0(OnNopeUpdateClicked, void());
MOCK_METHOD0(OnNeverClicked, void());
MOCK_METHOD1(OnNoInteraction, void(bool));
MOCK_METHOD0(PermanentlyBlacklist, void());
MOCK_METHOD0(OnPasswordsRevealed, void());
DISALLOW_COPY_AND_ASSIGN(MockPasswordFormManagerForUI);
};
} // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_MOCK_PASSWORD_FORM_MANAGER_FOR_UI_H_
......@@ -238,7 +238,8 @@ const PasswordForm& PasswordFormManager::GetPendingCredentials() const {
return pending_credentials_;
}
metrics_util::CredentialSourceType PasswordFormManager::GetCredentialSource() {
metrics_util::CredentialSourceType PasswordFormManager::GetCredentialSource()
const {
return metrics_util::CredentialSourceType::kPasswordManager;
}
......
......@@ -144,7 +144,7 @@ class PasswordFormManager : public PasswordFormManagerForUI,
std::vector<const autofill::PasswordForm*> GetFederatedMatches()
const override;
const autofill::PasswordForm& GetPendingCredentials() const override;
metrics_util::CredentialSourceType GetCredentialSource() override;
metrics_util::CredentialSourceType GetCredentialSource() const override;
PasswordFormMetricsRecorder* GetMetricsRecorder() override;
base::span<const InteractionsStats> GetInteractionsStats() const override;
bool IsBlacklisted() const override;
......
......@@ -48,7 +48,7 @@ class PasswordFormManagerForUI {
// Returns who created this PasswordFormManager. The Credential Management API
// uses a derived class of the PasswordFormManager that can indicate its
// origin.
virtual metrics_util::CredentialSourceType GetCredentialSource() = 0;
virtual metrics_util::CredentialSourceType GetCredentialSource() const = 0;
// Returns metric recorder which responsible for recording metrics for this
// form.
......
......@@ -51,7 +51,7 @@ class PasswordDataForUI : public PasswordFormManagerForUI {
const override;
std::vector<const PasswordForm*> GetFederatedMatches() const override;
const PasswordForm& GetPendingCredentials() const override;
metrics_util::CredentialSourceType GetCredentialSource() override;
metrics_util::CredentialSourceType GetCredentialSource() const override;
PasswordFormMetricsRecorder* GetMetricsRecorder() override;
base::span<const InteractionsStats> GetInteractionsStats() const override;
bool IsBlacklisted() const override;
......@@ -114,7 +114,8 @@ const PasswordForm& PasswordDataForUI::GetPendingCredentials() const {
return pending_form_;
}
metrics_util::CredentialSourceType PasswordDataForUI::GetCredentialSource() {
metrics_util::CredentialSourceType PasswordDataForUI::GetCredentialSource()
const {
return metrics_util::CredentialSourceType::kPasswordManager;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment