| Index: components/password_manager/core/browser/password_store_unittest.cc
|
| diff --git a/components/password_manager/core/browser/password_store_unittest.cc b/components/password_manager/core/browser/password_store_unittest.cc
|
| index 694a52ecb74cc5fd7b02749217d8f91e0cd3d94b..0ba0c23e59087e8f64c31f1fa024b47ee2b81c33 100644
|
| --- a/components/password_manager/core/browser/password_store_unittest.cc
|
| +++ b/components/password_manager/core/browser/password_store_unittest.cc
|
| @@ -799,4 +799,65 @@ TEST_F(PasswordStoreTest, MAYBE_UpdatePasswordsStoredForAffiliatedWebsites) {
|
| }
|
| }
|
|
|
| +TEST_F(PasswordStoreTest, GetAutofillableLoginsWithAffiliatedRealms) {
|
| + /* clang-format off */
|
| + static const PasswordFormData kTestCredentials[] = {
|
| + {PasswordForm::SCHEME_HTML,
|
| + kTestAndroidRealm1,
|
| + "", "", L"", L"", L"",
|
| + L"username_value_1",
|
| + L"", true, true, 1},
|
| + {PasswordForm::SCHEME_HTML,
|
| + kTestAndroidRealm2,
|
| + "", "", L"", L"", L"",
|
| + L"username_value_2",
|
| + L"", true, true, 1},
|
| + {PasswordForm::SCHEME_HTML,
|
| + kTestAndroidRealm3,
|
| + "", "", L"", L"", L"",
|
| + L"username_value_3",
|
| + L"", true, true, 1}};
|
| + /* clang-format on */
|
| +
|
| + scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
|
| + base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
|
| + make_scoped_ptr(new LoginDatabase(test_login_db_file_path()))));
|
| + store->Init(syncer::SyncableService::StartSyncFlare());
|
| +
|
| + ScopedVector<PasswordForm> all_credentials;
|
| + for (size_t i = 0; i < arraysize(kTestCredentials); ++i) {
|
| + all_credentials.push_back(
|
| + CreatePasswordFormFromDataForTesting(kTestCredentials[i]));
|
| + store->AddLogin(*all_credentials.back());
|
| + base::MessageLoop::current()->RunUntilIdle();
|
| + }
|
| +
|
| + MockPasswordStoreConsumer mock_consumer;
|
| + ScopedVector<PasswordForm> expected_results;
|
| + for (size_t i = 0; i < arraysize(kTestCredentials); ++i)
|
| + expected_results.push_back(new PasswordForm(*all_credentials[i]));
|
| +
|
| + MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper;
|
| + store->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper));
|
| +
|
| + std::vector<std::string> affiliated_web_realms;
|
| + affiliated_web_realms.push_back(kTestWebRealm1);
|
| + affiliated_web_realms.push_back(kTestWebRealm2);
|
| + affiliated_web_realms.push_back(std::string());
|
| + mock_helper->ExpectCallToInjectAffiliatedWebRealms(affiliated_web_realms);
|
| + for (size_t i = 0; i < expected_results.size(); ++i)
|
| + expected_results[i]->affiliated_web_realm = affiliated_web_realms[i];
|
| +
|
| + EXPECT_CALL(mock_consumer,
|
| + OnGetPasswordStoreResultsConstRef(
|
| + UnorderedPasswordFormElementsAre(expected_results.get())));
|
| + store->GetAutofillableLoginsWithAffiliatedRealms(&mock_consumer);
|
| + // Since GetAutofillableLoginsWithAffiliatedRealms schedules a request for
|
| + // affiliated realms to UI thread, don't shutdown UI thread until there are no
|
| + // tasks in the UI queue.
|
| + base::MessageLoop::current()->RunUntilIdle();
|
| + store->ShutdownOnUIThread();
|
| + base::MessageLoop::current()->RunUntilIdle();
|
| +}
|
| +
|
| } // namespace password_manager
|
|
|