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

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: Addressed review comments. 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
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..ae3ade0288458a120e5e3df128ad184d9eccc835 100644
--- a/chrome/browser/autofill/autofill_metrics_unittest.cc
+++ b/chrome/browser/autofill/autofill_metrics_unittest.cc
@@ -10,6 +10,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
#include "chrome/browser/autofill/autofill_common_test.h"
+#include "chrome/browser/autofill/autofill_flow_infobar_delegate.h"
#include "chrome/browser/autofill/autofill_manager.h"
#include "chrome/browser/autofill/autofill_manager_delegate.h"
#include "chrome/browser/autofill/autofill_metrics.h"
@@ -39,6 +40,7 @@ class MockAutofillMetrics : public AutofillMetrics {
public:
MockAutofillMetrics() {}
MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric));
+ MOCK_CONST_METHOD1(LogAutofillFlowInfoBarMetric, void(InfoBarMetric metric));
MOCK_CONST_METHOD1(LogDeveloperEngagementMetric,
void(DeveloperEngagementMetric metric));
MOCK_CONST_METHOD3(LogHeuristicTypePrediction,
@@ -228,6 +230,12 @@ class TestAutofillManager : public AutofillManager {
}
}
+ void ShowAutofillFlowDialog(const FormData& form,
+ const GURL& frame_url,
+ const content::SSLStatus& ssl_status) {
+ // no-op. Just used as callback into autofill_flow_infobar_delegate.
Albert Bodenhamer 2013/01/14 22:10:18 Is the callback required?
Raman Kakilate 2013/01/14 23:37:46 Yes, Actual AutofillManager's ShowAutofillFlowDial
+ }
+
virtual void UploadFormDataAsyncCallback(
const FormStructure* submitted_form,
const base::TimeTicks& load_time,
@@ -272,6 +280,9 @@ class AutofillMetricsTest : public ChromeRenderViewHostTestHarness {
MockAutofillMetrics* metric_logger,
CreditCard** created_card);
+ scoped_ptr<ConfirmInfoBarDelegate> CreateAutofillFlowDelegate(
+ MockAutofillMetrics* metric_logger);
+
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
@@ -347,6 +358,19 @@ scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate(
metric_logger);
}
+scoped_ptr<ConfirmInfoBarDelegate>
+AutofillMetricsTest::CreateAutofillFlowDelegate(
+ MockAutofillMetrics* metric_logger) {
+ EXPECT_CALL(*metric_logger,
+ LogAutofillFlowInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN));
+ GURL url("www.google.com");
Albert Bodenhamer 2013/01/14 22:10:18 I think there's a header for getting google URLs.
Raman Kakilate 2013/01/14 23:37:46 Done.
+ content::SSLStatus ssl_status;
+ return AutofillFlowInfoBarDelegate::Create(autofill_manager_.get(),
+ metric_logger,
+ url,
+ ssl_status);
+}
+
// Test that we log quality metrics appropriately.
TEST_F(AutofillMetricsTest, QualityMetrics) {
// Set up our form data.
@@ -1186,6 +1210,65 @@ TEST_F(AutofillMetricsTest, CreditCardInfoBar) {
}
}
+// Test that autofill flow infobar metrics are logged correctly.
+TEST_F(AutofillMetricsTest, AutofillFlowInfoBar) {
+ MockAutofillMetrics metric_logger;
+ ::testing::InSequence dummy;
+
+ // Accept the infobar.
+ {
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateAutofillFlowDelegate(&metric_logger));
+ ASSERT_TRUE(infobar);
+ EXPECT_CALL(metric_logger,
+ LogAutofillFlowInfoBarMetric(
+ AutofillMetrics::INFOBAR_ACCEPTED)).Times(1);
+ EXPECT_CALL(metric_logger,
+ LogAutofillFlowInfoBarMetric(
+ AutofillMetrics::INFOBAR_IGNORED)).Times(0);
+ EXPECT_TRUE(infobar->Accept());
+ }
+
+ // Cancel the infobar.
+ {
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateAutofillFlowDelegate(&metric_logger));
+ ASSERT_TRUE(infobar);
+ EXPECT_CALL(metric_logger,
+ LogAutofillFlowInfoBarMetric(
+ AutofillMetrics::INFOBAR_DENIED)).Times(1);
+ EXPECT_CALL(metric_logger,
+ LogAutofillFlowInfoBarMetric(
+ AutofillMetrics::INFOBAR_IGNORED)).Times(0);
+ EXPECT_TRUE(infobar->Cancel());
+ }
+
+ // Dismiss the infobar.
+ {
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateAutofillFlowDelegate(&metric_logger));
+ ASSERT_TRUE(infobar);
+ EXPECT_CALL(metric_logger,
+ LogAutofillFlowInfoBarMetric(
+ AutofillMetrics::INFOBAR_DENIED)).Times(1);
+ EXPECT_CALL(metric_logger,
+ LogAutofillFlowInfoBarMetric(
+ AutofillMetrics::INFOBAR_IGNORED)).Times(0);
+ infobar->InfoBarDismissed();
+ }
+
+ // Ignore the infobar.
+ {
+ scoped_ptr<ConfirmInfoBarDelegate> infobar(
+ CreateAutofillFlowDelegate(&metric_logger));
+ ASSERT_TRUE(infobar);
+ EXPECT_CALL(metric_logger,
+ LogAutofillFlowInfoBarMetric(
+ AutofillMetrics::INFOBAR_IGNORED)).Times(1);
+ }
+}
+
+
// Test that server query response experiment id metrics are logged correctly.
TEST_F(AutofillMetricsTest, ServerQueryExperimentIdForQuery) {
MockAutofillMetrics metric_logger;

Powered by Google App Engine
This is Rietveld 408576698