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..6a7840d06c45b186f3876542edbe385ce2789ba3 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,16 @@ 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))) |
+ EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef( |
+ ContainsSamePasswordForms(expected_forms.get()))) |
.WillOnce(QuitUIMessageLoop()); |
vasilii
2015/02/09 10:08:35
Not needed given the line #219
vabr (Chromium)
2015/02/09 11:36:06
Done.
|
store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
base::MessageLoop::current()->Run(); |
- |
- STLDeleteElements(&forms); |
} |
// Crashy. http://crbug.com/86558 |
@@ -273,7 +275,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 +308,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 +323,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,13 +337,13 @@ 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()))).WillOnce(QuitUIMessageLoop()); |
vasilii
2015/02/09 10:08:35
QuitUIMessageLoop() not needed
vabr (Chromium)
2015/02/09 11:36:06
Done.
|
store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &password_consumer); |
@@ -358,8 +360,6 @@ TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { |
// thread. |
base::MessageLoop::current()->Run(); |
base::MessageLoop::current()->Run(); |
- |
- STLDeleteElements(&forms); |
} |
TEST_F(PasswordStoreWinTest, EmptyLogins) { |
@@ -378,19 +378,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 +399,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 +415,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(); |