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

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

Issue 866983003: GetLoginsRequest: Use ScopedVector to express ownership of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@324291_scopedvector
Patch Set: Rebased Created 5 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
Index: chrome/browser/password_manager/password_store_mac_unittest.cc
diff --git a/chrome/browser/password_manager/password_store_mac_unittest.cc b/chrome/browser/password_manager/password_store_mac_unittest.cc
index 29a3f90f6c8b93e0ad1f891d6ce2f87c928d97a8..a30fa220c45ae0c7e2f0bb7e7eb2598b21f801c9 100644
--- a/chrome/browser/password_manager/password_store_mac_unittest.cc
+++ b/chrome/browser/password_manager/password_store_mac_unittest.cc
@@ -37,10 +37,6 @@ using testing::WithArg;
namespace {
-ACTION(STLDeleteElements0) {
- STLDeleteContainerPointers(arg0.begin(), arg0.end());
-}
-
ACTION(QuitUIMessageLoop) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::MessageLoop::current()->Quit();
@@ -48,28 +44,16 @@ ACTION(QuitUIMessageLoop) {
class MockPasswordStoreConsumer : public PasswordStoreConsumer {
public:
- MOCK_METHOD1(OnGetPasswordStoreResults,
- void(const std::vector<autofill::PasswordForm*>&));
-
- void CopyElements(const std::vector<autofill::PasswordForm*>& forms) {
- last_result.clear();
- for (size_t i = 0; i < forms.size(); ++i) {
- last_result.push_back(*forms[i]);
- }
- }
+ MOCK_METHOD0(OnGetPasswordStoreResults, void());
// Runs the current thread's message loop until OnGetPasswordStoreResults()
// is posted to it. This method should be called immediately after GetLogins,
// without pumping the message loop in-between.
void WaitOnGetPasswordStoreResults() {
- EXPECT_CALL(*this, OnGetPasswordStoreResults(_)).WillOnce(DoAll(
- WithArg<0>(Invoke(this, &MockPasswordStoreConsumer::CopyElements)),
- WithArg<0>(STLDeleteElements0()),
- QuitUIMessageLoop()));
+ EXPECT_CALL(*this, OnGetPasswordStoreResults())
+ .WillOnce(QuitUIMessageLoop());
base::MessageLoop::current()->Run();
}
-
- std::vector<PasswordForm> last_result;
};
class MockPasswordStoreObserver : public PasswordStore::Observer {
@@ -1277,10 +1261,10 @@ TEST_F(PasswordStoreMacTest, TestDBKeychainAssociation) {
MockPasswordStoreConsumer consumer;
store_->GetLogins(m_form, PasswordStore::ALLOW_PROMPT, &consumer);
consumer.WaitOnGetPasswordStoreResults();
- EXPECT_EQ(1u, consumer.last_result.size());
+ EXPECT_EQ(1u, consumer.results()->size());
// 3. Add the returned password for m.facebook.com.
- login_db()->AddLogin(consumer.last_result[0]);
+ login_db()->AddLogin(*(*consumer.results())[0]);
owned_keychain_adapter.AddPassword(m_form);
// 4. Remove both passwords.
@@ -1516,7 +1500,7 @@ TEST_F(PasswordStoreMacTest, StoreIsUsableImmediatelyAfterConstruction) {
event.Signal();
mock_consumer.WaitOnGetPasswordStoreResults();
- EXPECT_EQ(1u, mock_consumer.last_result.size());
+ EXPECT_EQ(1u, mock_consumer.results()->size());
EXPECT_TRUE(login_db());
}
@@ -1552,13 +1536,13 @@ TEST_F(PasswordStoreMacTest, OperationsOnABadDatabaseSilentlyFail) {
MockPasswordStoreConsumer mock_consumer;
store()->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &mock_consumer);
mock_consumer.WaitOnGetPasswordStoreResults();
- EXPECT_TRUE(mock_consumer.last_result.empty());
+ EXPECT_TRUE(mock_consumer.results()->empty());
store()->GetAutofillableLogins(&mock_consumer);
mock_consumer.WaitOnGetPasswordStoreResults();
- EXPECT_TRUE(mock_consumer.last_result.empty());
+ EXPECT_TRUE(mock_consumer.results()->empty());
store()->GetBlacklistLogins(&mock_consumer);
mock_consumer.WaitOnGetPasswordStoreResults();
- EXPECT_TRUE(mock_consumer.last_result.empty());
+ EXPECT_TRUE(mock_consumer.results()->empty());
// Report metrics.
store()->ReportMetrics("Test Username", true);

Powered by Google App Engine
This is Rietveld 408576698