Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/engagement/site_engagement_service.h" | 5 #include "chrome/browser/engagement/site_engagement_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1828 | 1828 |
| 1829 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::IO, | 1829 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::IO, |
| 1830 settings_map, url1)); | 1830 settings_map, url1)); |
| 1831 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::FILE, | 1831 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::FILE, |
| 1832 settings_map, url2)); | 1832 settings_map, url2)); |
| 1833 EXPECT_EQ(4, CheckScoreFromSettingsOnThread(content::BrowserThread::FILE, | 1833 EXPECT_EQ(4, CheckScoreFromSettingsOnThread(content::BrowserThread::FILE, |
| 1834 incognito_settings_map, url1)); | 1834 incognito_settings_map, url1)); |
| 1835 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::IO, | 1835 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::IO, |
| 1836 incognito_settings_map, url2)); | 1836 incognito_settings_map, url2)); |
| 1837 } | 1837 } |
| 1838 | |
| 1839 TEST_F(SiteEngagementServiceTest, GetAllDetailsIncludesBonusOnlyScores) { | |
| 1840 GURL url1("http://www.google.com/"); | |
| 1841 GURL url2("https://www.google.com/"); | |
| 1842 GURL url3("https://drive.google.com/"); | |
| 1843 | |
| 1844 std::vector<mojom::SiteEngagementDetails> details = service_->GetAllDetails(); | |
| 1845 EXPECT_EQ(0u, details.size()); | |
| 1846 | |
| 1847 // Add a single site score via explicitly resetting the engagement score. | |
| 1848 service_->ResetBaseScoreForURL(url1, 5); | |
| 1849 | |
| 1850 // Add a second site indirectly, via notifications permissions. | |
| 1851 HostContentSettingsMap* settings_map = | |
| 1852 HostContentSettingsMapFactory::GetForProfile(profile()); | |
| 1853 settings_map->SetContentSettingDefaultScope( | |
| 1854 url2, url2, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string(), | |
|
dominickn
2017/04/10 04:49:26
Nit: this second url2 should be GURL(). Notificati
Wez
2017/04/10 21:18:09
This was actually cribbed from the tests above. :P
| |
| 1855 CONTENT_SETTING_ALLOW); | |
| 1856 | |
| 1857 // Add a third site with notifications permission explicitly denied, to verify | |
| 1858 // that it is not included. | |
| 1859 settings_map->SetContentSettingDefaultScope( | |
| 1860 url3, url3, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string(), | |
|
dominickn
2017/04/10 04:49:26
Ditto
Wez
2017/04/10 21:18:09
Done.
| |
| 1861 CONTENT_SETTING_BLOCK); | |
| 1862 | |
| 1863 // Verify that the URLs with engagement, and with notifications permission | |
| 1864 // boosted engagement total, are included. | |
| 1865 details = service_->GetAllDetails(); | |
| 1866 EXPECT_EQ(2u, details.size()); | |
| 1867 } | |
| OLD | NEW |