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

Unified Diff: chrome/browser/password_manager/native_backend_libsecret_unittest.cc

Issue 906973007: PasswordStore: Clean up expectations about rewriting vectors of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Linux compile Created 5 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: chrome/browser/password_manager/native_backend_libsecret_unittest.cc
diff --git a/chrome/browser/password_manager/native_backend_libsecret_unittest.cc b/chrome/browser/password_manager/native_backend_libsecret_unittest.cc
index 40fbbc41a80913112f61772085d0a19e7d4cb55d..9ebd4f6873ff2f007ed6557a8c42034af1bf7543 100644
--- a/chrome/browser/password_manager/native_backend_libsecret_unittest.cc
+++ b/chrome/browser/password_manager/native_backend_libsecret_unittest.cc
@@ -151,13 +151,17 @@ gboolean mock_secret_password_clear_sync(const SecretSchema* schema,
g_hash_table_insert(attributes, g_strdup(name), value);
}
va_end(ap);
- for (uint32_t i = 0; i < global_mock_libsecret_items->size();)
- if (Matches((*global_mock_libsecret_items)[i], attributes)) {
- global_mock_libsecret_items->erase(global_mock_libsecret_items->begin() +
- i);
- } else {
- ++i;
+
+ ScopedVector<MockSecretItem> kept_mock_libsecret_items;
+ kept_mock_libsecret_items.reserve(global_mock_libsecret_items->size());
+ for (auto& item : *global_mock_libsecret_items) {
+ if (!Matches(item, attributes)) {
+ kept_mock_libsecret_items.push_back(item);
+ item = nullptr;
}
+ }
+ global_mock_libsecret_items->swap(kept_mock_libsecret_items);
+
g_hash_table_unref(attributes);
return true;
}
@@ -796,26 +800,6 @@ TEST_F(NativeBackendLibsecretTest, AddDuplicateLogin) {
"chrome-42");
}
-TEST_F(NativeBackendLibsecretTest, ListLoginsAppends) {
- NativeBackendLibsecret backend(42);
-
- backend.AddLogin(form_google_);
-
- // Send the same request twice with the same list both times.
- ScopedVector<autofill::PasswordForm> form_list;
- backend.GetAutofillableLogins(&form_list);
- backend.GetAutofillableLogins(&form_list);
-
- // Quick check that we got two results back.
- EXPECT_EQ(2u, form_list.size());
- form_list.clear();
-
- EXPECT_EQ(1u, global_mock_libsecret_items->size());
- if (!global_mock_libsecret_items->empty())
- CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_,
- "chrome-42");
-}
-
TEST_F(NativeBackendLibsecretTest, AndroidCredentials) {
NativeBackendLibsecret backend(42);
backend.Init();
@@ -838,7 +822,6 @@ TEST_F(NativeBackendLibsecretTest, AndroidCredentials) {
EXPECT_EQ(saved_android_form, *form_list[0]);
}
-
TEST_F(NativeBackendLibsecretTest, RemoveLoginsCreatedBetween) {
CheckRemoveLoginsBetween(CREATED);
}

Powered by Google App Engine
This is Rietveld 408576698