Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1158)

Side by Side Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup TODOs. merge code. kill more threads. i never get tired of thread carnage. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 scoped_ptr<AutofillExternalDelegate> external_delegate_; 275 scoped_ptr<AutofillExternalDelegate> external_delegate_;
276 }; 276 };
277 277
278 AutofillMetricsTest::~AutofillMetricsTest() { 278 AutofillMetricsTest::~AutofillMetricsTest() {
279 // Order of destruction is important as AutofillManager relies on 279 // Order of destruction is important as AutofillManager relies on
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();
tfarina 2013/07/11 01:35:45 can we create a TestBrowserContext now?
awong 2013/07/11 21:04:15 Same answer to previous comment. I'm not familiar
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698