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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 TestPopupControllerCommon* test_controller_common_; | 117 TestPopupControllerCommon* test_controller_common_; |
118 }; | 118 }; |
119 | 119 |
120 } // namespace | 120 } // namespace |
121 | 121 |
122 class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness { | 122 class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness { |
123 public: | 123 public: |
124 AutofillPopupControllerUnitTest() | 124 AutofillPopupControllerUnitTest() |
125 : autofill_client_(new MockAutofillClient()), | 125 : autofill_client_(new MockAutofillClient()), |
126 autofill_popup_controller_(NULL) {} | 126 autofill_popup_controller_(NULL) {} |
127 virtual ~AutofillPopupControllerUnitTest() {} | 127 ~AutofillPopupControllerUnitTest() override {} |
128 | 128 |
129 virtual void SetUp() override { | 129 void SetUp() override { |
130 ChromeRenderViewHostTestHarness::SetUp(); | 130 ChromeRenderViewHostTestHarness::SetUp(); |
131 | 131 |
132 ContentAutofillDriver::CreateForWebContentsAndDelegate( | 132 ContentAutofillDriver::CreateForWebContentsAndDelegate( |
133 web_contents(), | 133 web_contents(), |
134 autofill_client_.get(), | 134 autofill_client_.get(), |
135 "en-US", | 135 "en-US", |
136 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); | 136 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); |
137 ContentAutofillDriver* driver = | 137 ContentAutofillDriver* driver = |
138 ContentAutofillDriver::FromWebContents(web_contents()); | 138 ContentAutofillDriver::FromWebContents(web_contents()); |
139 external_delegate_.reset( | 139 external_delegate_.reset( |
140 new NiceMock<MockAutofillExternalDelegate>( | 140 new NiceMock<MockAutofillExternalDelegate>( |
141 driver->autofill_manager(), | 141 driver->autofill_manager(), |
142 driver)); | 142 driver)); |
143 | 143 |
144 autofill_popup_controller_ = | 144 autofill_popup_controller_ = |
145 new testing::NiceMock<TestAutofillPopupController>( | 145 new testing::NiceMock<TestAutofillPopupController>( |
146 external_delegate_->GetWeakPtr(),gfx::Rect()); | 146 external_delegate_->GetWeakPtr(),gfx::Rect()); |
147 } | 147 } |
148 | 148 |
149 virtual void TearDown() override { | 149 void TearDown() override { |
150 // This will make sure the controller and the view (if any) are both | 150 // This will make sure the controller and the view (if any) are both |
151 // cleaned up. | 151 // cleaned up. |
152 if (autofill_popup_controller_) | 152 if (autofill_popup_controller_) |
153 autofill_popup_controller_->DoHide(); | 153 autofill_popup_controller_->DoHide(); |
154 | 154 |
155 external_delegate_.reset(); | 155 external_delegate_.reset(); |
156 ChromeRenderViewHostTestHarness::TearDown(); | 156 ChromeRenderViewHostTestHarness::TearDown(); |
157 } | 157 } |
158 | 158 |
159 TestAutofillPopupController* popup_controller() { | 159 TestAutofillPopupController* popup_controller() { |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 EXPECT_NE(names[0], autofill_popup_controller_->names()[0]); | 526 EXPECT_NE(names[0], autofill_popup_controller_->names()[0]); |
527 EXPECT_NE(subtexts[0], autofill_popup_controller_->subtexts()[0]); | 527 EXPECT_NE(subtexts[0], autofill_popup_controller_->subtexts()[0]); |
528 | 528 |
529 // The second element was shorter so it should be unchanged. | 529 // The second element was shorter so it should be unchanged. |
530 EXPECT_EQ(names[1], autofill_popup_controller_->names()[1]); | 530 EXPECT_EQ(names[1], autofill_popup_controller_->names()[1]); |
531 EXPECT_EQ(subtexts[1], autofill_popup_controller_->subtexts()[1]); | 531 EXPECT_EQ(subtexts[1], autofill_popup_controller_->subtexts()[1]); |
532 } | 532 } |
533 #endif | 533 #endif |
534 | 534 |
535 } // namespace autofill | 535 } // namespace autofill |
OLD | NEW |