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

Side by Side Diff: chrome/browser/android/preferences/important_sites_util_unittest.cc

Issue 1465363002: [Storage] Android - ManageSpace UI, Important Origins, and CBD Dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dialog layout change to make message always appear, and comments Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 64 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
65 content_settings::ResourceIdentifier(), setting); 65 content_settings::ResourceIdentifier(), setting);
66 } 66 }
67 67
68 private: 68 private:
69 base::ScopedTempDir temp_dir_; 69 base::ScopedTempDir temp_dir_;
70 }; 70 };
71 71
72 TEST_F(ImportantSitesUtilTest, TestNoImportantSites) { 72 TEST_F(ImportantSitesUtilTest, TestNoImportantSites) {
73 EXPECT_TRUE(ImportantSitesUtil::GetImportantRegisterableDomains( 73 EXPECT_TRUE(ImportantSitesUtil::GetImportantRegisterableDomains(
74 profile(), kNumImportantSites) 74 profile(), kNumImportantSites, nullptr)
Theresa 2016/05/26 18:08:45 Will you please add a simple test where there are
dmurph 2016/05/27 02:09:12 Done.
75 .empty()); 75 .empty());
76 } 76 }
77 77
78 TEST_F(ImportantSitesUtilTest, NotificationsThenEngagement) { 78 TEST_F(ImportantSitesUtilTest, NotificationsThenEngagement) {
79 SiteEngagementService* service = SiteEngagementService::Get(profile()); 79 SiteEngagementService* service = SiteEngagementService::Get(profile());
80 ASSERT_TRUE(service); 80 ASSERT_TRUE(service);
81 81
82 GURL url1("http://www.google.com/"); 82 GURL url1("http://www.google.com/");
83 GURL url2("https://www.google.com/"); 83 GURL url2("https://www.google.com/");
84 GURL url3("https://drive.google.com/"); 84 GURL url3("https://drive.google.com/");
85 GURL url4("https://www.chrome.com/"); 85 GURL url4("https://www.chrome.com/");
86 GURL url5("https://www.example.com/"); 86 GURL url5("https://www.example.com/");
87 GURL url6("https://youtube.com/"); 87 GURL url6("https://youtube.com/");
88 GURL url7("https://foo.bar/"); 88 GURL url7("https://foo.bar/");
89 89
90 service->ResetScoreForURL(url1, 5); 90 service->ResetScoreForURL(url1, 5);
91 service->ResetScoreForURL(url2, 2); // Below medium engagement (5). 91 service->ResetScoreForURL(url2, 2); // Below medium engagement (5).
92 service->ResetScoreForURL(url3, 7); 92 service->ResetScoreForURL(url3, 7);
93 service->ResetScoreForURL(url4, 8); 93 service->ResetScoreForURL(url4, 8);
94 service->ResetScoreForURL(url5, 9); 94 service->ResetScoreForURL(url5, 9);
95 service->ResetScoreForURL(url6, 1); // Below the medium engagement (5). 95 service->ResetScoreForURL(url6, 1); // Below the medium engagement (5).
96 service->ResetScoreForURL(url7, 11); 96 service->ResetScoreForURL(url7, 11);
97 97
98 // Here we should have: 98 // Here we should have:
99 // 1: removed domains below minimum engagement, 99 // 1: removed domains below minimum engagement,
100 // 2: combined the google.com entries, and 100 // 2: combined the google.com entries, and
101 // 3: sorted by the score. 101 // 3: sorted by the score.
102 std::vector<std::string> expected_sorted_domains = { 102 std::vector<std::string> expected_sorted_domains = {
103 "foo.bar", "example.com", "chrome.com", "google.com"}; 103 "foo.bar", "example.com", "chrome.com", "google.com"};
104 std::vector<GURL> example_origins;
104 EXPECT_THAT(ImportantSitesUtil::GetImportantRegisterableDomains( 105 EXPECT_THAT(ImportantSitesUtil::GetImportantRegisterableDomains(
105 profile(), kNumImportantSites), 106 profile(), kNumImportantSites, &example_origins),
106 ::testing::ElementsAreArray(expected_sorted_domains)); 107 ::testing::ElementsAreArray(expected_sorted_domains));
108 std::vector<GURL> expected_sorted_origins = {url7, url5, url4, url1};
109 EXPECT_THAT(example_origins,
110 ::testing::ElementsAreArray(expected_sorted_origins));
107 111
108 // Test that notifications get moved to the front. 112 // Test that notifications get moved to the front.
109 AddContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW, 113 AddContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW,
110 url6); 114 url6);
111 // BLOCK'ed sites don't count. We want to make sure we only bump sites that 115 // BLOCK'ed sites don't count. We want to make sure we only bump sites that
112 // were granted the permsion. 116 // were granted the permsion.
113 AddContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_BLOCK, 117 AddContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_BLOCK,
114 url1); 118 url1);
115 119
116 // Same as above, but the site with notifications should be at the front. 120 // Same as above, but the site with notifications should be at the front.
117 expected_sorted_domains = {"youtube.com", "foo.bar", "example.com", 121 expected_sorted_domains = {"youtube.com", "foo.bar", "example.com",
118 "chrome.com", "google.com"}; 122 "chrome.com", "google.com"};
119 EXPECT_THAT(ImportantSitesUtil::GetImportantRegisterableDomains( 123 EXPECT_THAT(ImportantSitesUtil::GetImportantRegisterableDomains(
120 profile(), kNumImportantSites), 124 profile(), kNumImportantSites),
121 ::testing::ElementsAreArray(expected_sorted_domains)); 125 ::testing::ElementsAreArray(expected_sorted_domains));
122 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698