| 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/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 10 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 10 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 public: | 73 public: |
| 74 explicit TestAutofillPopupController( | 74 explicit TestAutofillPopupController( |
| 75 base::WeakPtr<AutofillExternalDelegate> external_delegate, | 75 base::WeakPtr<AutofillExternalDelegate> external_delegate, |
| 76 const gfx::RectF& element_bounds) | 76 const gfx::RectF& element_bounds) |
| 77 : AutofillPopupControllerImpl( | 77 : AutofillPopupControllerImpl( |
| 78 external_delegate, NULL, NULL, element_bounds, | 78 external_delegate, NULL, NULL, element_bounds, |
| 79 base::i18n::UNKNOWN_DIRECTION), | 79 base::i18n::UNKNOWN_DIRECTION), |
| 80 test_controller_common_(new TestPopupControllerCommon(element_bounds)) { | 80 test_controller_common_(new TestPopupControllerCommon(element_bounds)) { |
| 81 controller_common_.reset(test_controller_common_); | 81 controller_common_.reset(test_controller_common_); |
| 82 } | 82 } |
| 83 virtual ~TestAutofillPopupController() {} | 83 ~TestAutofillPopupController() override {} |
| 84 | 84 |
| 85 void set_display(const gfx::Display& display) { | 85 void set_display(const gfx::Display& display) { |
| 86 test_controller_common_->set_display(display); | 86 test_controller_common_->set_display(display); |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Making protected functions public for testing | 89 // Making protected functions public for testing |
| 90 using AutofillPopupControllerImpl::SetPopupBounds; | 90 using AutofillPopupControllerImpl::SetPopupBounds; |
| 91 using AutofillPopupControllerImpl::GetLineCount; | 91 using AutofillPopupControllerImpl::GetLineCount; |
| 92 using AutofillPopupControllerImpl::GetSuggestionAt; | 92 using AutofillPopupControllerImpl::GetSuggestionAt; |
| 93 using AutofillPopupControllerImpl::GetElidedValueAt; | 93 using AutofillPopupControllerImpl::GetElidedValueAt; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 110 using AutofillPopupControllerImpl::GetWeakPtr; | 110 using AutofillPopupControllerImpl::GetWeakPtr; |
| 111 MOCK_METHOD1(InvalidateRow, void(size_t)); | 111 MOCK_METHOD1(InvalidateRow, void(size_t)); |
| 112 MOCK_METHOD0(UpdateBoundsAndRedrawPopup, void()); | 112 MOCK_METHOD0(UpdateBoundsAndRedrawPopup, void()); |
| 113 MOCK_METHOD0(Hide, void()); | 113 MOCK_METHOD0(Hide, void()); |
| 114 | 114 |
| 115 void DoHide() { | 115 void DoHide() { |
| 116 AutofillPopupControllerImpl::Hide(); | 116 AutofillPopupControllerImpl::Hide(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 virtual void ShowView() override {} | 120 void ShowView() override {} |
| 121 | 121 |
| 122 TestPopupControllerCommon* test_controller_common_; | 122 TestPopupControllerCommon* test_controller_common_; |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 } // namespace | 125 } // namespace |
| 126 | 126 |
| 127 class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness { | 127 class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness { |
| 128 public: | 128 public: |
| 129 AutofillPopupControllerUnitTest() | 129 AutofillPopupControllerUnitTest() |
| 130 : autofill_client_(new MockAutofillClient()), | 130 : autofill_client_(new MockAutofillClient()), |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 | 524 |
| 525 // The second element was shorter so it should be unchanged. | 525 // The second element was shorter so it should be unchanged. |
| 526 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).value, | 526 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).value, |
| 527 autofill_popup_controller_->GetElidedValueAt(1)); | 527 autofill_popup_controller_->GetElidedValueAt(1)); |
| 528 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).label, | 528 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).label, |
| 529 autofill_popup_controller_->GetElidedLabelAt(1)); | 529 autofill_popup_controller_->GetElidedLabelAt(1)); |
| 530 } | 530 } |
| 531 #endif | 531 #endif |
| 532 | 532 |
| 533 } // namespace autofill | 533 } // namespace autofill |
| OLD | NEW |