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..0bc83823318d34f24c8e1c77c71da30ff8cb5b85 100644 |
--- a/chrome/browser/password_manager/password_store_win_unittest.cc |
+++ b/chrome/browser/password_manager/password_store_win_unittest.cc |
@@ -34,7 +34,6 @@ using autofill::PasswordForm; |
using base::WaitableEvent; |
using content::BrowserThread; |
using password_manager::LoginDatabase; |
-using password_manager::ContainsAllPasswordForms; |
using password_manager::PasswordFormData; |
using password_manager::PasswordStore; |
using password_manager::PasswordStoreConsumer; |
@@ -46,8 +45,7 @@ namespace { |
class MockPasswordStoreConsumer : public PasswordStoreConsumer { |
public: |
- MOCK_METHOD1(OnGetPasswordStoreResults, |
- void(const std::vector<autofill::PasswordForm*>&)); |
+ MOCK_METHOD0(OnGetPasswordStoreResults, void()); |
}; |
class MockWebDataServiceConsumer : public WebDataServiceConsumer { |
@@ -58,8 +56,6 @@ public: |
} // anonymous namespace |
-typedef std::vector<PasswordForm*> VectorOfForms; |
- |
class PasswordStoreWinTest : public testing::Test { |
protected: |
PasswordStoreWinTest() |
@@ -211,7 +207,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, OnGetPasswordStoreResults()) |
.WillByDefault(QuitUIMessageLoop()); |
PasswordFormData form_data = { |
@@ -242,18 +238,18 @@ TEST_F(PasswordStoreWinTest, DISABLED_ConvertIE7Login) { |
L"abcdefghijkl", |
true, false, 1, |
}; |
- std::vector<PasswordForm*> forms; |
- forms.push_back(CreatePasswordFormFromData(expected_form_data)); |
+ scoped_ptr<autofill::PasswordForm> expected_form( |
+ CreatePasswordFormFromData(expected_form_data)); |
vasilii
2015/02/03 19:22:16
Did you consider changing this function to return
vabr (Chromium)
2015/02/04 16:13:44
Good idea! Done.
I updated both copies of the fun
|
// The IE7 password should be returned. |
- EXPECT_CALL(consumer, |
- OnGetPasswordStoreResults(ContainsAllPasswordForms(forms))) |
+ EXPECT_CALL(consumer, OnGetPasswordStoreResults()) |
.WillOnce(QuitUIMessageLoop()); |
store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
base::MessageLoop::current()->Run(); |
- STLDeleteElements(&forms); |
+ EXPECT_EQ(1u, consumer.results()->size()); |
+ EXPECT_EQ(*expected_form, *consumer.results()->back()); |
} |
// Crashy. http://crbug.com/86558 |
@@ -306,7 +302,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, OnGetPasswordStoreResults()) |
.WillByDefault(QuitUIMessageLoop()); |
PasswordFormData form_data = { |
@@ -335,12 +331,11 @@ TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { |
L"abcdefghijkl", |
true, false, 1, |
}; |
- std::vector<PasswordForm*> forms; |
- forms.push_back(CreatePasswordFormFromData(expected_form_data)); |
+ scoped_ptr<autofill::PasswordForm> expected_form( |
+ CreatePasswordFormFromData(expected_form_data)); |
// The IE7 password should be returned. |
- EXPECT_CALL(password_consumer, |
- OnGetPasswordStoreResults(ContainsAllPasswordForms(forms))) |
+ EXPECT_CALL(password_consumer, OnGetPasswordStoreResults()) |
.WillOnce(QuitUIMessageLoop()); |
store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &password_consumer); |
@@ -359,7 +354,8 @@ TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { |
base::MessageLoop::current()->Run(); |
base::MessageLoop::current()->Run(); |
- STLDeleteElements(&forms); |
+ EXPECT_EQ(1u, password_consumer.results()->size()); |
+ EXPECT_EQ(*expected_form, *password_consumer.results()->back()); |
} |
TEST_F(PasswordStoreWinTest, EmptyLogins) { |
@@ -383,17 +379,16 @@ TEST_F(PasswordStoreWinTest, EmptyLogins) { |
MockPasswordStoreConsumer consumer; |
// Make sure we quit the MessageLoop even if the test fails. |
- ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
+ ON_CALL(consumer, OnGetPasswordStoreResults()) |
.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, OnGetPasswordStoreResults()) |
+ .WillOnce(QuitUIMessageLoop()); |
store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
base::MessageLoop::current()->Run(); |
+ |
+ EXPECT_EQ(0u, consumer.results()->size()); |
} |
TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) { |
@@ -403,18 +398,16 @@ TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) { |
MockPasswordStoreConsumer consumer; |
// Make sure we quit the MessageLoop even if the test fails. |
- ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
+ ON_CALL(consumer, OnGetPasswordStoreResults()) |
.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, OnGetPasswordStoreResults()) |
+ .WillOnce(QuitUIMessageLoop()); |
store_->GetBlacklistLogins(&consumer); |
base::MessageLoop::current()->Run(); |
+ |
+ EXPECT_EQ(0u, consumer.results()->size()); |
} |
TEST_F(PasswordStoreWinTest, EmptyAutofillableLogins) { |
@@ -424,16 +417,14 @@ TEST_F(PasswordStoreWinTest, EmptyAutofillableLogins) { |
MockPasswordStoreConsumer consumer; |
// Make sure we quit the MessageLoop even if the test fails. |
- ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
+ ON_CALL(consumer, OnGetPasswordStoreResults()) |
.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, OnGetPasswordStoreResults()) |
+ .WillOnce(QuitUIMessageLoop()); |
store_->GetAutofillableLogins(&consumer); |
base::MessageLoop::current()->Run(); |
+ |
+ EXPECT_EQ(0u, consumer.results()->size()); |
} |