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

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

Issue 283563002: Password Login Database: report correct changes from AddLogin(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: the nit addressed 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 44650942f0b7c27c1e12208e314eeec16c50c6d5..1b3e96624787d7bd54717ca9c5f4b9891f7d8ad6 100644
--- a/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc
+++ b/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc
@@ -29,6 +29,8 @@
using autofill::PasswordForm;
using base::UTF8ToUTF16;
using content::BrowserThread;
+using password_manager::PasswordStoreChange;
+using password_manager::PasswordStoreChangeList;
using testing::_;
using testing::Invoke;
using testing::Return;
@@ -163,8 +165,10 @@ class NativeBackendKWalletTestBase : public testing::Test {
form_isc_.signon_realm = "ISC";
}
- void CheckPasswordForm(const PasswordForm& expected,
- const PasswordForm& actual);
+ static void CheckPasswordForm(const PasswordForm& expected,
+ const PasswordForm& actual);
+ static void CheckPasswordChanges(const PasswordStoreChangeList& expected,
+ const PasswordStoreChangeList& actual);
PasswordForm old_form_google_;
PasswordForm form_google_;
@@ -190,6 +194,16 @@ void NativeBackendKWalletTestBase::CheckPasswordForm(
EXPECT_EQ(expected.scheme, actual.scheme);
}
+void NativeBackendKWalletTestBase::CheckPasswordChanges(
+ const PasswordStoreChangeList& expected,
+ const PasswordStoreChangeList& actual) {
+ ASSERT_EQ(expected.size(), actual.size());
+ for (size_t i = 0; i < expected.size(); ++i) {
+ EXPECT_EQ(expected[i].type(), actual[i].type());
+ CheckPasswordForm(expected[i].form(), actual[i].form());
+ }
+}
+
class NativeBackendKWalletTest : public NativeBackendKWalletTestBase {
protected:
NativeBackendKWalletTest()
@@ -634,14 +648,29 @@ TEST_F(NativeBackendKWalletTest, AddDuplicateLogin) {
NativeBackendKWalletStub backend(42);
EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
- BrowserThread::PostTask(
+ PasswordStoreChangeList changes;
+ changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD,
+ form_google_));
+ BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::DB, FROM_HERE,
- base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
- base::Unretained(&backend), form_google_));
- BrowserThread::PostTask(
+ base::Bind(&NativeBackendKWalletStub::AddLogin,
+ base::Unretained(&backend), form_google_),
+ base::Bind(&NativeBackendKWalletTest::CheckPasswordChanges,
+ changes));
+
+ changes.clear();
+ changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE,
+ form_google_));
+ form_google_.times_used++;
+ changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD,
+ form_google_));
+
+ BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::DB, FROM_HERE,
- base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
- base::Unretained(&backend), form_google_));
+ base::Bind(&NativeBackendKWalletStub::AddLogin,
+ base::Unretained(&backend), form_google_),
+ base::Bind(&NativeBackendKWalletTest::CheckPasswordChanges,
+ changes));
RunDBThread();
« 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