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

Unified Diff: components/password_manager/core/browser/login_database_unittest.cc

Issue 715193002: [Password Generation] Breakout UMA stats for generated passwords (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Created 6 years, 1 month 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 | « components/password_manager/core/browser/login_database.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/login_database_unittest.cc
diff --git a/components/password_manager/core/browser/login_database_unittest.cc b/components/password_manager/core/browser/login_database_unittest.cc
index 4faaa8c968354a04d8eec941341a5141702b763f..5ec0e2ed88c338f46238a41719119811fc78c9f6 100644
--- a/components/password_manager/core/browser/login_database_unittest.cc
+++ b/components/password_manager/core/browser/login_database_unittest.cc
@@ -11,6 +11,7 @@
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/histogram_tester.h"
#include "base/time/time.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/psl_matching_helper.h"
@@ -951,6 +952,79 @@ TEST_F(LoginDatabaseTest, UpdateLogin) {
EXPECT_EQ(form, *result[0]);
}
+TEST_F(LoginDatabaseTest, ReportMetricsTest) {
+ PasswordForm password_form;
+ password_form.origin = GURL("http://example.com");
+ password_form.username_value = ASCIIToUTF16("test1@gmail.com");
+ password_form.password_value = ASCIIToUTF16("test");
+ password_form.signon_realm = "http://example.com/";
+ password_form.times_used = 0;
+ EXPECT_EQ(AddChangeForForm(password_form), db_.AddLogin(password_form));
+
+ password_form.username_value = ASCIIToUTF16("test2@gmail.com");
+ password_form.times_used = 1;
+ EXPECT_EQ(AddChangeForForm(password_form), db_.AddLogin(password_form));
+
+ password_form.origin = GURL("http://second.example.com");
+ password_form.signon_realm = "http://second.example.com";
+ password_form.times_used = 3;
+ EXPECT_EQ(AddChangeForForm(password_form), db_.AddLogin(password_form));
+
+ password_form.username_value = ASCIIToUTF16("test3@gmail.com");
+ password_form.type = PasswordForm::TYPE_GENERATED;
+ password_form.times_used = 2;
+ EXPECT_EQ(AddChangeForForm(password_form), db_.AddLogin(password_form));
+
+ password_form.origin = GURL("http://third.example.com/");
+ password_form.signon_realm = "http://third.example.com/";
+ password_form.times_used = 4;
+ EXPECT_EQ(AddChangeForForm(password_form), db_.AddLogin(password_form));
+
+ base::HistogramTester histogram_tester;
+ db_.ReportMetrics("", false);
+
+ histogram_tester.ExpectUniqueSample(
+ "PasswordManager.TotalAccounts.UserCreated.WithoutCustomPassphrase",
+ 3,
+ 1);
+ histogram_tester.ExpectBucketCount(
+ "PasswordManager.AccountsPerSite.UserCreated.WithoutCustomPassphrase",
+ 1,
+ 1);
+ histogram_tester.ExpectBucketCount(
+ "PasswordManager.AccountsPerSite.UserCreated.WithoutCustomPassphrase",
+ 2,
+ 1);
+ histogram_tester.ExpectBucketCount(
+ "PasswordManager.TimesPasswordUsed.UserCreated.WithoutCustomPassphrase",
+ 0,
+ 1);
+ histogram_tester.ExpectBucketCount(
+ "PasswordManager.TimesPasswordUsed.UserCreated.WithoutCustomPassphrase",
+ 1,
+ 1);
+ histogram_tester.ExpectBucketCount(
+ "PasswordManager.TimesPasswordUsed.UserCreated.WithoutCustomPassphrase",
+ 3,
+ 1);
+ histogram_tester.ExpectUniqueSample(
+ "PasswordManager.TotalAccounts.AutoGenerated.WithoutCustomPassphrase",
+ 2,
+ 1);
+ histogram_tester.ExpectUniqueSample(
+ "PasswordManager.AccountsPerSite.AutoGenerated.WithoutCustomPassphrase",
+ 1,
+ 2);
+ histogram_tester.ExpectBucketCount(
+ "PasswordManager.TimesPasswordUsed.AutoGenerated.WithoutCustomPassphrase",
+ 2,
+ 1);
+ histogram_tester.ExpectBucketCount(
+ "PasswordManager.TimesPasswordUsed.AutoGenerated.WithoutCustomPassphrase",
+ 4,
+ 1);
+}
+
#if defined(OS_POSIX)
// Only the current user has permission to read the database.
//
« no previous file with comments | « components/password_manager/core/browser/login_database.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698