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

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: 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
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 4dd83f82a14092b8e169e7f033063659b643da6f..cf73601dfc2f46842dd740f1b0de2a2b0ac4de1e 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"
@@ -950,6 +951,79 @@ TEST_F(LoginDatabaseTest, UpdateLogin) {
EXPECT_EQ(form, *result[0]);
}
+TEST_F(LoginDatabaseTest, ReportMetricsTest) {
+ PasswordForm user_created;
+ user_created.origin = GURL("http://example.com");
+ user_created.username_value = ASCIIToUTF16("test1@gmail.com");
+ user_created.password_value = ASCIIToUTF16("test");
+ user_created.signon_realm = "http://example.com/";
+ user_created.times_used = 0;
+ EXPECT_EQ(AddChangeForForm(user_created), db_.AddLogin(user_created));
+
+ user_created.username_value = ASCIIToUTF16("test2@gmail.com");
+ user_created.times_used = 1;
+ EXPECT_EQ(AddChangeForForm(user_created), db_.AddLogin(user_created));
+
+ user_created.origin = GURL("http://second.example.com");
+ user_created.signon_realm = "http://second.example.com";
+ user_created.times_used = 3;
+ EXPECT_EQ(AddChangeForForm(user_created), db_.AddLogin(user_created));
+
+ user_created.username_value = ASCIIToUTF16("test3@gmail.com");
+ user_created.type = PasswordForm::TYPE_GENERATED;
Ilya Sherman 2014/11/13 01:54:53 It seems pretty weird to still be calling the acco
Garrett Casto 2014/11/18 22:30:24 Changed.
+ user_created.times_used = 2;
+ EXPECT_EQ(AddChangeForForm(user_created), db_.AddLogin(user_created));
+
+ user_created.origin = GURL("http://third.example.com/");
+ user_created.signon_realm = "http://third.example.com/";
+ user_created.times_used = 4;
+ EXPECT_EQ(AddChangeForForm(user_created), db_.AddLogin(user_created));
+
+ 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.ExpectBucketCount(
Ilya Sherman 2014/11/13 01:54:53 nit: Perhaps call ExpectUniqueSample here?
Garrett Casto 2014/11/18 22:30:24 Done.
+ "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.
//

Powered by Google App Engine
This is Rietveld 408576698