| 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/guid.h" | 5 #include "base/guid.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" | 9 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| 10 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 10 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 FormData form_data; | 138 FormData form_data; |
| 139 form_data.fields.push_back(field); | 139 form_data.fields.push_back(field); |
| 140 | 140 |
| 141 profile()->GetPrefs()->SetBoolean( | 141 profile()->GetPrefs()->SetBoolean( |
| 142 prefs::kAutofillDialogPayWithoutWallet, true); | 142 prefs::kAutofillDialogPayWithoutWallet, true); |
| 143 profile()->CreateRequestContext(); | 143 profile()->CreateRequestContext(); |
| 144 test_web_contents_.reset( | 144 test_web_contents_.reset( |
| 145 content::WebContentsTester::CreateTestWebContents(profile(), NULL)); | 145 content::WebContentsTester::CreateTestWebContents(profile(), NULL)); |
| 146 | 146 |
| 147 base::Callback<void(const FormStructure*)> callback; | 147 base::Callback<void(const FormStructure*)> callback; |
| 148 AutofillMetrics metrics; | |
| 149 controller_ = new TestAutofillDialogController( | 148 controller_ = new TestAutofillDialogController( |
| 150 test_web_contents_.get(), | 149 test_web_contents_.get(), |
| 151 form_data, | 150 form_data, |
| 152 GURL(), | 151 GURL(), |
| 153 content::SSLStatus(), | 152 content::SSLStatus(), |
| 154 metrics, | 153 metric_logger_, |
| 155 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, | 154 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, |
| 156 callback); | 155 callback); |
| 157 controller_->Show(); | 156 controller_->Show(); |
| 158 } | 157 } |
| 159 | 158 |
| 160 virtual void TearDown() OVERRIDE { | 159 virtual void TearDown() OVERRIDE { |
| 161 controller_->ViewClosed(); | 160 controller_->ViewClosed(); |
| 162 } | 161 } |
| 163 | 162 |
| 164 protected: | 163 protected: |
| 165 TestAutofillDialogController* controller() { return controller_; } | 164 TestAutofillDialogController* controller() { return controller_; } |
| 166 | 165 |
| 167 TestingProfile* profile() { return &profile_; } | 166 TestingProfile* profile() { return &profile_; } |
| 168 | 167 |
| 169 private: | 168 private: |
| 170 // A bunch of threads are necessary for classes like TestWebContents and | 169 // A bunch of threads are necessary for classes like TestWebContents and |
| 171 // URLRequestContextGetter not to fall over. | 170 // URLRequestContextGetter not to fall over. |
| 172 MessageLoopForUI loop_; | 171 MessageLoopForUI loop_; |
| 173 content::TestBrowserThread ui_thread_; | 172 content::TestBrowserThread ui_thread_; |
| 174 content::TestBrowserThread file_thread_; | 173 content::TestBrowserThread file_thread_; |
| 175 content::TestBrowserThread file_blocking_thread_; | 174 content::TestBrowserThread file_blocking_thread_; |
| 176 content::TestBrowserThread io_thread_; | 175 content::TestBrowserThread io_thread_; |
| 177 TestingProfile profile_; | 176 TestingProfile profile_; |
| 178 | 177 |
| 179 // The controller owns itself. | 178 // The controller owns itself. |
| 180 TestAutofillDialogController* controller_; | 179 TestAutofillDialogController* controller_; |
| 181 | 180 |
| 182 scoped_ptr<content::WebContents> test_web_contents_; | 181 scoped_ptr<content::WebContents> test_web_contents_; |
| 183 | 182 |
| 183 // Must outlive the controller. |
| 184 AutofillMetrics metric_logger_; |
| 185 |
| 184 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); | 186 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); |
| 185 }; | 187 }; |
| 186 | 188 |
| 187 } // namespace | 189 } // namespace |
| 188 | 190 |
| 189 // This test makes sure nothing falls over when fields are being validity- | 191 // This test makes sure nothing falls over when fields are being validity- |
| 190 // checked. | 192 // checked. |
| 191 TEST_F(AutofillDialogControllerTest, ValidityCheck) { | 193 TEST_F(AutofillDialogControllerTest, ValidityCheck) { |
| 192 const DialogSection sections[] = { | 194 const DialogSection sections[] = { |
| 193 SECTION_EMAIL, | 195 SECTION_EMAIL, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 email_model->ActivatedAt(1); | 263 email_model->ActivatedAt(1); |
| 262 EXPECT_EQ(kEmail2, controller()->SuggestionTextForSection(SECTION_EMAIL)); | 264 EXPECT_EQ(kEmail2, controller()->SuggestionTextForSection(SECTION_EMAIL)); |
| 263 | 265 |
| 264 controller()->EditClickedForSection(SECTION_EMAIL); | 266 controller()->EditClickedForSection(SECTION_EMAIL); |
| 265 const DetailInputs& inputs = | 267 const DetailInputs& inputs = |
| 266 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 268 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
| 267 EXPECT_EQ(kEmail2, inputs[0].autofilled_value); | 269 EXPECT_EQ(kEmail2, inputs[0].autofilled_value); |
| 268 } | 270 } |
| 269 | 271 |
| 270 } // namespace autofill | 272 } // namespace autofill |
| OLD | NEW |