Index: chrome/browser/password_manager/password_store_win_unittest.cc |
diff --git a/chrome/browser/password_manager/password_store_win_unittest.cc b/chrome/browser/password_manager/password_store_win_unittest.cc |
index 79472438bedceda81d2443be08bed32b3bdbb25f..b81b9becf92e17d863d4fad25753c7053a6f68a8 100644 |
--- a/chrome/browser/password_manager/password_store_win_unittest.cc |
+++ b/chrome/browser/password_manager/password_store_win_unittest.cc |
@@ -33,21 +33,27 @@ |
using autofill::PasswordForm; |
using base::WaitableEvent; |
using content::BrowserThread; |
+using password_manager::ContainsSamePasswordForms; |
using password_manager::LoginDatabase; |
-using password_manager::ContainsAllPasswordForms; |
using password_manager::PasswordFormData; |
using password_manager::PasswordStore; |
using password_manager::PasswordStoreConsumer; |
using testing::_; |
using testing::DoAll; |
+using testing::IsEmpty; |
using testing::WithArg; |
namespace { |
class MockPasswordStoreConsumer : public PasswordStoreConsumer { |
public: |
- MOCK_METHOD1(OnGetPasswordStoreResults, |
- void(const std::vector<autofill::PasswordForm*>&)); |
+ MOCK_METHOD1(OnGetPasswordStoreResultsConstRef, |
+ void(const std::vector<PasswordForm*>&)); |
+ |
+ // GMock cannot mock methods with move-only args. |
+ void OnGetPasswordStoreResults(ScopedVector<PasswordForm> results) override { |
+ OnGetPasswordStoreResultsConstRef(results.get()); |
+ } |
}; |
class MockWebDataServiceConsumer : public WebDataServiceConsumer { |
@@ -58,8 +64,6 @@ public: |
} // anonymous namespace |
-typedef std::vector<PasswordForm*> VectorOfForms; |
- |
class PasswordStoreWinTest : public testing::Test { |
protected: |
PasswordStoreWinTest() |
@@ -211,7 +215,7 @@ TEST_F(PasswordStoreWinTest, DISABLED_ConvertIE7Login) { |
MockPasswordStoreConsumer consumer; |
// Make sure we quit the MessageLoop even if the test fails. |
- ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
+ ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
.WillByDefault(QuitUIMessageLoop()); |
PasswordFormData form_data = { |
@@ -226,7 +230,7 @@ TEST_F(PasswordStoreWinTest, DISABLED_ConvertIE7Login) { |
L"", |
true, false, 1, |
}; |
- scoped_ptr<PasswordForm> form(CreatePasswordFormFromData(form_data)); |
+ scoped_ptr<PasswordForm> form = CreatePasswordFormFromData(form_data); |
// The returned form will not have 'action' or '*_element' fields set. This |
// is because credentials imported from IE don't have this information. |
@@ -242,18 +246,15 @@ TEST_F(PasswordStoreWinTest, DISABLED_ConvertIE7Login) { |
L"abcdefghijkl", |
true, false, 1, |
}; |
- std::vector<PasswordForm*> forms; |
- forms.push_back(CreatePasswordFormFromData(expected_form_data)); |
+ ScopedVector<autofill::PasswordForm> expected_forms; |
+ expected_forms.push_back(CreatePasswordFormFromData(expected_form_data)); |
// The IE7 password should be returned. |
- EXPECT_CALL(consumer, |
- OnGetPasswordStoreResults(ContainsAllPasswordForms(forms))) |
- .WillOnce(QuitUIMessageLoop()); |
+ EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef( |
+ ContainsSamePasswordForms(expected_forms.get()))); |
store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
base::MessageLoop::current()->Run(); |
- |
- STLDeleteElements(&forms); |
} |
// Crashy. http://crbug.com/86558 |
@@ -273,7 +274,7 @@ TEST_F(PasswordStoreWinTest, DISABLED_OutstandingWDSQueries) { |
L"", |
true, false, 1, |
}; |
- scoped_ptr<PasswordForm> form(CreatePasswordFormFromData(form_data)); |
+ scoped_ptr<PasswordForm> form = CreatePasswordFormFromData(form_data); |
MockPasswordStoreConsumer consumer; |
store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
@@ -306,7 +307,7 @@ TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { |
MockPasswordStoreConsumer password_consumer; |
// Make sure we quit the MessageLoop even if the test fails. |
- ON_CALL(password_consumer, OnGetPasswordStoreResults(_)) |
+ ON_CALL(password_consumer, OnGetPasswordStoreResultsConstRef(_)) |
.WillByDefault(QuitUIMessageLoop()); |
PasswordFormData form_data = { |
@@ -321,7 +322,7 @@ TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { |
L"", |
true, false, 1, |
}; |
- scoped_ptr<PasswordForm> form(CreatePasswordFormFromData(form_data)); |
+ scoped_ptr<PasswordForm> form = CreatePasswordFormFromData(form_data); |
PasswordFormData expected_form_data = { |
PasswordForm::SCHEME_HTML, |
@@ -335,20 +336,19 @@ TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { |
L"abcdefghijkl", |
true, false, 1, |
}; |
- std::vector<PasswordForm*> forms; |
- forms.push_back(CreatePasswordFormFromData(expected_form_data)); |
+ ScopedVector<autofill::PasswordForm> expected_forms; |
+ expected_forms.push_back(CreatePasswordFormFromData(expected_form_data)); |
// The IE7 password should be returned. |
EXPECT_CALL(password_consumer, |
- OnGetPasswordStoreResults(ContainsAllPasswordForms(forms))) |
- .WillOnce(QuitUIMessageLoop()); |
+ OnGetPasswordStoreResultsConstRef( |
+ ContainsSamePasswordForms(expected_forms.get()))); |
store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &password_consumer); |
MockWebDataServiceConsumer wds_consumer; |
- EXPECT_CALL(wds_consumer, |
- OnWebDataServiceRequestDone(_, _)) |
+ EXPECT_CALL(wds_consumer, OnWebDataServiceRequestDone(_, _)) |
.WillOnce(QuitUIMessageLoop()); |
wds_->GetIE7Login(password_info, &wds_consumer); |
@@ -358,8 +358,6 @@ TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { |
// thread. |
base::MessageLoop::current()->Run(); |
base::MessageLoop::current()->Run(); |
- |
- STLDeleteElements(&forms); |
} |
TEST_F(PasswordStoreWinTest, EmptyLogins) { |
@@ -378,19 +376,15 @@ TEST_F(PasswordStoreWinTest, EmptyLogins) { |
L"", |
true, false, 1, |
}; |
- scoped_ptr<PasswordForm> form(CreatePasswordFormFromData(form_data)); |
+ scoped_ptr<PasswordForm> form = CreatePasswordFormFromData(form_data); |
MockPasswordStoreConsumer consumer; |
// Make sure we quit the MessageLoop even if the test fails. |
- ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
+ ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
.WillByDefault(QuitUIMessageLoop()); |
- VectorOfForms expect_none; |
- // expect that we get no results; |
- EXPECT_CALL(consumer, |
- OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) |
- .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); |
+ EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
base::MessageLoop::current()->Run(); |
@@ -403,15 +397,10 @@ TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) { |
MockPasswordStoreConsumer consumer; |
// Make sure we quit the MessageLoop even if the test fails. |
- ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
+ ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
.WillByDefault(QuitUIMessageLoop()); |
- VectorOfForms expect_none; |
- // expect that we get no results; |
- EXPECT_CALL( |
- consumer, |
- OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) |
- .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); |
+ EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
store_->GetBlacklistLogins(&consumer); |
base::MessageLoop::current()->Run(); |
@@ -424,15 +413,10 @@ TEST_F(PasswordStoreWinTest, EmptyAutofillableLogins) { |
MockPasswordStoreConsumer consumer; |
// Make sure we quit the MessageLoop even if the test fails. |
- ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
+ ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
.WillByDefault(QuitUIMessageLoop()); |
- VectorOfForms expect_none; |
- // expect that we get no results; |
- EXPECT_CALL( |
- consumer, |
- OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) |
- .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); |
+ EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
store_->GetAutofillableLogins(&consumer); |
base::MessageLoop::current()->Run(); |