| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
| 7 #include "base/prefs/testing_pref_service.h" | 7 #include "base/prefs/testing_pref_service.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/autofill/autofill_external_delegate.h" |
| 9 #include "chrome/browser/autofill/autofill_manager.h" | 10 #include "chrome/browser/autofill/autofill_manager.h" |
| 10 #include "chrome/browser/autofill/autofill_manager_delegate.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/autofill/test_autofill_manager_delegate.h" |
| 12 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 13 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 13 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.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/display.h" | 19 #include "ui/gfx/display.h" |
| 19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 20 | 21 |
| 21 using ::testing::_; | 22 using ::testing::_; |
| 22 using ::testing::AtLeast; | 23 using ::testing::AtLeast; |
| 23 using ::testing::NiceMock; | 24 using ::testing::NiceMock; |
| 24 using base::WeakPtr; | 25 using base::WeakPtr; |
| 25 using WebKit::WebAutofillClient; | 26 using WebKit::WebAutofillClient; |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 class MockAutofillExternalDelegate : | 30 class MockAutofillExternalDelegate : public AutofillExternalDelegate { |
| 30 public autofill::TestAutofillExternalDelegate { | |
| 31 public: | 31 public: |
| 32 MockAutofillExternalDelegate(content::WebContents* web_contents, | 32 MockAutofillExternalDelegate(content::WebContents* web_contents, |
| 33 AutofillManager* autofill_manager) | 33 AutofillManager* autofill_manager) |
| 34 : TestAutofillExternalDelegate(web_contents, autofill_manager) {} | 34 : AutofillExternalDelegate(web_contents, autofill_manager) {} |
| 35 virtual ~MockAutofillExternalDelegate() {} | 35 virtual ~MockAutofillExternalDelegate() {} |
| 36 | 36 |
| 37 virtual void DidSelectSuggestion(int identifier) OVERRIDE {} | 37 virtual void DidSelectSuggestion(int identifier) OVERRIDE {} |
| 38 virtual void RemoveSuggestion(const string16& value, int identifier) OVERRIDE | 38 virtual void RemoveSuggestion(const string16& value, int identifier) OVERRIDE |
| 39 {} | 39 {} |
| 40 virtual void ClearPreviewedForm() OVERRIDE {} | 40 virtual void ClearPreviewedForm() OVERRIDE {} |
| 41 | |
| 42 MOCK_METHOD0(ControllerDestroyed, void()); | |
| 43 }; | 41 }; |
| 44 | 42 |
| 45 class MockAutofillManagerDelegate : public autofill::AutofillManagerDelegate { | 43 class MockAutofillManagerDelegate |
| 44 : public autofill::TestAutofillManagerDelegate { |
| 46 public: | 45 public: |
| 47 MockAutofillManagerDelegate() {} | 46 MockAutofillManagerDelegate() {} |
| 48 virtual ~MockAutofillManagerDelegate() {} | 47 virtual ~MockAutofillManagerDelegate() {} |
| 49 | 48 |
| 50 // AutofillManagerDelegate: | |
| 51 virtual PersonalDataManager* GetPersonalDataManager() OVERRIDE { | |
| 52 return NULL; | |
| 53 } | |
| 54 virtual InfoBarService* GetInfoBarService() { return NULL; } | |
| 55 virtual PrefService* GetPrefs() { return &prefs_; } | 49 virtual PrefService* GetPrefs() { return &prefs_; } |
| 56 virtual ProfileSyncServiceBase* GetProfileSyncService() { return NULL; } | |
| 57 virtual void HideRequestAutocompleteDialog() OVERRIDE {} | |
| 58 virtual bool IsSavingPasswordsEnabled() const { return false; } | |
| 59 virtual void OnAutocheckoutError() OVERRIDE {} | |
| 60 virtual void ShowAutofillSettings() {} | |
| 61 virtual void ShowPasswordGenerationBubble( | |
| 62 const gfx::Rect& bounds, | |
| 63 const content::PasswordForm& form, | |
| 64 autofill::PasswordGenerator* generator) {} | |
| 65 virtual void ShowAutocheckoutBubble( | |
| 66 const gfx::RectF& bounding_box, | |
| 67 const gfx::NativeView& native_view, | |
| 68 const base::Closure& callback) {} | |
| 69 virtual void ShowRequestAutocompleteDialog( | |
| 70 const FormData& form, | |
| 71 const GURL& source_url, | |
| 72 const content::SSLStatus& ssl_status, | |
| 73 const AutofillMetrics& metric_logger, | |
| 74 autofill::DialogType dialog_type, | |
| 75 const base::Callback<void(const FormStructure*)>& callback) {} | |
| 76 virtual void RequestAutocompleteDialogClosed() {} | |
| 77 virtual void UpdateProgressBar(double value) {} | |
| 78 | 50 |
| 79 private: | 51 private: |
| 80 TestingPrefServiceSimple prefs_; | 52 TestingPrefServiceSimple prefs_; |
| 81 | 53 |
| 82 DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); | 54 DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); |
| 83 }; | 55 }; |
| 84 | 56 |
| 85 class TestAutofillPopupController : public AutofillPopupControllerImpl { | 57 class TestAutofillPopupController : public AutofillPopupControllerImpl { |
| 86 public: | 58 public: |
| 87 explicit TestAutofillPopupController( | 59 explicit TestAutofillPopupController( |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 autofill_popup_controller->Show(names, names, names, autofill_ids); | 434 autofill_popup_controller->Show(names, names, names, autofill_ids); |
| 463 | 435 |
| 464 EXPECT_EQ(expected_popup_bounds[i].ToString(), | 436 EXPECT_EQ(expected_popup_bounds[i].ToString(), |
| 465 autofill_popup_controller->popup_bounds().ToString()) << | 437 autofill_popup_controller->popup_bounds().ToString()) << |
| 466 "Popup bounds failed to match for test " << i; | 438 "Popup bounds failed to match for test " << i; |
| 467 | 439 |
| 468 // Hide the controller to delete it. | 440 // Hide the controller to delete it. |
| 469 autofill_popup_controller->DoHide(); | 441 autofill_popup_controller->DoHide(); |
| 470 } | 442 } |
| 471 } | 443 } |
| OLD | NEW |