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

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

Issue 2667363003: Enable moving of credentials in HttpPasswordMigrator (Closed)
Patch Set: Comments. 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..7e545bd661e7a0fa2543913ddbef74d8eb95f74c 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,45 @@ class HttpPasswordMigratorTest : public testing::Test {
MockConsumer& consumer() { return consumer_; }
MockPasswordStore& store() { return *mock_store_; }
+ protected:
+ void TestEmptyStore(HttpPasswordMigrator::MigrationMode mode) {
vasilii 2017/02/02 16:04:37 We shouldn't inline such a big method per our styl
jdoerrie 2017/02/02 16:44:55 Done.
+ PasswordStore::FormDigest form(autofill::PasswordForm::SCHEME_HTML,
+ kTestHttpURL, GURL(kTestHttpURL));
+ EXPECT_CALL(store(), GetLogins(form, _));
+ HttpPasswordMigrator migrator(GURL(kTestHttpsURL), mode, &store(),
+ &consumer());
+
+ EXPECT_CALL(consumer(),
+ ProcessForms(std::vector<autofill::PasswordForm*>()));
+ migrator.OnGetPasswordStoreResults(
+ std::vector<std::unique_ptr<autofill::PasswordForm>>());
+ }
+
+ void 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), mode, &store(),
+ &consumer());
+
+ PasswordForm form = CreateTestForm();
+ PasswordForm psl_form = CreateTestPSLForm();
+ PasswordForm android_form = CreateAndroidCredential();
+ PasswordForm expected_form = form;
+ expected_form.origin = GURL(kTestHttpsURL);
+ 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));
+ results.push_back(base::MakeUnique<PasswordForm>(form));
+ results.push_back(base::MakeUnique<PasswordForm>(android_form));
+ migrator.OnGetPasswordStoreResults(std::move(results));
+ }
+
private:
base::MessageLoop message_loop_; // Used by mock_store_.
MockConsumer consumer_;
@@ -93,37 +132,20 @@ class HttpPasswordMigratorTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(HttpPasswordMigratorTest);
};
-TEST_F(HttpPasswordMigratorTest, EmptyStore) {
- PasswordStore::FormDigest form(autofill::PasswordForm::SCHEME_HTML,
- kTestHttpURL, GURL(kTestHttpURL));
- EXPECT_CALL(store(), GetLogins(form, _));
- HttpPasswordMigrator migrator(GURL(kTestHttpsURL), &store(), &consumer());
+TEST_F(HttpPasswordMigratorTest, EmptyStoreWithMove) {
+ TestEmptyStore(HttpPasswordMigrator::MigrationMode::MOVE);
+}
+
+TEST_F(HttpPasswordMigratorTest, EmptyStoreWithCopy) {
+ TestEmptyStore(HttpPasswordMigrator::MigrationMode::COPY);
+}
- EXPECT_CALL(consumer(), ProcessForms(std::vector<autofill::PasswordForm*>()));
- migrator.OnGetPasswordStoreResults(
- std::vector<std::unique_ptr<autofill::PasswordForm>>());
+TEST_F(HttpPasswordMigratorTest, FullStoreWithMove) {
+ TestFullStore(HttpPasswordMigrator::MigrationMode::MOVE);
}
-TEST_F(HttpPasswordMigratorTest, FullStore) {
- PasswordStore::FormDigest form_digest(autofill::PasswordForm::SCHEME_HTML,
- kTestHttpURL, GURL(kTestHttpURL));
- EXPECT_CALL(store(), GetLogins(form_digest, _));
- HttpPasswordMigrator migrator(GURL(kTestHttpsURL), &store(), &consumer());
-
- PasswordForm form = CreateTestForm();
- PasswordForm psl_form = CreateTestPSLForm();
- PasswordForm android_form = CreateAndroidCredential();
- PasswordForm expected_form = form;
- expected_form.origin = GURL(kTestHttpsURL);
- expected_form.signon_realm = expected_form.origin.spec();
-
- EXPECT_CALL(store(), AddLogin(expected_form));
- EXPECT_CALL(consumer(), ProcessForms(ElementsAre(Pointee(expected_form))));
- std::vector<std::unique_ptr<autofill::PasswordForm>> results;
- results.push_back(base::MakeUnique<PasswordForm>(psl_form));
- results.push_back(base::MakeUnique<PasswordForm>(form));
- results.push_back(base::MakeUnique<PasswordForm>(android_form));
- migrator.OnGetPasswordStoreResults(std::move(results));
+TEST_F(HttpPasswordMigratorTest, FullStoreWithCopy) {
+ TestFullStore(HttpPasswordMigrator::MigrationMode::COPY);
}
} // namespace
« 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