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

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

Issue 11539003: Pop up requestAutocomplete UI when autofill server hints chrome client that it is in a multipage au… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Resolve with AutofillDialogController refactoring. 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_metrics.cc ('k') | chrome/browser/autofill/autofill_xml_parser.h » ('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
diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc
index 40fb33fec085a66c81466c168d51460678c4a665..9946a5d3498e94fe0dfc1e874279832791eeaccf 100644
--- a/chrome/browser/autofill/autofill_metrics_unittest.cc
+++ b/chrome/browser/autofill/autofill_metrics_unittest.cc
@@ -8,6 +8,7 @@
#include "base/string16.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/autofill/autocheckout_infobar_delegate.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"
@@ -22,6 +23,7 @@
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread.h"
+#include "googleurl/src/gurl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/rect.h"
@@ -39,6 +41,7 @@ class MockAutofillMetrics : public AutofillMetrics {
public:
MockAutofillMetrics() {}
MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric));
+ MOCK_CONST_METHOD1(LogAutocheckoutInfoBarMetric, void(InfoBarMetric metric));
MOCK_CONST_METHOD1(LogDeveloperEngagementMetric,
void(DeveloperEngagementMetric metric));
MOCK_CONST_METHOD3(LogHeuristicTypePrediction,
@@ -257,6 +260,25 @@ class TestAutofillManager : public AutofillManager {
DISALLOW_COPY_AND_ASSIGN(TestAutofillManager);
};
+class TestAutocheckoutManager : public AutocheckoutManager {
+ public:
+ explicit TestAutocheckoutManager(AutofillManager* autofill_manager)
+ : AutocheckoutManager(autofill_manager) {
+ }
+
+ virtual void ShowAutocheckoutDialog(
+ const GURL& frame_url,
+ const content::SSLStatus& ssl_status) OVERRIDE {
+ // no-op. Just used as callback from autocheckout_infobar_delegate.
+ }
+
+ virtual ~TestAutocheckoutManager() {
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestAutocheckoutManager);
+};
+
} // namespace
class AutofillMetricsTest : public ChromeRenderViewHostTestHarness {
@@ -272,6 +294,9 @@ class AutofillMetricsTest : public ChromeRenderViewHostTestHarness {
MockAutofillMetrics* metric_logger,
CreditCard** created_card);
+ scoped_ptr<ConfirmInfoBarDelegate> CreateAutocheckoutDelegate(
+ MockAutofillMetrics* metric_logger);
+
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
@@ -347,6 +372,20 @@ scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate(
metric_logger);
}
+scoped_ptr<ConfirmInfoBarDelegate>
+AutofillMetricsTest::CreateAutocheckoutDelegate(
+ MockAutofillMetrics* metric_logger) {
+ EXPECT_CALL(*metric_logger,
+ LogAutocheckoutInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN));
+ GURL url("www.google.com");
+ content::SSLStatus ssl_status;
+ return AutocheckoutInfoBarDelegate::Create(
+ *metric_logger,
+ url,
+ ssl_status,
+ new TestAutocheckoutManager(NULL));
+}
+
// Test that we log quality metrics appropriately.
TEST_F(AutofillMetricsTest, QualityMetrics) {
// Set up our form data.
@@ -1186,6 +1225,65 @@ TEST_F(AutofillMetricsTest, CreditCardInfoBar) {
}
}
+// Test that autofill flow infobar metrics are logged correctly.
+TEST_F(AutofillMetricsTest, AutocheckoutInfoBar) {
+ MockAutofillMetrics metric_logger;
+ ::testing::InSequence dummy;
+
+ // Accept the infobar.
+ {
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateAutocheckoutDelegate(&metric_logger));
+ ASSERT_TRUE(infobar);
+ EXPECT_CALL(metric_logger,
+ LogAutocheckoutInfoBarMetric(
+ AutofillMetrics::INFOBAR_ACCEPTED)).Times(1);
+ EXPECT_CALL(metric_logger,
+ LogAutocheckoutInfoBarMetric(
+ AutofillMetrics::INFOBAR_IGNORED)).Times(0);
+ EXPECT_TRUE(infobar->Accept());
+ }
+
+ // Cancel the infobar.
+ {
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateAutocheckoutDelegate(&metric_logger));
+ ASSERT_TRUE(infobar);
+ EXPECT_CALL(metric_logger,
+ LogAutocheckoutInfoBarMetric(
+ AutofillMetrics::INFOBAR_DENIED)).Times(1);
+ EXPECT_CALL(metric_logger,
+ LogAutocheckoutInfoBarMetric(
+ AutofillMetrics::INFOBAR_IGNORED)).Times(0);
+ EXPECT_TRUE(infobar->Cancel());
+ }
+
+ // Dismiss the infobar.
+ {
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateAutocheckoutDelegate(&metric_logger));
+ ASSERT_TRUE(infobar);
+ EXPECT_CALL(metric_logger,
+ LogAutocheckoutInfoBarMetric(
+ AutofillMetrics::INFOBAR_DENIED)).Times(1);
+ EXPECT_CALL(metric_logger,
+ LogAutocheckoutInfoBarMetric(
+ AutofillMetrics::INFOBAR_IGNORED)).Times(0);
+ infobar->InfoBarDismissed();
+ }
+
+ // Ignore the infobar.
+ {
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateAutocheckoutDelegate(&metric_logger));
+ ASSERT_TRUE(infobar);
+ EXPECT_CALL(metric_logger,
+ LogAutocheckoutInfoBarMetric(
+ AutofillMetrics::INFOBAR_IGNORED)).Times(1);
+ }
+}
+
+
// Test that server query response experiment id metrics are logged correctly.
TEST_F(AutofillMetricsTest, ServerQueryExperimentIdForQuery) {
MockAutofillMetrics metric_logger;
« no previous file with comments | « chrome/browser/autofill/autofill_metrics.cc ('k') | chrome/browser/autofill/autofill_xml_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698