| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 5 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "components/password_manager/core/common/password_manager_pref_names.h" | 14 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 15 #include "content/public/test/test_browser_thread_bundle.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 class PasswordManagerMetricsUtilTest : public testing::Test { | 18 class PasswordManagerMetricsUtilTest : public testing::Test { |
| 18 public: | 19 public: |
| 19 PasswordManagerMetricsUtilTest() {} | 20 PasswordManagerMetricsUtilTest() {} |
| 20 | 21 |
| 21 protected: | 22 protected: |
| 22 bool IsMonitored(const char* url_host) { | 23 bool IsMonitored(const char* url_host) { |
| 23 size_t group_id = password_manager::metrics_util::MonitoredDomainGroupId( | 24 size_t group_id = password_manager::metrics_util::MonitoredDomainGroupId( |
| 24 url_host, profile_.GetPrefs()); | 25 url_host, profile_.GetPrefs()); |
| 25 return group_id > 0; | 26 return group_id > 0; |
| 26 } | 27 } |
| 27 | 28 |
| 29 content::TestBrowserThreadBundle thread_bundle_; |
| 28 TestingProfile profile_; | 30 TestingProfile profile_; |
| 29 }; | 31 }; |
| 30 | 32 |
| 31 TEST_F(PasswordManagerMetricsUtilTest, MonitoredDomainGroupAssigmentTest) { | 33 TEST_F(PasswordManagerMetricsUtilTest, MonitoredDomainGroupAssigmentTest) { |
| 32 const char* const kMonitoredWebsites[] = { | 34 const char* const kMonitoredWebsites[] = { |
| 33 "https://www.google.com", | 35 "https://www.google.com", |
| 34 "https://www.yahoo.com", | 36 "https://www.yahoo.com", |
| 35 "https://www.baidu.com", | 37 "https://www.baidu.com", |
| 36 "https://www.wikipedia.org", | 38 "https://www.wikipedia.org", |
| 37 "https://www.linkedin.com", | 39 "https://www.linkedin.com", |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 74 } |
| 73 } | 75 } |
| 74 | 76 |
| 75 TEST_F(PasswordManagerMetricsUtilTest, MonitoredDomainGroupTest) { | 77 TEST_F(PasswordManagerMetricsUtilTest, MonitoredDomainGroupTest) { |
| 76 EXPECT_TRUE(IsMonitored("https://www.linkedin.com")); | 78 EXPECT_TRUE(IsMonitored("https://www.linkedin.com")); |
| 77 EXPECT_TRUE(IsMonitored("https://www.amazon.com")); | 79 EXPECT_TRUE(IsMonitored("https://www.amazon.com")); |
| 78 EXPECT_TRUE(IsMonitored("https://www.facebook.com")); | 80 EXPECT_TRUE(IsMonitored("https://www.facebook.com")); |
| 79 EXPECT_TRUE(IsMonitored("http://wikipedia.org")); | 81 EXPECT_TRUE(IsMonitored("http://wikipedia.org")); |
| 80 EXPECT_FALSE(IsMonitored("http://thisisnotwikipedia.org")); | 82 EXPECT_FALSE(IsMonitored("http://thisisnotwikipedia.org")); |
| 81 } | 83 } |
| OLD | NEW |