#include "components/safe_browsing/core/browser/password_protection/password_reuse_detection_manager.h"
#include <array>
#include <optional>
#include "base/test/simple_test_clock.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "components/password_manager/core/browser/mock_password_reuse_manager.h"
#include "components/safe_browsing/core/browser/password_protection/stub_password_reuse_detection_manager_client.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/keycodes/keyboard_codes_posix.h"
#include "url/gurl.h"
_;
AnyNumber;
namespace safe_browsing {
namespace {
constexpr size_t kMaxNumberOfCharactersToStore = …;
class MockPasswordReuseDetectionManagerClient
: public StubPasswordReuseDetectionManagerClient { … };
class PasswordReuseDetectionManagerTest : public ::testing::Test { … };
TEST_F(PasswordReuseDetectionManagerTest, CheckReuseCalled) { … }
TEST_F(PasswordReuseDetectionManagerTest,
CheckThatBufferClearedAfterInactivity) { … }
TEST_F(PasswordReuseDetectionManagerTest, CheckThatBufferClearedAfterEnter) { … }
TEST_F(PasswordReuseDetectionManagerTest, NoReuseCheckingAfterReuseFound) { … }
TEST_F(PasswordReuseDetectionManagerTest, DidNavigateMainFrame) { … }
TEST_F(PasswordReuseDetectionManagerTest, CheckReuseCalledOnPaste) { … }
TEST_F(PasswordReuseDetectionManagerTest,
CheckReuseCalledOnPasteTwiceProduceNoDuplicates) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(PasswordReuseDetectionManagerTest,
CheckReusedCalledWithUncommittedText) {
EXPECT_CALL(client_, GetPasswordReuseManager())
.WillRepeatedly(testing::Return(&reuse_manager_));
PasswordReuseDetectionManager manager(&client_);
GURL test_url("https://www.example.com");
manager.DidNavigateMainFrame(test_url);
std::u16string init_text = u"init_text";
std::u16string uncommitted_text = u"uncommitted_text";
std::u16string committed_text = u"committed_text";
EXPECT_CALL(reuse_manager_,
CheckReuse(init_text, test_url.DeprecatedGetOriginAsURL().spec(),
&manager));
manager.OnKeyPressedCommitted(init_text);
EXPECT_CALL(reuse_manager_,
CheckReuse(init_text + uncommitted_text,
test_url.DeprecatedGetOriginAsURL().spec(), &manager));
manager.OnKeyPressedUncommitted(uncommitted_text);
EXPECT_CALL(reuse_manager_,
CheckReuse(init_text + committed_text,
test_url.DeprecatedGetOriginAsURL().spec(), &manager));
manager.OnKeyPressedCommitted(committed_text);
}
#endif
}
}