Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: chrome/browser/autofill/autofill_external_delegate_unittest.cc

Issue 10837363: Introduce AutofillClient and use it to get rid of PasswordManager dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix header Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/autofill/autofill_manager.h" 10 #include "chrome/browser/autofill/autofill_manager.h"
11 #include "chrome/browser/autofill/test_autofill_external_delegate.h" 11 #include "chrome/browser/autofill/test_autofill_external_delegate.h"
12 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h"
12 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" 13 #include "chrome/browser/ui/tab_contents/test_tab_contents.h"
13 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h" 15 #include "content/public/test/test_browser_thread.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h"
18 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
19 #include "webkit/forms/form_data.h" 20 #include "webkit/forms/form_data.h"
20 #include "webkit/forms/form_field.h" 21 #include "webkit/forms/form_field.h"
21 22
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 59
59 private: 60 private:
60 virtual void HideAutofillPopupInternal() {}; 61 virtual void HideAutofillPopupInternal() {};
61 }; 62 };
62 63
63 class MockAutofillManager : public AutofillManager { 64 class MockAutofillManager : public AutofillManager {
64 public: 65 public:
65 explicit MockAutofillManager(TabContents* tab_contents) 66 explicit MockAutofillManager(TabContents* tab_contents)
66 // Force to use the constructor designated for unit test, but we don't 67 // Force to use the constructor designated for unit test, but we don't
67 // really need personal_data in this test so we pass a NULL pointer. 68 // really need personal_data in this test so we pass a NULL pointer.
68 : AutofillManager(tab_contents, NULL) {} 69 : AutofillManager(&delegate_, tab_contents, NULL),
70 delegate_(tab_contents) {
71 }
69 72
70 MOCK_METHOD4(OnFillAutofillFormData, 73 MOCK_METHOD4(OnFillAutofillFormData,
71 void(int query_id, 74 void(int query_id,
72 const webkit::forms::FormData& form, 75 const webkit::forms::FormData& form,
73 const webkit::forms::FormField& field, 76 const webkit::forms::FormField& field,
74 int unique_id)); 77 int unique_id));
75 78
76 protected: 79 protected:
77 virtual ~MockAutofillManager() {} 80 virtual ~MockAutofillManager() {}
81
82 private:
83 TabAutofillManagerDelegate delegate_;
78 }; 84 };
79 85
80 } // namespace 86 } // namespace
81 87
82 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness { 88 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness {
83 public: 89 public:
84 AutofillExternalDelegateUnitTest() 90 AutofillExternalDelegateUnitTest()
85 : ui_thread_(BrowserThread::UI, &message_loop_) {} 91 : ui_thread_(BrowserThread::UI, &message_loop_) {}
86 virtual ~AutofillExternalDelegateUnitTest() {} 92 virtual ~AutofillExternalDelegateUnitTest() {}
87 93
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 external_delegate_->SelectAutofillSuggestionAtIndex(1); 245 external_delegate_->SelectAutofillSuggestionAtIndex(1);
240 } 246 }
241 247
242 // Test that the popup is hidden once we are done editing the autofill field. 248 // Test that the popup is hidden once we are done editing the autofill field.
243 TEST_F(AutofillExternalDelegateUnitTest, 249 TEST_F(AutofillExternalDelegateUnitTest,
244 ExternalDelegateHidePopupAfterEditing) { 250 ExternalDelegateHidePopupAfterEditing) {
245 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); 251 EXPECT_CALL(*external_delegate_, HideAutofillPopup());
246 252
247 external_delegate_->DidEndTextFieldEditing(); 253 external_delegate_->DidEndTextFieldEditing();
248 } 254 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/api/autofill_manager_delegate.h ('k') | chrome/browser/autofill/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698