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

Side by Side Diff: chrome/browser/browsing_data/history_counter_browsertest.cc

Issue 2623033003: Always show counters in the material design Clear Browsing Data dialog. (Closed)
Patch Set: iOS fix #2 Created 3 years, 11 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "components/browsing_data/core/counters/history_counter.h" 5 #include "components/browsing_data/core/counters/history_counter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/history/history_service_factory.h" 10 #include "chrome/browser/history/history_service_factory.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 ProfileSyncServiceFactory::GetForProfile(profile)); 206 ProfileSyncServiceFactory::GetForProfile(profile));
207 207
208 counter.Init(profile->GetPrefs(), base::Bind(&HistoryCounterTest::Callback, 208 counter.Init(profile->GetPrefs(), base::Bind(&HistoryCounterTest::Callback,
209 base::Unretained(this))); 209 base::Unretained(this)));
210 SetHistoryDeletionPref(true); 210 SetHistoryDeletionPref(true);
211 211
212 WaitForCounting(); 212 WaitForCounting();
213 EXPECT_EQ(2u, GetLocalResult()); 213 EXPECT_EQ(2u, GetLocalResult());
214 } 214 }
215 215
216 // Tests that the counter does not count history if the deletion
217 // preference is false.
218 IN_PROC_BROWSER_TEST_F(HistoryCounterTest, PrefIsFalse) {
219 SetHistoryDeletionPref(false);
220 AddVisit("https://www.google.com");
221
222 Profile* profile = browser()->profile();
223
224 browsing_data::HistoryCounter counter(
225 GetHistoryService(),
226 base::Bind(&HistoryCounterTest::GetRealWebHistoryService,
227 base::Unretained(this),
228 base::Unretained(profile)),
229 ProfileSyncServiceFactory::GetForProfile(profile));
230
231 counter.Init(profile->GetPrefs(), base::Bind(&HistoryCounterTest::Callback,
232 base::Unretained(this)));
233 counter.Restart();
234
235 EXPECT_FALSE(counter.HasTrackedTasks());
236 }
237
238 // Tests that changing the deletion period restarts the counting, and that 216 // Tests that changing the deletion period restarts the counting, and that
239 // the result takes visit dates into account. 217 // the result takes visit dates into account.
240 IN_PROC_BROWSER_TEST_F(HistoryCounterTest, PeriodChanged) { 218 IN_PROC_BROWSER_TEST_F(HistoryCounterTest, PeriodChanged) {
241 AddVisit("https://www.google.com"); 219 AddVisit("https://www.google.com");
242 220
243 RevertTimeInDays(2); 221 RevertTimeInDays(2);
244 AddVisit("https://www.google.com"); 222 AddVisit("https://www.google.com");
245 AddVisit("https://www.example.com"); 223 AddVisit("https://www.example.com");
246 224
247 RevertTimeInDays(4); 225 RevertTimeInDays(4);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // history deletion did not change. However, in reality we can get two 430 // history deletion did not change. However, in reality we can get two
453 // notifications, one that history sync has stopped and another that it is 431 // notifications, one that history sync has stopped and another that it is
454 // active again. 432 // active again.
455 433
456 // Stopping the Sync service triggers a restart. 434 // Stopping the Sync service triggers a restart.
457 sync_service->RequestStop(syncer::SyncService::CLEAR_DATA); 435 sync_service->RequestStop(syncer::SyncService::CLEAR_DATA);
458 WaitForCountingOrConfirmFinished(); 436 WaitForCountingOrConfirmFinished();
459 } 437 }
460 438
461 } // namespace 439 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698