| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_metrics.h" | 5 #include "components/autofill/core/browser/autofill_metrics.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // PersonalDataManager to be around when it gets destroyed. | 280 // PersonalDataManager to be around when it gets destroyed. |
| 281 autofill_manager_.reset(); | 281 autofill_manager_.reset(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void AutofillMetricsTest::SetUp() { | 284 void AutofillMetricsTest::SetUp() { |
| 285 TestingProfile* profile = new TestingProfile(); | 285 TestingProfile* profile = new TestingProfile(); |
| 286 | 286 |
| 287 // Ensure Mac OS X does not pop up a modal dialog for the Address Book. | 287 // Ensure Mac OS X does not pop up a modal dialog for the Address Book. |
| 288 autofill::test::DisableSystemServices(profile); | 288 autofill::test::DisableSystemServices(profile); |
| 289 | 289 |
| 290 profile->CreateRequestContext(); | |
| 291 browser_context_.reset(profile); | 290 browser_context_.reset(profile); |
| 292 PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile, NULL); | 291 PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile, NULL); |
| 293 | 292 |
| 294 ChromeRenderViewHostTestHarness::SetUp(); | 293 ChromeRenderViewHostTestHarness::SetUp(); |
| 295 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); | 294 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); |
| 296 | 295 |
| 297 personal_data_.reset(new TestPersonalDataManager()); | 296 personal_data_.reset(new TestPersonalDataManager()); |
| 298 personal_data_->SetBrowserContext(profile); | 297 personal_data_->SetBrowserContext(profile); |
| 299 autofill_driver_.reset(new TestAutofillDriver(web_contents())); | 298 autofill_driver_.reset(new TestAutofillDriver(web_contents())); |
| 300 autofill_manager_.reset(new TestAutofillManager( | 299 autofill_manager_.reset(new TestAutofillManager( |
| 301 autofill_driver_.get(), | 300 autofill_driver_.get(), |
| 302 TabAutofillManagerDelegate::FromWebContents(web_contents()), | 301 TabAutofillManagerDelegate::FromWebContents(web_contents()), |
| 303 personal_data_.get())); | 302 personal_data_.get())); |
| 304 | 303 |
| 305 external_delegate_.reset(new AutofillExternalDelegate( | 304 external_delegate_.reset(new AutofillExternalDelegate( |
| 306 web_contents(), | 305 web_contents(), |
| 307 autofill_manager_.get(), | 306 autofill_manager_.get(), |
| 308 autofill_driver_.get())); | 307 autofill_driver_.get())); |
| 309 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 308 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
| 310 } | 309 } |
| 311 | 310 |
| 312 void AutofillMetricsTest::TearDown() { | 311 void AutofillMetricsTest::TearDown() { |
| 313 // Order of destruction is important as AutofillManager relies on | 312 // Order of destruction is important as AutofillManager relies on |
| 314 // PersonalDataManager to be around when it gets destroyed. Also, a real | 313 // PersonalDataManager to be around when it gets destroyed. Also, a real |
| 315 // AutofillManager is tied to the lifetime of the WebContents, so it must | 314 // AutofillManager is tied to the lifetime of the WebContents, so it must |
| 316 // be destroyed at the destruction of the WebContents. | 315 // be destroyed at the destruction of the WebContents. |
| 317 autofill_manager_.reset(); | 316 autofill_manager_.reset(); |
| 318 autofill_driver_.reset(); | 317 autofill_driver_.reset(); |
| 319 personal_data_.reset(); | 318 personal_data_.reset(); |
| 320 profile()->ResetRequestContext(); | |
| 321 ChromeRenderViewHostTestHarness::TearDown(); | 319 ChromeRenderViewHostTestHarness::TearDown(); |
| 322 } | 320 } |
| 323 | 321 |
| 324 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( | 322 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( |
| 325 MockAutofillMetrics* metric_logger) { | 323 MockAutofillMetrics* metric_logger) { |
| 326 EXPECT_CALL(*metric_logger, | 324 EXPECT_CALL(*metric_logger, |
| 327 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); | 325 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); |
| 328 | 326 |
| 329 CreditCard credit_card; | 327 CreditCard credit_card; |
| 330 return AutofillCCInfoBarDelegate::CreateForTesting( | 328 return AutofillCCInfoBarDelegate::CreateForTesting( |
| (...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 TimeTicks::FromInternalValue(5)); | 1557 TimeTicks::FromInternalValue(5)); |
| 1560 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1558 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
| 1561 TimeTicks::FromInternalValue(3)); | 1559 TimeTicks::FromInternalValue(3)); |
| 1562 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1560 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
| 1563 autofill_manager_->Reset(); | 1561 autofill_manager_->Reset(); |
| 1564 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1562 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
| 1565 } | 1563 } |
| 1566 } | 1564 } |
| 1567 | 1565 |
| 1568 } // namespace autofill | 1566 } // namespace autofill |
| OLD | NEW |