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/browsing_data/media_licenses_counter.h" | 5 #include "chrome/browser/browsing_data/media_licenses_counter.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 std::string origin_; | 149 std::string origin_; |
150 | 150 |
151 std::unique_ptr<base::RunLoop> run_loop_; | 151 std::unique_ptr<base::RunLoop> run_loop_; |
152 }; | 152 }; |
153 | 153 |
154 // Tests that for the empty file system, the result is zero. | 154 // Tests that for the empty file system, the result is zero. |
155 IN_PROC_BROWSER_TEST_F(MediaLicensesCounterTest, Empty) { | 155 IN_PROC_BROWSER_TEST_F(MediaLicensesCounterTest, Empty) { |
156 Profile* profile = browser()->profile(); | 156 Profile* profile = browser()->profile(); |
157 MediaLicensesCounter counter(profile); | 157 MediaLicensesCounter counter(profile); |
158 counter.Init(profile->GetPrefs(), | 158 counter.Init(profile->GetPrefs(), |
| 159 browsing_data::ClearBrowsingDataPreferenceType::DEFAULT, |
159 base::Bind(&MediaLicensesCounterTest::CountingCallback, | 160 base::Bind(&MediaLicensesCounterTest::CountingCallback, |
160 base::Unretained(this))); | 161 base::Unretained(this))); |
161 counter.Restart(); | 162 counter.Restart(); |
162 | 163 |
163 RunAndWaitForResult(); | 164 RunAndWaitForResult(); |
164 | 165 |
165 EXPECT_TRUE(CallbackCalled()); | 166 EXPECT_TRUE(CallbackCalled()); |
166 EXPECT_EQ(0u, GetCount()); | 167 EXPECT_EQ(0u, GetCount()); |
167 EXPECT_TRUE(GetOrigin().empty()); | 168 EXPECT_TRUE(GetOrigin().empty()); |
168 } | 169 } |
169 | 170 |
170 // Tests that for a non-empty file system, the result is nonzero. | 171 // Tests that for a non-empty file system, the result is nonzero. |
171 IN_PROC_BROWSER_TEST_F(MediaLicensesCounterTest, NonEmpty) { | 172 IN_PROC_BROWSER_TEST_F(MediaLicensesCounterTest, NonEmpty) { |
172 CreateMediaLicenseTestData(); | 173 CreateMediaLicenseTestData(); |
173 | 174 |
174 Profile* profile = browser()->profile(); | 175 Profile* profile = browser()->profile(); |
175 MediaLicensesCounter counter(profile); | 176 MediaLicensesCounter counter(profile); |
176 counter.Init(profile->GetPrefs(), | 177 counter.Init(profile->GetPrefs(), |
| 178 browsing_data::ClearBrowsingDataPreferenceType::DEFAULT, |
177 base::Bind(&MediaLicensesCounterTest::CountingCallback, | 179 base::Bind(&MediaLicensesCounterTest::CountingCallback, |
178 base::Unretained(this))); | 180 base::Unretained(this))); |
179 counter.Restart(); | 181 counter.Restart(); |
180 | 182 |
181 RunAndWaitForResult(); | 183 RunAndWaitForResult(); |
182 | 184 |
183 EXPECT_TRUE(CallbackCalled()); | 185 EXPECT_TRUE(CallbackCalled()); |
184 EXPECT_EQ(1u, GetCount()); | 186 EXPECT_EQ(1u, GetCount()); |
185 EXPECT_EQ(kOrigin.host(), GetOrigin()); | 187 EXPECT_EQ(kOrigin.host(), GetOrigin()); |
186 } | 188 } |
187 | 189 |
188 // Tests that the counter starts counting automatically when the deletion | 190 // Tests that the counter starts counting automatically when the deletion |
189 // pref changes to true. | 191 // pref changes to true. |
190 IN_PROC_BROWSER_TEST_F(MediaLicensesCounterTest, PrefChanged) { | 192 IN_PROC_BROWSER_TEST_F(MediaLicensesCounterTest, PrefChanged) { |
191 SetMediaLicenseDeletionPref(false); | 193 SetMediaLicenseDeletionPref(false); |
192 | 194 |
193 Profile* profile = browser()->profile(); | 195 Profile* profile = browser()->profile(); |
194 MediaLicensesCounter counter(profile); | 196 MediaLicensesCounter counter(profile); |
195 counter.Init(profile->GetPrefs(), | 197 counter.Init(profile->GetPrefs(), |
| 198 browsing_data::ClearBrowsingDataPreferenceType::DEFAULT, |
196 base::Bind(&MediaLicensesCounterTest::CountingCallback, | 199 base::Bind(&MediaLicensesCounterTest::CountingCallback, |
197 base::Unretained(this))); | 200 base::Unretained(this))); |
198 SetMediaLicenseDeletionPref(true); | 201 SetMediaLicenseDeletionPref(true); |
199 | 202 |
200 RunAndWaitForResult(); | 203 RunAndWaitForResult(); |
201 | 204 |
202 EXPECT_TRUE(CallbackCalled()); | 205 EXPECT_TRUE(CallbackCalled()); |
203 EXPECT_EQ(0u, GetCount()); | 206 EXPECT_EQ(0u, GetCount()); |
204 EXPECT_TRUE(GetOrigin().empty()); | 207 EXPECT_TRUE(GetOrigin().empty()); |
205 } | 208 } |
206 | 209 |
207 } // namespace | 210 } // namespace |
OLD | NEW |