| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 base::Unretained(this))); | 178 base::Unretained(this))); |
| 179 counter.Restart(); | 179 counter.Restart(); |
| 180 | 180 |
| 181 RunAndWaitForResult(); | 181 RunAndWaitForResult(); |
| 182 | 182 |
| 183 EXPECT_TRUE(CallbackCalled()); | 183 EXPECT_TRUE(CallbackCalled()); |
| 184 EXPECT_EQ(1u, GetCount()); | 184 EXPECT_EQ(1u, GetCount()); |
| 185 EXPECT_EQ(kOrigin.host(), GetOrigin()); | 185 EXPECT_EQ(kOrigin.host(), GetOrigin()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Tests that the counter does not count if the deletion preference is false. | |
| 189 IN_PROC_BROWSER_TEST_F(MediaLicensesCounterTest, PrefIsFalse) { | |
| 190 SetMediaLicenseDeletionPref(false); | |
| 191 | |
| 192 Profile* profile = browser()->profile(); | |
| 193 MediaLicensesCounter counter(profile); | |
| 194 counter.Init(profile->GetPrefs(), | |
| 195 base::Bind(&MediaLicensesCounterTest::CountingCallback, | |
| 196 base::Unretained(this))); | |
| 197 counter.Restart(); | |
| 198 | |
| 199 EXPECT_FALSE(CallbackCalled()); | |
| 200 } | |
| 201 | |
| 202 // Tests that the counter starts counting automatically when the deletion | 188 // Tests that the counter starts counting automatically when the deletion |
| 203 // pref changes to true. | 189 // pref changes to true. |
| 204 IN_PROC_BROWSER_TEST_F(MediaLicensesCounterTest, PrefChanged) { | 190 IN_PROC_BROWSER_TEST_F(MediaLicensesCounterTest, PrefChanged) { |
| 205 SetMediaLicenseDeletionPref(false); | 191 SetMediaLicenseDeletionPref(false); |
| 206 | 192 |
| 207 Profile* profile = browser()->profile(); | 193 Profile* profile = browser()->profile(); |
| 208 MediaLicensesCounter counter(profile); | 194 MediaLicensesCounter counter(profile); |
| 209 counter.Init(profile->GetPrefs(), | 195 counter.Init(profile->GetPrefs(), |
| 210 base::Bind(&MediaLicensesCounterTest::CountingCallback, | 196 base::Bind(&MediaLicensesCounterTest::CountingCallback, |
| 211 base::Unretained(this))); | 197 base::Unretained(this))); |
| 212 SetMediaLicenseDeletionPref(true); | 198 SetMediaLicenseDeletionPref(true); |
| 213 | 199 |
| 214 RunAndWaitForResult(); | 200 RunAndWaitForResult(); |
| 215 | 201 |
| 216 EXPECT_TRUE(CallbackCalled()); | 202 EXPECT_TRUE(CallbackCalled()); |
| 217 EXPECT_EQ(0u, GetCount()); | 203 EXPECT_EQ(0u, GetCount()); |
| 218 EXPECT_TRUE(GetOrigin().empty()); | 204 EXPECT_TRUE(GetOrigin().empty()); |
| 219 } | 205 } |
| 220 | 206 |
| 221 } // namespace | 207 } // namespace |
| OLD | NEW |