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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
11 #include "build/build_config.h" | 12 #include "build/build_config.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/browser/ui/autofill/autofill_popup_view.h" | 14 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
16 #include "components/autofill/content/browser/content_autofill_driver.h" | 17 #include "components/autofill/content/browser/content_autofill_driver.h" |
17 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 18 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
18 #include "components/autofill/core/browser/autofill_external_delegate.h" | 19 #include "components/autofill/core/browser/autofill_external_delegate.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 }; | 58 }; |
58 | 59 |
59 class MockAutofillClient : public autofill::TestAutofillClient { | 60 class MockAutofillClient : public autofill::TestAutofillClient { |
60 public: | 61 public: |
61 MockAutofillClient() : prefs_(autofill::test::PrefServiceForTesting()) {} | 62 MockAutofillClient() : prefs_(autofill::test::PrefServiceForTesting()) {} |
62 ~MockAutofillClient() override {} | 63 ~MockAutofillClient() override {} |
63 | 64 |
64 PrefService* GetPrefs() override { return prefs_.get(); } | 65 PrefService* GetPrefs() override { return prefs_.get(); } |
65 | 66 |
66 private: | 67 private: |
67 scoped_ptr<PrefService> prefs_; | 68 std::unique_ptr<PrefService> prefs_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); | 70 DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); |
70 }; | 71 }; |
71 | 72 |
72 class TestAutofillPopupController : public AutofillPopupControllerImpl { | 73 class TestAutofillPopupController : public AutofillPopupControllerImpl { |
73 public: | 74 public: |
74 TestAutofillPopupController( | 75 TestAutofillPopupController( |
75 base::WeakPtr<AutofillExternalDelegate> external_delegate, | 76 base::WeakPtr<AutofillExternalDelegate> external_delegate, |
76 const gfx::RectF& element_bounds) | 77 const gfx::RectF& element_bounds) |
77 : AutofillPopupControllerImpl(external_delegate, | 78 : AutofillPopupControllerImpl(external_delegate, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 155 |
155 TestAutofillPopupController* popup_controller() { | 156 TestAutofillPopupController* popup_controller() { |
156 return autofill_popup_controller_; | 157 return autofill_popup_controller_; |
157 } | 158 } |
158 | 159 |
159 MockAutofillExternalDelegate* delegate() { | 160 MockAutofillExternalDelegate* delegate() { |
160 return external_delegate_.get(); | 161 return external_delegate_.get(); |
161 } | 162 } |
162 | 163 |
163 protected: | 164 protected: |
164 scoped_ptr<MockAutofillClient> autofill_client_; | 165 std::unique_ptr<MockAutofillClient> autofill_client_; |
165 scoped_ptr<NiceMock<MockAutofillExternalDelegate> > external_delegate_; | 166 std::unique_ptr<NiceMock<MockAutofillExternalDelegate>> external_delegate_; |
166 testing::NiceMock<TestAutofillPopupController>* autofill_popup_controller_; | 167 testing::NiceMock<TestAutofillPopupController>* autofill_popup_controller_; |
167 }; | 168 }; |
168 | 169 |
169 TEST_F(AutofillPopupControllerUnitTest, ChangeSelectedLine) { | 170 TEST_F(AutofillPopupControllerUnitTest, ChangeSelectedLine) { |
170 // Set up the popup. | 171 // Set up the popup. |
171 std::vector<Suggestion> suggestions; | 172 std::vector<Suggestion> suggestions; |
172 suggestions.push_back(Suggestion("", "", "", 0)); | 173 suggestions.push_back(Suggestion("", "", "", 0)); |
173 suggestions.push_back(Suggestion("", "", "", 0)); | 174 suggestions.push_back(Suggestion("", "", "", 0)); |
174 autofill_popup_controller_->Show(suggestions); | 175 autofill_popup_controller_->Show(suggestions); |
175 | 176 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 463 |
463 // The second element was shorter so it should be unchanged. | 464 // The second element was shorter so it should be unchanged. |
464 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).value, | 465 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).value, |
465 autofill_popup_controller_->GetElidedValueAt(1)); | 466 autofill_popup_controller_->GetElidedValueAt(1)); |
466 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).label, | 467 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).label, |
467 autofill_popup_controller_->GetElidedLabelAt(1)); | 468 autofill_popup_controller_->GetElidedLabelAt(1)); |
468 } | 469 } |
469 #endif | 470 #endif |
470 | 471 |
471 } // namespace autofill | 472 } // namespace autofill |
OLD | NEW |