OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 #include <wincrypt.h> | 8 #include <wincrypt.h> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/scoped_temp_dir.h" | 12 #include "base/scoped_temp_dir.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "chrome/browser/password_manager/ie7_password.h" | 16 #include "chrome/browser/password_manager/ie7_password.h" |
17 #include "chrome/browser/password_manager/password_form_data.h" | 17 #include "chrome/browser/password_manager/password_form_data.h" |
18 #include "chrome/browser/password_manager/password_store_consumer.h" | 18 #include "chrome/browser/password_manager/password_store_consumer.h" |
19 #include "chrome/browser/password_manager/password_store_win.h" | 19 #include "chrome/browser/password_manager/password_store_win.h" |
20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
21 #include "chrome/browser/webdata/web_data_service.h" | 21 #include "chrome/browser/webdata/web_data_service.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/signaling_task.h" | 23 #include "chrome/test/base/signaling_task.h" |
24 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
| 25 #include "chrome/test/testing_browser_process_test.h" |
25 #include "content/browser/browser_thread.h" | 26 #include "content/browser/browser_thread.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
28 | 29 |
29 using base::WaitableEvent; | 30 using base::WaitableEvent; |
30 using testing::_; | 31 using testing::_; |
31 using testing::DoAll; | 32 using testing::DoAll; |
32 using testing::WithArg; | 33 using testing::WithArg; |
33 using webkit_glue::PasswordForm; | 34 using webkit_glue::PasswordForm; |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 class MockPasswordStoreConsumer : public PasswordStoreConsumer { | 38 class MockPasswordStoreConsumer : public PasswordStoreConsumer { |
38 public: | 39 public: |
39 MOCK_METHOD2(OnPasswordStoreRequestDone, | 40 MOCK_METHOD2(OnPasswordStoreRequestDone, |
40 void(CancelableRequestProvider::Handle, | 41 void(CancelableRequestProvider::Handle, |
41 const std::vector<webkit_glue::PasswordForm*>&)); | 42 const std::vector<webkit_glue::PasswordForm*>&)); |
42 }; | 43 }; |
43 | 44 |
44 class MockWebDataServiceConsumer : public WebDataServiceConsumer { | 45 class MockWebDataServiceConsumer : public WebDataServiceConsumer { |
45 public: | 46 public: |
46 MOCK_METHOD2(OnWebDataServiceRequestDone, | 47 MOCK_METHOD2(OnWebDataServiceRequestDone, |
47 void(WebDataService::Handle, const WDTypedResult*)); | 48 void(WebDataService::Handle, const WDTypedResult*)); |
48 }; | 49 }; |
49 | 50 |
50 } // anonymous namespace | 51 } // anonymous namespace |
51 | 52 |
52 typedef std::vector<PasswordForm*> VectorOfForms; | 53 typedef std::vector<PasswordForm*> VectorOfForms; |
53 | 54 |
54 class PasswordStoreWinTest : public testing::Test { | 55 class PasswordStoreWinTest : public TestingBrowserProcessTest { |
55 protected: | 56 protected: |
56 PasswordStoreWinTest() | 57 PasswordStoreWinTest() |
57 : ui_thread_(BrowserThread::UI, &message_loop_), | 58 : ui_thread_(BrowserThread::UI, &message_loop_), |
58 db_thread_(BrowserThread::DB) { | 59 db_thread_(BrowserThread::DB) { |
59 } | 60 } |
60 | 61 |
61 bool CreateIE7PasswordInfo(const std::wstring& url, const base::Time& created, | 62 bool CreateIE7PasswordInfo(const std::wstring& url, const base::Time& created, |
62 IE7PasswordInfo* info) { | 63 IE7PasswordInfo* info) { |
63 // Copied from chrome/browser/importer/importer_unittest.cc | 64 // Copied from chrome/browser/importer/importer_unittest.cc |
64 // The username is "abcdefgh" and the password "abcdefghijkl". | 65 // The username is "abcdefgh" and the password "abcdefghijkl". |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 // expect that we get no results; | 592 // expect that we get no results; |
592 EXPECT_CALL(consumer, OnPasswordStoreRequestDone( | 593 EXPECT_CALL(consumer, OnPasswordStoreRequestDone( |
593 _, ContainsAllPasswordForms(expect_none))) | 594 _, ContainsAllPasswordForms(expect_none))) |
594 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop())); | 595 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop())); |
595 | 596 |
596 store->GetAutofillableLogins(&consumer); | 597 store->GetAutofillableLogins(&consumer); |
597 MessageLoop::current()->Run(); | 598 MessageLoop::current()->Run(); |
598 | 599 |
599 store->Shutdown(); | 600 store->Shutdown(); |
600 } | 601 } |
OLD | NEW |