OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "components/password_manager/core/common/password_manager_pref_names.h" | 26 #include "components/password_manager/core/common/password_manager_pref_names.h" |
27 #include "components/webdata/common/web_database_service.h" | 27 #include "components/webdata/common/web_database_service.h" |
28 #include "content/public/test/test_browser_thread.h" | 28 #include "content/public/test/test_browser_thread.h" |
29 #include "crypto/wincrypt_shim.h" | 29 #include "crypto/wincrypt_shim.h" |
30 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
32 | 32 |
33 using autofill::PasswordForm; | 33 using autofill::PasswordForm; |
34 using base::WaitableEvent; | 34 using base::WaitableEvent; |
35 using content::BrowserThread; | 35 using content::BrowserThread; |
36 using password_manager::ContainsSamePasswordForms; | |
37 using password_manager::LoginDatabase; | 36 using password_manager::LoginDatabase; |
38 using password_manager::PasswordFormData; | 37 using password_manager::PasswordFormData; |
39 using password_manager::PasswordStore; | 38 using password_manager::PasswordStore; |
40 using password_manager::PasswordStoreConsumer; | 39 using password_manager::PasswordStoreConsumer; |
| 40 using password_manager::UnorderedPasswordFormElementsAre; |
41 using testing::_; | 41 using testing::_; |
42 using testing::DoAll; | 42 using testing::DoAll; |
43 using testing::IsEmpty; | 43 using testing::IsEmpty; |
44 using testing::WithArg; | 44 using testing::WithArg; |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 class MockPasswordStoreConsumer : public PasswordStoreConsumer { | 48 class MockPasswordStoreConsumer : public PasswordStoreConsumer { |
49 public: | 49 public: |
50 MOCK_METHOD1(OnGetPasswordStoreResultsConstRef, | 50 MOCK_METHOD1(OnGetPasswordStoreResultsConstRef, |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 L"", | 245 L"", |
246 L"abcdefgh", | 246 L"abcdefgh", |
247 L"abcdefghijkl", | 247 L"abcdefghijkl", |
248 true, false, 1, | 248 true, false, 1, |
249 }; | 249 }; |
250 ScopedVector<autofill::PasswordForm> expected_forms; | 250 ScopedVector<autofill::PasswordForm> expected_forms; |
251 expected_forms.push_back( | 251 expected_forms.push_back( |
252 CreatePasswordFormFromDataForTesting(expected_form_data)); | 252 CreatePasswordFormFromDataForTesting(expected_form_data)); |
253 | 253 |
254 // The IE7 password should be returned. | 254 // The IE7 password should be returned. |
255 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef( | 255 EXPECT_CALL(consumer, |
256 ContainsSamePasswordForms(expected_forms.get()))); | 256 OnGetPasswordStoreResultsConstRef( |
| 257 UnorderedPasswordFormElementsAre(expected_forms.get()))); |
257 | 258 |
258 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); | 259 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
259 base::MessageLoop::current()->Run(); | 260 base::MessageLoop::current()->Run(); |
260 } | 261 } |
261 | 262 |
262 // Crashy. http://crbug.com/86558 | 263 // Crashy. http://crbug.com/86558 |
263 TEST_F(PasswordStoreWinTest, DISABLED_OutstandingWDSQueries) { | 264 TEST_F(PasswordStoreWinTest, DISABLED_OutstandingWDSQueries) { |
264 store_ = CreatePasswordStore(); | 265 store_ = CreatePasswordStore(); |
265 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 266 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); |
266 | 267 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 L"abcdefghijkl", | 341 L"abcdefghijkl", |
341 true, false, 1, | 342 true, false, 1, |
342 }; | 343 }; |
343 ScopedVector<autofill::PasswordForm> expected_forms; | 344 ScopedVector<autofill::PasswordForm> expected_forms; |
344 expected_forms.push_back( | 345 expected_forms.push_back( |
345 CreatePasswordFormFromDataForTesting(expected_form_data)); | 346 CreatePasswordFormFromDataForTesting(expected_form_data)); |
346 | 347 |
347 // The IE7 password should be returned. | 348 // The IE7 password should be returned. |
348 EXPECT_CALL(password_consumer, | 349 EXPECT_CALL(password_consumer, |
349 OnGetPasswordStoreResultsConstRef( | 350 OnGetPasswordStoreResultsConstRef( |
350 ContainsSamePasswordForms(expected_forms.get()))); | 351 UnorderedPasswordFormElementsAre(expected_forms.get()))); |
351 | 352 |
352 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &password_consumer); | 353 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &password_consumer); |
353 | 354 |
354 MockWebDataServiceConsumer wds_consumer; | 355 MockWebDataServiceConsumer wds_consumer; |
355 | 356 |
356 EXPECT_CALL(wds_consumer, OnWebDataServiceRequestDone(_, _)) | 357 EXPECT_CALL(wds_consumer, OnWebDataServiceRequestDone(_, _)) |
357 .WillOnce(QuitUIMessageLoop()); | 358 .WillOnce(QuitUIMessageLoop()); |
358 | 359 |
359 wds_->GetIE7Login(password_info, &wds_consumer); | 360 wds_->GetIE7Login(password_info, &wds_consumer); |
360 | 361 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 421 |
421 // Make sure we quit the MessageLoop even if the test fails. | 422 // Make sure we quit the MessageLoop even if the test fails. |
422 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) | 423 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
423 .WillByDefault(QuitUIMessageLoop()); | 424 .WillByDefault(QuitUIMessageLoop()); |
424 | 425 |
425 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 426 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
426 | 427 |
427 store_->GetAutofillableLogins(&consumer); | 428 store_->GetAutofillableLogins(&consumer); |
428 base::MessageLoop::current()->Run(); | 429 base::MessageLoop::current()->Run(); |
429 } | 430 } |
OLD | NEW |