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

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

Issue 2667363003: Enable moving of credentials in HttpPasswordMigrator (Closed)
Patch Set: Moved test methods out of class Created 3 years, 11 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
« no previous file with comments | « components/password_manager/core/browser/http_password_migrator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/http_password_migrator_unittest.cc
diff --git a/components/password_manager/core/browser/http_password_migrator_unittest.cc b/components/password_manager/core/browser/http_password_migrator_unittest.cc
index e536f10a2fd3a02bbd274c4a1fef6491fcf8fae9..76cc5937a3e9fb9fa64fce57d148e3d66a044d82 100644
--- a/components/password_manager/core/browser/http_password_migrator_unittest.cc
+++ b/components/password_manager/core/browser/http_password_migrator_unittest.cc
@@ -85,6 +85,10 @@ class HttpPasswordMigratorTest : public testing::Test {
MockConsumer& consumer() { return consumer_; }
MockPasswordStore& store() { return *mock_store_; }
+ protected:
+ void TestEmptyStore(HttpPasswordMigrator::MigrationMode mode);
+ void TestFullStore(HttpPasswordMigrator::MigrationMode mode);
+
private:
base::MessageLoop message_loop_; // Used by mock_store_.
MockConsumer consumer_;
@@ -93,22 +97,26 @@ class HttpPasswordMigratorTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(HttpPasswordMigratorTest);
};
-TEST_F(HttpPasswordMigratorTest, EmptyStore) {
+void HttpPasswordMigratorTest::TestEmptyStore(
+ HttpPasswordMigrator::MigrationMode mode) {
PasswordStore::FormDigest form(autofill::PasswordForm::SCHEME_HTML,
kTestHttpURL, GURL(kTestHttpURL));
EXPECT_CALL(store(), GetLogins(form, _));
- HttpPasswordMigrator migrator(GURL(kTestHttpsURL), &store(), &consumer());
+ HttpPasswordMigrator migrator(GURL(kTestHttpsURL), mode, &store(),
+ &consumer());
EXPECT_CALL(consumer(), ProcessForms(std::vector<autofill::PasswordForm*>()));
migrator.OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>>());
}
-TEST_F(HttpPasswordMigratorTest, FullStore) {
+void HttpPasswordMigratorTest::TestFullStore(
+ HttpPasswordMigrator::MigrationMode mode) {
PasswordStore::FormDigest form_digest(autofill::PasswordForm::SCHEME_HTML,
kTestHttpURL, GURL(kTestHttpURL));
EXPECT_CALL(store(), GetLogins(form_digest, _));
- HttpPasswordMigrator migrator(GURL(kTestHttpsURL), &store(), &consumer());
+ HttpPasswordMigrator migrator(GURL(kTestHttpsURL), mode, &store(),
+ &consumer());
PasswordForm form = CreateTestForm();
PasswordForm psl_form = CreateTestPSLForm();
@@ -118,6 +126,8 @@ TEST_F(HttpPasswordMigratorTest, FullStore) {
expected_form.signon_realm = expected_form.origin.spec();
EXPECT_CALL(store(), AddLogin(expected_form));
+ EXPECT_CALL(store(), RemoveLogin(form))
+ .Times(mode == HttpPasswordMigrator::MigrationMode::MOVE);
EXPECT_CALL(consumer(), ProcessForms(ElementsAre(Pointee(expected_form))));
std::vector<std::unique_ptr<autofill::PasswordForm>> results;
results.push_back(base::MakeUnique<PasswordForm>(psl_form));
@@ -126,5 +136,21 @@ TEST_F(HttpPasswordMigratorTest, FullStore) {
migrator.OnGetPasswordStoreResults(std::move(results));
}
+TEST_F(HttpPasswordMigratorTest, EmptyStoreWithMove) {
+ TestEmptyStore(HttpPasswordMigrator::MigrationMode::MOVE);
+}
+
+TEST_F(HttpPasswordMigratorTest, EmptyStoreWithCopy) {
+ TestEmptyStore(HttpPasswordMigrator::MigrationMode::COPY);
+}
+
+TEST_F(HttpPasswordMigratorTest, FullStoreWithMove) {
+ TestFullStore(HttpPasswordMigrator::MigrationMode::MOVE);
+}
+
+TEST_F(HttpPasswordMigratorTest, FullStoreWithCopy) {
+ TestFullStore(HttpPasswordMigrator::MigrationMode::COPY);
+}
+
} // namespace
} // namespace password_manager
« no previous file with comments | « components/password_manager/core/browser/http_password_migrator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698