| Index: components/password_manager/core/browser/affiliated_match_helper_unittest.cc
|
| diff --git a/components/password_manager/core/browser/affiliated_match_helper_unittest.cc b/components/password_manager/core/browser/affiliated_match_helper_unittest.cc
|
| index 6f5dc3d038718dcc5327db4cc4f9ab6dc08bc147..6ff95ece2199636bbac3407bfd9c5c00e8bc7f64 100644
|
| --- a/components/password_manager/core/browser/affiliated_match_helper_unittest.cc
|
| +++ b/components/password_manager/core/browser/affiliated_match_helper_unittest.cc
|
| @@ -164,6 +164,11 @@ class AffiliatedMatchHelperTest : public testing::Test {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| + void UpdateLogin(const autofill::PasswordForm& form) {
|
| + password_store_->UpdateLogin(form);
|
| + base::RunLoop().RunUntilIdle();
|
| + }
|
| +
|
| void RemoveLogin(const autofill::PasswordForm& form) {
|
| password_store_->RemoveLogin(form);
|
| base::RunLoop().RunUntilIdle();
|
| @@ -227,6 +232,18 @@ class AffiliatedMatchHelperTest : public testing::Test {
|
| return last_result_;
|
| }
|
|
|
| + std::vector<std::string> GetAffiliatedWebRealms(
|
| + const autofill::PasswordForm& android_form) {
|
| + expecting_result_callback_ = true;
|
| + match_helper()->GetAffiliatedWebRealms(
|
| + android_form,
|
| + base::Bind(&AffiliatedMatchHelperTest::OnAffiliatedRealmsCallback,
|
| + base::Unretained(this)));
|
| + base::RunLoop().RunUntilIdle();
|
| + EXPECT_FALSE(expecting_result_callback_);
|
| + return last_result_;
|
| + }
|
| +
|
| void DestroyMatchHelper() { match_helper_.reset(); }
|
|
|
| base::TestSimpleTaskRunner* waiting_task_runner() {
|
| @@ -354,6 +371,51 @@ TEST_F(AffiliatedMatchHelperTest,
|
| testing::IsEmpty());
|
| }
|
|
|
| +// GetAffiliatedWebRealms* tests verify that GetAffiliatedWebRealms() returns
|
| +// the realms of web sites affiliated with the given Android application, but
|
| +// only web sites, and only if an Android application is queried.
|
| +
|
| +TEST_F(AffiliatedMatchHelperTest, GetAffiliatedWebRealmsYieldsResults) {
|
| + mock_affiliation_service()->ExpectCallToGetAffiliationsAndSucceedWithResult(
|
| + FacetURI::FromCanonicalSpec(kTestAndroidFacetURIAlpha3),
|
| + StrategyOnCacheMiss::FETCH_OVER_NETWORK, GetTestEquivalenceClassAlpha());
|
| + autofill::PasswordForm android_form(
|
| + GetTestAndroidCredentials(kTestAndroidRealmAlpha3));
|
| + EXPECT_THAT(
|
| + GetAffiliatedWebRealms(android_form),
|
| + testing::UnorderedElementsAre(kTestWebRealmAlpha1, kTestWebRealmAlpha2));
|
| +}
|
| +
|
| +TEST_F(AffiliatedMatchHelperTest, GetAffiliatedWebRealmsYieldsOnlyWebsites) {
|
| + mock_affiliation_service()->ExpectCallToGetAffiliationsAndSucceedWithResult(
|
| + FacetURI::FromCanonicalSpec(kTestAndroidFacetURIBeta2),
|
| + StrategyOnCacheMiss::FETCH_OVER_NETWORK, GetTestEquivalenceClassBeta());
|
| + autofill::PasswordForm android_form(
|
| + GetTestAndroidCredentials(kTestAndroidRealmBeta2));
|
| + // This verifies that |kTestAndroidRealmBeta3| is not returned.
|
| + EXPECT_THAT(GetAffiliatedWebRealms(android_form),
|
| + testing::UnorderedElementsAre(kTestWebRealmBeta1));
|
| +}
|
| +
|
| +TEST_F(AffiliatedMatchHelperTest,
|
| + GetAffiliatedWebRealmsYieldsEmptyResultsForWebKeyedForms) {
|
| + autofill::PasswordForm web_form(
|
| + GetTestObservedWebForm(kTestWebRealmBeta1, nullptr));
|
| + EXPECT_THAT(GetAffiliatedWebRealms(web_form), testing::IsEmpty());
|
| +}
|
| +
|
| +// Note: IsValidWebCredential() is tested as part of GetAffiliatedAndroidRealms
|
| +// tests above.
|
| +TEST_F(AffiliatedMatchHelperTest, IsValidAndroidCredential) {
|
| + autofill::PasswordForm web_credential(
|
| + GetTestObservedWebForm(kTestWebRealmBeta1, nullptr));
|
| + EXPECT_FALSE(AffiliatedMatchHelper::IsValidAndroidCredential(web_credential));
|
| + autofill::PasswordForm android_credential(
|
| + GetTestAndroidCredentials(kTestAndroidRealmBeta2));
|
| + EXPECT_TRUE(
|
| + AffiliatedMatchHelper::IsValidAndroidCredential(android_credential));
|
| +}
|
| +
|
| // Verifies that affiliations for Android applications with pre-existing
|
| // credentials on start-up are prefetched.
|
| TEST_F(AffiliatedMatchHelperTest,
|
|
|