| 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/autofill/tab_autofill_manager_delegate.h" | 12 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
| 13 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" | |
| 14 #include "chrome/common/form_data.h" | 13 #include "chrome/common/form_data.h" |
| 15 #include "chrome/common/form_field_data.h" | 14 #include "chrome/common/form_field_data.h" |
| 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/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 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" |
| 21 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
| 22 | 22 |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 using testing::_; | 24 using testing::_; |
| 25 using WebKit::WebAutofillClient; | 25 using WebKit::WebAutofillClient; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 const FormData& form, | 73 const FormData& form, |
| 74 const FormFieldData& field, | 74 const FormFieldData& field, |
| 75 int unique_id)); | 75 int unique_id)); |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 virtual ~MockAutofillManager() {} | 78 virtual ~MockAutofillManager() {} |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness { | 83 class AutofillExternalDelegateUnitTest |
| 84 : public ChromeRenderViewHostTestHarness { |
| 84 public: | 85 public: |
| 85 AutofillExternalDelegateUnitTest() | 86 AutofillExternalDelegateUnitTest() |
| 86 : ui_thread_(BrowserThread::UI, &message_loop_) {} | 87 : ui_thread_(BrowserThread::UI, &message_loop_) {} |
| 87 virtual ~AutofillExternalDelegateUnitTest() {} | 88 virtual ~AutofillExternalDelegateUnitTest() {} |
| 88 | 89 |
| 89 virtual void SetUp() OVERRIDE { | 90 virtual void SetUp() OVERRIDE { |
| 90 TabContentsTestHarness::SetUp(); | 91 ChromeRenderViewHostTestHarness::SetUp(); |
| 91 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); | 92 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); |
| 92 autofill_manager_ = new MockAutofillManager( | 93 autofill_manager_ = new MockAutofillManager( |
| 93 web_contents(), | 94 web_contents(), |
| 94 TabAutofillManagerDelegate::FromWebContents(web_contents())); | 95 TabAutofillManagerDelegate::FromWebContents(web_contents())); |
| 95 external_delegate_.reset(new MockAutofillExternalDelegate( | 96 external_delegate_.reset(new MockAutofillExternalDelegate( |
| 96 web_contents(), | 97 web_contents(), |
| 97 autofill_manager_)); | 98 autofill_manager_)); |
| 98 } | 99 } |
| 99 | 100 |
| 100 protected: | 101 protected: |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 external_delegate_->SelectAutofillSuggestionAtIndex(1); | 244 external_delegate_->SelectAutofillSuggestionAtIndex(1); |
| 244 } | 245 } |
| 245 | 246 |
| 246 // Test that the popup is hidden once we are done editing the autofill field. | 247 // Test that the popup is hidden once we are done editing the autofill field. |
| 247 TEST_F(AutofillExternalDelegateUnitTest, | 248 TEST_F(AutofillExternalDelegateUnitTest, |
| 248 ExternalDelegateHidePopupAfterEditing) { | 249 ExternalDelegateHidePopupAfterEditing) { |
| 249 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); | 250 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); |
| 250 | 251 |
| 251 external_delegate_->DidEndTextFieldEditing(); | 252 external_delegate_->DidEndTextFieldEditing(); |
| 252 } | 253 } |
| OLD | NEW |