Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: components/password_manager/core/browser/password_store_unittest.cc

Issue 1615653005: [Password manager] Human readable origins for Android credentials on chrome://settings/passwords (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Inlined the variable androidUriSuffix Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698