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

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

Issue 299443002: Password Login Database: report correct changes from UpdateLogin(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added UpdateNonexistentLogin tests Created 6 years, 7 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_gnome_x_unittest.cc
diff --git a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
index bf648f9d1ba75eef8ab058c840d6476e067fc5fe..a634cb7fbab7623ffd78fd3c6880543a0b65050f 100644
--- a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
+++ b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
@@ -556,7 +556,8 @@ class NativeBackendGnomeTest : public testing::Test {
FROM_HERE,
base::Bind(base::IgnoreResult(&NativeBackendGnome::UpdateLogin),
base::Unretained(&backend),
- new_facebook));
+ new_facebook,
+ base::Owned(new PasswordStoreChangeList)));
break;
case UPDATE_BY_ADDLOGIN:
BrowserThread::PostTask(
@@ -753,13 +754,19 @@ TEST_F(NativeBackendGnomeTest, BasicUpdateLogin) {
CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
// Update login
+ PasswordStoreChangeList changes;
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
base::Bind(base::IgnoreResult(&NativeBackendGnome::UpdateLogin),
- base::Unretained(&backend), new_form_google));
+ base::Unretained(&backend),
+ new_form_google,
+ base::Unretained(&changes)));
RunBothThreads();
+ ASSERT_EQ(1u, changes.size());
+ EXPECT_EQ(PasswordStoreChange::UPDATE, changes.front().type());
+ EXPECT_EQ(new_form_google, changes.front().form());
EXPECT_EQ(1u, mock_keyring_items.size());
if (mock_keyring_items.size() > 0)
CheckMockKeyringItem(&mock_keyring_items[0], new_form_google, "chrome-42");
@@ -831,6 +838,39 @@ TEST_F(NativeBackendGnomeTest, RemoveNonexistentLogin) {
CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
}
+TEST_F(NativeBackendGnomeTest, UpdateNonexistentLogin) {
+ NativeBackendGnome backend(42);
+ backend.Init();
+
+ // First add an unrelated login.
+ BrowserThread::PostTask(
+ BrowserThread::DB, FROM_HERE,
+ base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
+ base::Unretained(&backend), form_google_));
+
+ RunBothThreads();
+
+ EXPECT_EQ(1u, mock_keyring_items.size());
+ if (mock_keyring_items.size() > 0)
+ CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
+
+ // Attempt to update a login that doesn't exist.
+ PasswordStoreChangeList changes;
+ BrowserThread::PostTask(
+ BrowserThread::DB, FROM_HERE,
+ base::Bind(base::IgnoreResult(&NativeBackendGnome::UpdateLogin),
+ base::Unretained(&backend),
+ form_isc_,
+ base::Unretained(&changes)));
+
+ RunBothThreads();
+
+ EXPECT_EQ(PasswordStoreChangeList(), changes);
+ EXPECT_EQ(1u, mock_keyring_items.size());
+ if (mock_keyring_items.size() > 0)
+ CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
+}
+
TEST_F(NativeBackendGnomeTest, AddDuplicateLogin) {
NativeBackendGnome backend(42);
backend.Init();
« no previous file with comments | « chrome/browser/password_manager/native_backend_gnome_x.cc ('k') | chrome/browser/password_manager/native_backend_kwallet_x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698