Commit 63830d3f authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

BulkLeakCheckServiceTest should handle gracefully the case with 0 credentials to check.

Bug: 1049185
Change-Id: I948f68fb5e7487a072617ed07911fd4d4213f6b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094302
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748265}
parent 296a6c85
......@@ -773,6 +773,7 @@ TEST_F(PasswordCheckDelegateTest,
// Verify that the event gets fired once the saved passwords provider is
// initialized.
store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1));
RunUntilIdle();
EXPECT_EQ(events::PASSWORDS_PRIVATE_ON_PASSWORD_CHECK_STATUS_CHANGED,
event_router_observer().events().at(kEventName)->histogram_value);
......
......@@ -22,6 +22,8 @@ BulkLeakCheckService::~BulkLeakCheckService() = default;
void BulkLeakCheckService::CheckUsernamePasswordPairs(
std::vector<password_manager::LeakCheckCredential> credentials) {
DVLOG(0) << "Bulk password check, start " << credentials.size();
if (credentials.empty())
return;
if (bulk_leak_check_) {
DCHECK_EQ(State::kRunning, state_);
// The check is already running. Append the credentials to the list.
......
......@@ -100,6 +100,15 @@ TEST_F(BulkLeakCheckServiceTest, OnCreation) {
EXPECT_EQ(BulkLeakCheckService::State::kIdle, service().state());
}
TEST_F(BulkLeakCheckServiceTest, StartWithZeroPasswords) {
StrictMock<MockObserver> observer;
service().AddObserver(&observer);
service().CheckUsernamePasswordPairs({});
EXPECT_EQ(BulkLeakCheckService::State::kIdle, service().state());
EXPECT_EQ(0u, service().GetPendingChecksCount());
}
TEST_F(BulkLeakCheckServiceTest, Running) {
StrictMock<MockObserver> observer;
service().AddObserver(&observer);
......
......@@ -183,6 +183,9 @@ TEST_F(BulkLeakCheckServiceAdapterTest, StartBulkLeakCheckDedupes) {
// Checks that trying to start a leak check when another check is already
// running does nothing and returns false to the caller.
TEST_F(BulkLeakCheckServiceAdapterTest, MultipleStarts) {
store().AddLogin(MakeSavedPassword(kExampleCom, "alice", kPassword1));
RunUntilIdle();
auto leak_check = std::make_unique<NiceMockBulkLeakCheck>();
auto& leak_check_ref = *leak_check;
EXPECT_CALL(leak_check_ref, CheckCredentials);
......@@ -197,6 +200,9 @@ TEST_F(BulkLeakCheckServiceAdapterTest, MultipleStarts) {
// Checks that stopping the leak check correctly resets the state of the bulk
// leak check.
TEST_F(BulkLeakCheckServiceAdapterTest, StopBulkLeakCheck) {
store().AddLogin(MakeSavedPassword(kExampleCom, "alice", kPassword1));
RunUntilIdle();
auto leak_check = std::make_unique<NiceMockBulkLeakCheck>();
EXPECT_CALL(*leak_check, CheckCredentials);
EXPECT_CALL(factory(), TryCreateBulkLeakCheck)
......
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