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

Unified Diff: chrome/browser/password_manager/password_manager_metrics_util_unittest.cc

Issue 23140005: Added of new UMA signals in order to be able to discover early if the "save password" feature gets … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review 7 Created 7 years, 3 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/password_manager/password_manager_metrics_util_unittest.cc
diff --git a/chrome/browser/password_manager/password_manager_metrics_util_unittest.cc b/chrome/browser/password_manager/password_manager_metrics_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bb6351d13cb47cc9a62741e2706a3792346eb412
--- /dev/null
+++ b/chrome/browser/password_manager/password_manager_metrics_util_unittest.cc
@@ -0,0 +1,66 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/password_manager/password_manager_metrics_util.h"
+
+#include <iterator>
+#include <map>
+
+#include "base/basictypes.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(PasswordManagerTest, MonitoredDomainGroupTest) {
+ std::string domain_name;
+ const char* const kMonitoredWebsite[] = {
+ "https://www.google.com",
+ "https://www.yahoo.com",
+ "https://www.baidu.com",
+ "https://www.wikipedia.org",
+ "https://www.linkedin.com",
+ "https://www.twitter.com",
+ "https://www.live.com",
+ "https://www.amazon.com",
+ "https://www.ebay.com",
+ "https://www.tumblr.com",
+ };
+ const size_t kMonitoredWebsiteLength = arraysize(kMonitoredWebsite);
+
+ domain_name = password_manager_metrics_util::MonitoredDomainGroup(
+ "https://www.linkedin.com");
+ EXPECT_FALSE(domain_name.empty());
+ domain_name = password_manager_metrics_util::MonitoredDomainGroup(
+ "https://www.amazon.com");
+ EXPECT_FALSE(domain_name.empty());
+ domain_name = password_manager_metrics_util::MonitoredDomainGroup(
+ "https://www.facebook.com");
+ EXPECT_TRUE(domain_name.empty());
+ domain_name = password_manager_metrics_util::MonitoredDomainGroup(
+ "http://wikipedia.org");
+ EXPECT_FALSE(domain_name.empty());
+ domain_name = password_manager_metrics_util::MonitoredDomainGroup(
+ "http://thisisnotwikipedia.org");
+ EXPECT_TRUE(domain_name.empty());
+
+ // The |groups| map contains the group name and the number of times
+ // it get assigned.
+ std::map<std::string, unsigned int> groups;
vabr (Chromium) 2013/09/11 17:31:24 nit: It could be better if the rest of this test i
jdomingos 2013/09/11 19:15:28 Done.
+
+ // Provide all possible values of the group id parameter for each monitored
+ // website.
+ for (size_t i = 0; i < kMonitoredWebsiteLength; ++i) {
+ for (size_t j = 0; j < password_manager_metrics_util::kGroupsPerDomain;
+ j++) {
+ password_manager_metrics_util::setGroupId(j);
+ ++groups[password_manager_metrics_util::MonitoredDomainGroup(
+ kMonitoredWebsite[i])];
+ }
+ }
+
+ // Check if all groups get assigned the same number of time.
+ unsigned int number_of_assignemt = groups["group_1"];
vabr (Chromium) 2013/09/11 17:31:24 typo (assignemt)
jdomingos 2013/09/11 19:15:28 Done.
+ for (std::map<std::string, unsigned int>::iterator it = groups.begin();
+ it != groups.end(); ++it) {
+ EXPECT_EQ(it->second, number_of_assignemt);
vabr (Chromium) 2013/09/11 17:31:24 nit: Adding << " group name = " << it->first might
jdomingos 2013/09/11 19:15:28 Done.
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698