| 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 <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/tab_contents/test_tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/test/test_browser_thread.h" | 14 #include "content/public/test/test_browser_thread.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" |
| 18 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 19 #include "webkit/forms/form_data.h" | 19 #include "webkit/forms/form_data.h" |
| 20 #include "webkit/forms/form_field.h" | 20 #include "webkit/forms/form_field.h" |
| 21 | 21 |
| 22 using content::BrowserThread; | 22 using content::BrowserThread; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 const webkit::forms::FormData& form, | 66 const webkit::forms::FormData& form, |
| 67 const webkit::forms::FormField& field, | 67 const webkit::forms::FormField& field, |
| 68 int unique_id)); | 68 int unique_id)); |
| 69 | 69 |
| 70 protected: | 70 protected: |
| 71 virtual ~MockAutofillManager() {} | 71 virtual ~MockAutofillManager() {} |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 | 75 |
| 76 class AutofillExternalDelegateUnitTest : public TabContentsWrapperTestHarness { | 76 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness { |
| 77 public: | 77 public: |
| 78 AutofillExternalDelegateUnitTest() | 78 AutofillExternalDelegateUnitTest() |
| 79 : ui_thread_(BrowserThread::UI, &message_loop_) {} | 79 : ui_thread_(BrowserThread::UI, &message_loop_) {} |
| 80 virtual ~AutofillExternalDelegateUnitTest() {} | 80 virtual ~AutofillExternalDelegateUnitTest() {} |
| 81 | 81 |
| 82 virtual void SetUp() OVERRIDE { | 82 virtual void SetUp() OVERRIDE { |
| 83 TabContentsWrapperTestHarness::SetUp(); | 83 TabContentsTestHarness::SetUp(); |
| 84 autofill_manager_ = new MockAutofillManager(contents_wrapper()); | 84 autofill_manager_ = new MockAutofillManager(tab_contents()); |
| 85 external_delegate_.reset(new MockAutofillExternalDelegate( | 85 external_delegate_.reset(new MockAutofillExternalDelegate( |
| 86 contents_wrapper(), | 86 tab_contents(), |
| 87 autofill_manager_)); | 87 autofill_manager_)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 scoped_refptr<MockAutofillManager> autofill_manager_; | 91 scoped_refptr<MockAutofillManager> autofill_manager_; |
| 92 scoped_ptr<MockAutofillExternalDelegate> external_delegate_; | 92 scoped_ptr<MockAutofillExternalDelegate> external_delegate_; |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 content::TestBrowserThread ui_thread_; | 95 content::TestBrowserThread ui_thread_; |
| 96 | 96 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 external_delegate_->SelectAutofillSuggestionAtIndex(1); | 166 external_delegate_->SelectAutofillSuggestionAtIndex(1); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Test that the popup is hidden once we are done editing the autofill field. | 169 // Test that the popup is hidden once we are done editing the autofill field. |
| 170 TEST_F(AutofillExternalDelegateUnitTest, | 170 TEST_F(AutofillExternalDelegateUnitTest, |
| 171 ExternalDelegateHidePopupAfterEditing) { | 171 ExternalDelegateHidePopupAfterEditing) { |
| 172 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); | 172 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); |
| 173 | 173 |
| 174 external_delegate_->DidEndTextFieldEditing(); | 174 external_delegate_->DidEndTextFieldEditing(); |
| 175 } | 175 } |
| OLD | NEW |