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 ChromeRenderViewHostTestHarness::SetUp(); | 285 ChromeRenderViewHostTestHarness::SetUp(); |
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 PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile(), NULL); | 290 PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile(), NULL); |
292 | 291 |
293 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); | 292 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); |
294 | 293 |
295 personal_data_.reset(new TestPersonalDataManager()); | 294 personal_data_.reset(new TestPersonalDataManager()); |
296 personal_data_->SetBrowserContext(profile()); | 295 personal_data_->SetBrowserContext(profile()); |
297 autofill_driver_.reset(new TestAutofillDriver(web_contents())); | 296 autofill_driver_.reset(new TestAutofillDriver(web_contents())); |
298 autofill_manager_.reset(new TestAutofillManager( | 297 autofill_manager_.reset(new TestAutofillManager( |
299 autofill_driver_.get(), | 298 autofill_driver_.get(), |
300 TabAutofillManagerDelegate::FromWebContents(web_contents()), | 299 TabAutofillManagerDelegate::FromWebContents(web_contents()), |
301 personal_data_.get())); | 300 personal_data_.get())); |
302 | 301 |
303 external_delegate_.reset(new AutofillExternalDelegate( | 302 external_delegate_.reset(new AutofillExternalDelegate( |
304 web_contents(), | 303 web_contents(), |
305 autofill_manager_.get(), | 304 autofill_manager_.get(), |
306 autofill_driver_.get())); | 305 autofill_driver_.get())); |
307 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 306 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
308 } | 307 } |
309 | 308 |
310 void AutofillMetricsTest::TearDown() { | 309 void AutofillMetricsTest::TearDown() { |
311 // Order of destruction is important as AutofillManager relies on | 310 // Order of destruction is important as AutofillManager relies on |
312 // PersonalDataManager to be around when it gets destroyed. Also, a real | 311 // PersonalDataManager to be around when it gets destroyed. Also, a real |
313 // AutofillManager is tied to the lifetime of the WebContents, so it must | 312 // AutofillManager is tied to the lifetime of the WebContents, so it must |
314 // be destroyed at the destruction of the WebContents. | 313 // be destroyed at the destruction of the WebContents. |
315 autofill_manager_.reset(); | 314 autofill_manager_.reset(); |
316 autofill_driver_.reset(); | 315 autofill_driver_.reset(); |
317 personal_data_.reset(); | 316 personal_data_.reset(); |
318 profile()->ResetRequestContext(); | |
319 ChromeRenderViewHostTestHarness::TearDown(); | 317 ChromeRenderViewHostTestHarness::TearDown(); |
320 } | 318 } |
321 | 319 |
322 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( | 320 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( |
323 MockAutofillMetrics* metric_logger) { | 321 MockAutofillMetrics* metric_logger) { |
324 EXPECT_CALL(*metric_logger, | 322 EXPECT_CALL(*metric_logger, |
325 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); | 323 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); |
326 | 324 |
327 CreditCard credit_card; | 325 CreditCard credit_card; |
328 return AutofillCCInfoBarDelegate::Create( | 326 return AutofillCCInfoBarDelegate::Create( |
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 TimeTicks::FromInternalValue(5)); | 1555 TimeTicks::FromInternalValue(5)); |
1558 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1556 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
1559 TimeTicks::FromInternalValue(3)); | 1557 TimeTicks::FromInternalValue(3)); |
1560 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1558 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
1561 autofill_manager_->Reset(); | 1559 autofill_manager_->Reset(); |
1562 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1560 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
1563 } | 1561 } |
1564 } | 1562 } |
1565 | 1563 |
1566 } // namespace autofill | 1564 } // namespace autofill |
OLD | NEW |