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

Unified Diff: chrome/browser/autofill/autofill_metrics_unittest.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/chrome_quota_permission_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_metrics_unittest.cc
===================================================================
--- chrome/browser/autofill/autofill_metrics_unittest.cc (revision 175396)
+++ chrome/browser/autofill/autofill_metrics_unittest.cc (working copy)
@@ -8,7 +8,6 @@
#include "base/string16.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/api/infobars/infobar_service.h"
#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
#include "chrome/browser/autofill/autofill_common_test.h"
#include "chrome/browser/autofill/autofill_manager.h"
@@ -269,8 +268,9 @@
virtual void TearDown() OVERRIDE;
protected:
- AutofillCCInfoBarDelegate* CreateDelegate(MockAutofillMetrics* metric_logger,
- CreditCard** created_card);
+ scoped_ptr<ConfirmInfoBarDelegate> CreateDelegate(
+ MockAutofillMetrics* metric_logger,
+ CreditCard** created_card);
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
@@ -334,7 +334,7 @@
ChromeRenderViewHostTestHarness::TearDown();
}
-AutofillCCInfoBarDelegate* AutofillMetricsTest::CreateDelegate(
+scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate(
MockAutofillMetrics* metric_logger,
CreditCard** created_card) {
EXPECT_CALL(*metric_logger,
@@ -343,11 +343,8 @@
CreditCard* credit_card = new CreditCard();
if (created_card)
*created_card = credit_card;
- return new AutofillCCInfoBarDelegate(
- InfoBarService::FromWebContents(web_contents()),
- credit_card,
- &personal_data_,
- metric_logger);
+ return AutofillCCInfoBarDelegate::Create(credit_card, &personal_data_,
+ metric_logger);
}
// Test that we log quality metrics appropriately.
@@ -1138,37 +1135,40 @@
// Test that credit card infobar metrics are logged correctly.
TEST_F(AutofillMetricsTest, CreditCardInfoBar) {
- InfoBarService::CreateForWebContents(web_contents());
-
MockAutofillMetrics metric_logger;
::testing::InSequence dummy;
// Accept the infobar.
{
CreditCard* credit_card;
- scoped_ptr<InfoBarDelegate> infobar(CreateDelegate(&metric_logger,
- &credit_card));
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger,
+ &credit_card));
+ ASSERT_TRUE(infobar);
EXPECT_CALL(personal_data_, SaveImportedCreditCard(*credit_card));
EXPECT_CALL(metric_logger,
LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_ACCEPTED)).Times(1);
EXPECT_CALL(metric_logger,
LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)).Times(0);
- EXPECT_TRUE(static_cast<ConfirmInfoBarDelegate*>(infobar.get())->Accept());
+ EXPECT_TRUE(infobar->Accept());
}
// Cancel the infobar.
{
- scoped_ptr<InfoBarDelegate> infobar(CreateDelegate(&metric_logger, NULL));
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger,
+ NULL));
+ ASSERT_TRUE(infobar);
EXPECT_CALL(metric_logger,
LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_DENIED)).Times(1);
EXPECT_CALL(metric_logger,
LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)).Times(0);
- EXPECT_TRUE(static_cast<ConfirmInfoBarDelegate*>(infobar.get())->Cancel());
+ EXPECT_TRUE(infobar->Cancel());
}
// Dismiss the infobar.
{
- scoped_ptr<InfoBarDelegate> infobar(CreateDelegate(&metric_logger, NULL));
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger,
+ NULL));
+ ASSERT_TRUE(infobar);
EXPECT_CALL(metric_logger,
LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_DENIED)).Times(1);
EXPECT_CALL(metric_logger,
@@ -1178,7 +1178,9 @@
// Ignore the infobar.
{
- scoped_ptr<InfoBarDelegate> infobar(CreateDelegate(&metric_logger, NULL));
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(CreateDelegate(&metric_logger,
+ NULL));
+ ASSERT_TRUE(infobar);
EXPECT_CALL(metric_logger,
LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_IGNORED)).Times(1);
}
« no previous file with comments | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/chrome_quota_permission_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698