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

Unified Diff: chrome/browser/password_manager/native_backend_kwallet_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_kwallet_x_unittest.cc
diff --git a/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc b/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc
index 1b3e96624787d7bd54717ca9c5f4b9891f7d8ad6..682a30d9a566c9ee8b71fa01863816336433736d 100644
--- a/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc
+++ b/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc
@@ -540,6 +540,42 @@ TEST_F(NativeBackendKWalletTest, BasicAddLogin) {
CheckPasswordForms("Chrome Form Data (42)", expected);
}
+TEST_F(NativeBackendKWalletTest, BasicUpdateLogin) {
+ NativeBackendKWalletStub backend(42);
+ EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
+
+ BrowserThread::PostTask(
+ BrowserThread::DB, FROM_HERE,
+ base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
+ base::Unretained(&backend), form_google_));
+
+ RunDBThread();
+
+ PasswordForm new_form_google(form_google_);
+ new_form_google.times_used = 10;
+ new_form_google.action = GURL("http://www.google.com/different/login");
+
+ // Update login
+ PasswordStoreChangeList changes;
+ BrowserThread::PostTask(
+ BrowserThread::DB, FROM_HERE,
+ base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::UpdateLogin),
+ base::Unretained(&backend),
+ new_form_google,
+ base::Unretained(&changes)));
+ RunDBThread();
+
+ ASSERT_EQ(1u, changes.size());
+ EXPECT_EQ(PasswordStoreChange::UPDATE, changes.front().type());
+ EXPECT_EQ(new_form_google, changes.front().form());
+
+ std::vector<const PasswordForm*> forms;
+ forms.push_back(&new_form_google);
+ ExpectationArray expected;
+ expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
+ CheckPasswordForms("Chrome Form Data (42)", expected);
+}
+
TEST_F(NativeBackendKWalletTest, BasicListLogins) {
NativeBackendKWalletStub backend(42);
EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
@@ -601,6 +637,39 @@ TEST_F(NativeBackendKWalletTest, BasicRemoveLogin) {
CheckPasswordForms("Chrome Form Data (42)", expected);
}
+TEST_F(NativeBackendKWalletTest, UpdateNonexistentLogin) {
+ NativeBackendKWalletStub backend(42);
+ EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
+
+ // First add an unrelated login.
+ BrowserThread::PostTask(
+ BrowserThread::DB, FROM_HERE,
+ base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
+ base::Unretained(&backend), form_google_));
+
+ RunDBThread();
+
+ std::vector<const PasswordForm*> forms;
+ forms.push_back(&form_google_);
+ ExpectationArray expected;
+ expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
+ CheckPasswordForms("Chrome Form Data (42)", expected);
+
+ // Attempt to update a login that doesn't exist.
+ PasswordStoreChangeList changes;
+ BrowserThread::PostTask(
+ BrowserThread::DB, FROM_HERE,
+ base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::UpdateLogin),
+ base::Unretained(&backend),
+ form_isc_,
+ base::Unretained(&changes)));
+
+ RunDBThread();
+
+ EXPECT_EQ(PasswordStoreChangeList(), changes);
+ CheckPasswordForms("Chrome Form Data (42)", expected);
+}
+
TEST_F(NativeBackendKWalletTest, RemoveNonexistentLogin) {
NativeBackendKWalletStub backend(42);
EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
« no previous file with comments | « chrome/browser/password_manager/native_backend_kwallet_x.cc ('k') | chrome/browser/password_manager/password_store_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698