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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/password_manager/password_manager.h" | 10 #include "chrome/browser/password_manager/password_manager.h" |
11 #include "chrome/browser/password_manager/password_manager_delegate.h" | 11 #include "chrome/browser/password_manager/password_manager_delegate.h" |
12 #include "chrome/browser/password_manager/password_store.h" | 12 #include "chrome/browser/password_manager/password_store.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
16 #include "content/browser/tab_contents/test_tab_contents.h" | 16 #include "content/browser/tab_contents/test_tab_contents.h" |
17 #include "content/test/test_browser_thread.h" | 17 #include "content/test/test_browser_thread.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 using content::BrowserThread; | 21 using content::BrowserThread; |
22 using webkit_glue::PasswordForm; | 22 using webkit::forms::PasswordForm; |
23 using testing::_; | 23 using testing::_; |
24 using testing::DoAll; | 24 using testing::DoAll; |
25 using ::testing::Exactly; | 25 using ::testing::Exactly; |
26 using ::testing::WithArg; | 26 using ::testing::WithArg; |
27 using ::testing::Return; | 27 using ::testing::Return; |
28 | 28 |
29 class MockPasswordManagerDelegate : public PasswordManagerDelegate { | 29 class MockPasswordManagerDelegate : public PasswordManagerDelegate { |
30 public: | 30 public: |
31 MOCK_METHOD1(FillPasswordForm, void( | 31 MOCK_METHOD1(FillPasswordForm, void( |
32 const webkit_glue::PasswordFormFillData&)); | 32 const webkit::forms::PasswordFormFillData&)); |
33 MOCK_METHOD1(AddSavePasswordInfoBar, void(PasswordFormManager*)); | 33 MOCK_METHOD1(AddSavePasswordInfoBar, void(PasswordFormManager*)); |
34 MOCK_METHOD0(GetProfileForPasswordManager, Profile*()); | 34 MOCK_METHOD0(GetProfileForPasswordManager, Profile*()); |
35 MOCK_METHOD0(DidLastPageLoadEncounterSSLErrors, bool()); | 35 MOCK_METHOD0(DidLastPageLoadEncounterSSLErrors, bool()); |
36 }; | 36 }; |
37 | 37 |
38 class TestingProfileWithPasswordStore : public TestingProfile { | 38 class TestingProfileWithPasswordStore : public TestingProfile { |
39 public: | 39 public: |
40 explicit TestingProfileWithPasswordStore(PasswordStore* store) | 40 explicit TestingProfileWithPasswordStore(PasswordStore* store) |
41 : store_(store) {} | 41 : store_(store) {} |
42 virtual ~TestingProfileWithPasswordStore() { | 42 virtual ~TestingProfileWithPasswordStore() { |
(...skipping 16 matching lines...) Expand all Loading... |
59 MOCK_METHOD0(ReportMetricsImpl, void()); | 59 MOCK_METHOD0(ReportMetricsImpl, void()); |
60 MOCK_METHOD1(AddLoginImpl, void(const PasswordForm&)); | 60 MOCK_METHOD1(AddLoginImpl, void(const PasswordForm&)); |
61 MOCK_METHOD1(UpdateLoginImpl, void(const PasswordForm&)); | 61 MOCK_METHOD1(UpdateLoginImpl, void(const PasswordForm&)); |
62 MOCK_METHOD1(RemoveLoginImpl, void(const PasswordForm&)); | 62 MOCK_METHOD1(RemoveLoginImpl, void(const PasswordForm&)); |
63 MOCK_METHOD2(RemoveLoginsCreatedBetweenImpl, void(const base::Time&, | 63 MOCK_METHOD2(RemoveLoginsCreatedBetweenImpl, void(const base::Time&, |
64 const base::Time&)); | 64 const base::Time&)); |
65 MOCK_METHOD2(GetLoginsImpl, void(GetLoginsRequest*, const PasswordForm&)); | 65 MOCK_METHOD2(GetLoginsImpl, void(GetLoginsRequest*, const PasswordForm&)); |
66 MOCK_METHOD1(GetAutofillableLoginsImpl, void(GetLoginsRequest*)); | 66 MOCK_METHOD1(GetAutofillableLoginsImpl, void(GetLoginsRequest*)); |
67 MOCK_METHOD1(GetBlacklistLoginsImpl, void(GetLoginsRequest*)); | 67 MOCK_METHOD1(GetBlacklistLoginsImpl, void(GetLoginsRequest*)); |
68 MOCK_METHOD1(FillAutofillableLogins, | 68 MOCK_METHOD1(FillAutofillableLogins, |
69 bool(std::vector<webkit_glue::PasswordForm*>*)); | 69 bool(std::vector<webkit::forms::PasswordForm*>*)); |
70 MOCK_METHOD1(FillBlacklistLogins, | 70 MOCK_METHOD1(FillBlacklistLogins, |
71 bool(std::vector<webkit_glue::PasswordForm*>*)); | 71 bool(std::vector<webkit::forms::PasswordForm*>*)); |
72 }; | 72 }; |
73 | 73 |
74 ACTION_P2(InvokeConsumer, handle, forms) { | 74 ACTION_P2(InvokeConsumer, handle, forms) { |
75 arg0->OnPasswordStoreRequestDone(handle, forms); | 75 arg0->OnPasswordStoreRequestDone(handle, forms); |
76 } | 76 } |
77 | 77 |
78 ACTION_P(SaveToScopedPtr, scoped) { | 78 ACTION_P(SaveToScopedPtr, scoped) { |
79 scoped->reset(arg0); | 79 scoped->reset(arg0); |
80 } | 80 } |
81 | 81 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 EXPECT_CALL(*store_, GetLogins(_,_)) | 274 EXPECT_CALL(*store_, GetLogins(_,_)) |
275 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0))); | 275 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0))); |
276 std::vector<PasswordForm> observed; | 276 std::vector<PasswordForm> observed; |
277 PasswordForm form(MakeSimpleForm()); | 277 PasswordForm form(MakeSimpleForm()); |
278 observed.push_back(form); | 278 observed.push_back(form); |
279 manager()->OnPasswordFormsFound(observed); // The initial load. | 279 manager()->OnPasswordFormsFound(observed); // The initial load. |
280 // PasswordFormsVisible is not called. | 280 // PasswordFormsVisible is not called. |
281 | 281 |
282 manager()->DidStopLoading(); | 282 manager()->DidStopLoading(); |
283 } | 283 } |
OLD | NEW |