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

Side by Side Diff: components/offline_pages/offline_page_storage_manager_unittest.cc

Issue 2111653002: [Offline Pages] Adding metadatas for namespace async_loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing tests. Created 4 years, 5 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 "components/offline_pages/offline_page_storage_manager.h" 5 #include "components/offline_pages/offline_page_storage_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 {{kBookmarkNamespace, 30, 0}, {kLastNNamespace, 100, 1}}), 293 {{kBookmarkNamespace, 30, 0}, {kLastNNamespace, 100, 1}}),
294 {1000 * (1 << 20), 0}); 294 {1000 * (1 << 20), 0});
295 clock()->Advance(base::TimeDelta::FromMinutes(30)); 295 clock()->Advance(base::TimeDelta::FromMinutes(30));
296 TryClearPages(); 296 TryClearPages();
297 EXPECT_EQ(1, last_cleared_page_count()); 297 EXPECT_EQ(1, last_cleared_page_count());
298 EXPECT_EQ(1, total_cleared_times()); 298 EXPECT_EQ(1, total_cleared_times());
299 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); 299 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result());
300 EXPECT_EQ(0, static_cast<int>(model()->GetRemovedPages().size())); 300 EXPECT_EQ(0, static_cast<int>(model()->GetRemovedPages().size()));
301 } 301 }
302 302
303 TEST_F(OfflinePageStorageManagerTest, TestDeleteAsyncPages) {
304 Initialize(std::vector<PageSettings>({{kAsyncNamespace, 20, 0}}));
305 clock()->Advance(base::TimeDelta::FromDays(367));
306 TryClearPages();
307 EXPECT_EQ(0, last_cleared_page_count());
308 EXPECT_EQ(1, total_cleared_times());
309 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result());
310 EXPECT_EQ(0, static_cast<int>(model()->GetRemovedPages().size()));
311 }
312
303 TEST_F(OfflinePageStorageManagerTest, TestDeletionFailed) { 313 TEST_F(OfflinePageStorageManagerTest, TestDeletionFailed) {
304 Initialize(std::vector<PageSettings>( 314 Initialize(std::vector<PageSettings>(
305 {{kBookmarkNamespace, 10, 10}, {kLastNNamespace, 10, 10}}), 315 {{kBookmarkNamespace, 10, 10}, {kLastNNamespace, 10, 10}}),
306 {kFreeSpaceNormal, 0}, TestOptions::DELETE_FAILURE); 316 {kFreeSpaceNormal, 0}, TestOptions::DELETE_FAILURE);
307 TryClearPages(); 317 TryClearPages();
308 EXPECT_EQ(20, last_cleared_page_count()); 318 EXPECT_EQ(20, last_cleared_page_count());
309 EXPECT_EQ(1, total_cleared_times()); 319 EXPECT_EQ(1, total_cleared_times());
310 EXPECT_EQ(ClearStorageResult::DELETE_FAILURE, last_clear_storage_result()); 320 EXPECT_EQ(ClearStorageResult::DELETE_FAILURE, last_clear_storage_result());
311 EXPECT_EQ(0, static_cast<int>(model()->GetRemovedPages().size())); 321 EXPECT_EQ(0, static_cast<int>(model()->GetRemovedPages().size()));
312 } 322 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 379
370 clock()->Advance(kRemovePageItemInterval + base::TimeDelta::FromDays(1)); 380 clock()->Advance(kRemovePageItemInterval + base::TimeDelta::FromDays(1));
371 TryClearPages(); 381 TryClearPages();
372 EXPECT_EQ(10, last_cleared_page_count()); 382 EXPECT_EQ(10, last_cleared_page_count());
373 EXPECT_EQ(2, total_cleared_times()); 383 EXPECT_EQ(2, total_cleared_times());
374 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); 384 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result());
375 EXPECT_EQ(10, static_cast<int>(model()->GetRemovedPages().size())); 385 EXPECT_EQ(10, static_cast<int>(model()->GetRemovedPages().size()));
376 } 386 }
377 387
378 TEST_F(OfflinePageStorageManagerTest, TestClearMultipleTimes) { 388 TEST_F(OfflinePageStorageManagerTest, TestClearMultipleTimes) {
379 Initialize(std::vector<PageSettings>( 389 Initialize(std::vector<PageSettings>({{kBookmarkNamespace, 30, 0},
380 {{kBookmarkNamespace, 30, 0}, {kLastNNamespace, 100, 1}}), 390 {kLastNNamespace, 100, 1},
391 {kAsyncNamespace, 40, 0}}),
381 {1000 * (1 << 20), 0}); 392 {1000 * (1 << 20), 0});
382 clock()->Advance(base::TimeDelta::FromMinutes(30)); 393 clock()->Advance(base::TimeDelta::FromMinutes(30));
383 LifetimePolicy policy = 394 LifetimePolicy policy =
384 policy_controller()->GetPolicy(kLastNNamespace).lifetime_policy; 395 policy_controller()->GetPolicy(kLastNNamespace).lifetime_policy;
385 396
386 TryClearPages(); 397 TryClearPages();
387 EXPECT_EQ(1, last_cleared_page_count()); 398 EXPECT_EQ(1, last_cleared_page_count());
388 EXPECT_EQ(1, total_cleared_times()); 399 EXPECT_EQ(1, total_cleared_times());
389 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); 400 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result());
390 EXPECT_EQ(0, static_cast<int>(model()->GetRemovedPages().size())); 401 EXPECT_EQ(0, static_cast<int>(model()->GetRemovedPages().size()));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 EXPECT_EQ(0, model()->GetTotalSize()); 439 EXPECT_EQ(0, model()->GetTotalSize());
429 EXPECT_EQ(5, total_cleared_times()); 440 EXPECT_EQ(5, total_cleared_times());
430 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); 441 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result());
431 // Number of removed pages should be the ones expired above and all the pages 442 // Number of removed pages should be the ones expired above and all the pages
432 // initially created for last_n namespace. 443 // initially created for last_n namespace.
433 EXPECT_EQ(expired_page_count + 101, 444 EXPECT_EQ(expired_page_count + 101,
434 static_cast<int>(model()->GetRemovedPages().size())); 445 static_cast<int>(model()->GetRemovedPages().size()));
435 } 446 }
436 447
437 } // namespace offline_pages 448 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_storage_manager.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698