| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/android/preferences/important_sites_util.h" | 5 #include "chrome/browser/android/preferences/important_sites_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 13 #include "chrome/browser/engagement/site_engagement_helper.h" | 13 #include "chrome/browser/engagement/site_engagement_score.h" |
| 14 #include "chrome/browser/engagement/site_engagement_metrics.h" | |
| 15 #include "chrome/browser/engagement/site_engagement_service.h" | 14 #include "chrome/browser/engagement/site_engagement_service.h" |
| 16 #include "chrome/browser/engagement/site_engagement_service_factory.h" | |
| 17 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
| 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 16 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 20 #include "components/content_settings/core/browser/host_content_settings_map.h" | 18 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 21 #include "components/content_settings/core/common/content_settings.h" | 19 #include "components/content_settings/core/common/content_settings.h" |
| 22 #include "components/content_settings/core/common/content_settings_pattern.h" | 20 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 23 #include "components/history/core/browser/history_database_params.h" | 21 #include "components/history/core/browser/history_database_params.h" |
| 24 #include "components/history/core/browser/history_service.h" | 22 #include "components/history/core/browser/history_service.h" |
| 25 #include "components/history/core/test/test_history_database.h" | 23 #include "components/history/core/test/test_history_database.h" |
| 26 #include "components/keyed_service/core/keyed_service.h" | 24 #include "components/keyed_service/core/keyed_service.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 base::ScopedTempDir temp_dir_; | 69 base::ScopedTempDir temp_dir_; |
| 72 }; | 70 }; |
| 73 | 71 |
| 74 TEST_F(ImportantSitesUtilTest, TestNoImportantSites) { | 72 TEST_F(ImportantSitesUtilTest, TestNoImportantSites) { |
| 75 EXPECT_TRUE(ImportantSitesUtil::GetImportantRegisterableDomains( | 73 EXPECT_TRUE(ImportantSitesUtil::GetImportantRegisterableDomains( |
| 76 profile(), kNumImportantSites) | 74 profile(), kNumImportantSites) |
| 77 .empty()); | 75 .empty()); |
| 78 } | 76 } |
| 79 | 77 |
| 80 TEST_F(ImportantSitesUtilTest, NotificationsThenEngagement) { | 78 TEST_F(ImportantSitesUtilTest, NotificationsThenEngagement) { |
| 81 SiteEngagementService* service = | 79 SiteEngagementService* service = SiteEngagementService::Get(profile()); |
| 82 SiteEngagementServiceFactory::GetForProfile(profile()); | |
| 83 ASSERT_TRUE(service); | 80 ASSERT_TRUE(service); |
| 84 | 81 |
| 85 GURL url1("http://www.google.com/"); | 82 GURL url1("http://www.google.com/"); |
| 86 GURL url2("https://www.google.com/"); | 83 GURL url2("https://www.google.com/"); |
| 87 GURL url3("https://drive.google.com/"); | 84 GURL url3("https://drive.google.com/"); |
| 88 GURL url4("https://www.chrome.com/"); | 85 GURL url4("https://www.chrome.com/"); |
| 89 GURL url5("https://www.example.com/"); | 86 GURL url5("https://www.example.com/"); |
| 90 GURL url6("https://youtube.com/"); | 87 GURL url6("https://youtube.com/"); |
| 91 GURL url7("https://foo.bar/"); | 88 GURL url7("https://foo.bar/"); |
| 92 | 89 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 116 AddContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_BLOCK, | 113 AddContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_BLOCK, |
| 117 url1); | 114 url1); |
| 118 | 115 |
| 119 // Same as above, but the site with notifications should be at the front. | 116 // Same as above, but the site with notifications should be at the front. |
| 120 expected_sorted_domains = {"youtube.com", "foo.bar", "example.com", | 117 expected_sorted_domains = {"youtube.com", "foo.bar", "example.com", |
| 121 "chrome.com", "google.com"}; | 118 "chrome.com", "google.com"}; |
| 122 EXPECT_THAT(ImportantSitesUtil::GetImportantRegisterableDomains( | 119 EXPECT_THAT(ImportantSitesUtil::GetImportantRegisterableDomains( |
| 123 profile(), kNumImportantSites), | 120 profile(), kNumImportantSites), |
| 124 ::testing::ElementsAreArray(expected_sorted_domains)); | 121 ::testing::ElementsAreArray(expected_sorted_domains)); |
| 125 } | 122 } |
| OLD | NEW |