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

Side by Side Diff: ios/chrome/browser/snapshots/snapshot_cache_unittest.mm

Issue 2881873002: [reland] Use TaskScheduler instead of SequencedWorkerPool in snapshot_cache.mm. (Closed)
Patch Set: add comment Created 3 years, 6 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
« no previous file with comments | « ios/chrome/browser/snapshots/snapshot_cache.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #import "ios/chrome/browser/snapshots/snapshot_cache.h" 5 #import "ios/chrome/browser/snapshots/snapshot_cache.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/mac/bind_objc_block.h" 13 #include "base/mac/bind_objc_block.h"
14 #include "base/mac/scoped_cftyperef.h" 14 #include "base/mac/scoped_cftyperef.h"
15 #include "base/mac/scoped_nsautorelease_pool.h" 15 #include "base/mac/scoped_nsautorelease_pool.h"
16 #include "base/mac/scoped_nsobject.h" 16 #include "base/mac/scoped_nsobject.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/strings/sys_string_conversions.h" 18 #include "base/strings/sys_string_conversions.h"
19 #include "base/threading/sequenced_worker_pool.h" 19 #include "base/task_scheduler/task_scheduler.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #import "ios/chrome/browser/snapshots/snapshot_cache_internal.h" 21 #import "ios/chrome/browser/snapshots/snapshot_cache_internal.h"
22 #include "ios/web/public/test/test_web_thread_bundle.h" 22 #include "ios/web/public/test/test_web_thread_bundle.h"
23 #include "ios/web/public/web_thread.h"
24 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
25 #include "testing/gtest_mac.h" 24 #include "testing/gtest_mac.h"
26 #include "testing/platform_test.h" 25 #include "testing/platform_test.h"
27 26
28 static const NSUInteger kSessionCount = 10; 27 static const NSUInteger kSessionCount = 10;
29 static const NSUInteger kSnapshotPixelSize = 8; 28 static const NSUInteger kSnapshotPixelSize = 8;
30 29
31 namespace { 30 namespace {
32 31
33 class SnapshotCacheTest : public PlatformTest { 32 class SnapshotCacheTest : public PlatformTest {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 CGContextSetRGBStrokeColor(context, r, g, b, 1.0); 76 CGContextSetRGBStrokeColor(context, r, g, b, 1.0);
78 CGContextSetRGBFillColor(context, r, g, b, 1.0); 77 CGContextSetRGBFillColor(context, r, g, b, 1.0);
79 CGContextFillRect( 78 CGContextFillRect(
80 context, CGRectMake(0.0, 0.0, kSnapshotPixelSize, kSnapshotPixelSize)); 79 context, CGRectMake(0.0, 0.0, kSnapshotPixelSize, kSnapshotPixelSize));
81 return UIGraphicsGetImageFromCurrentImageContext(); 80 return UIGraphicsGetImageFromCurrentImageContext();
82 } 81 }
83 82
84 // Flushes all the runloops internally used by the snapshot cache. 83 // Flushes all the runloops internally used by the snapshot cache.
85 void FlushRunLoops() { 84 void FlushRunLoops() {
86 base::RunLoop().RunUntilIdle(); 85 base::RunLoop().RunUntilIdle();
87 web::WebThread::GetBlockingPool()->FlushForTesting(); 86 base::TaskScheduler::GetInstance()->FlushForTesting();
88 base::RunLoop().RunUntilIdle(); 87 base::RunLoop().RunUntilIdle();
89 } 88 }
90 89
91 // This function removes the snapshots both from dictionary and from disk. 90 // This function removes the snapshots both from dictionary and from disk.
92 void ClearDumpedImages() { 91 void ClearDumpedImages() {
93 SnapshotCache* cache = GetSnapshotCache(); 92 SnapshotCache* cache = GetSnapshotCache();
94 93
95 NSString* sessionID; 94 NSString* sessionID;
96 for (sessionID in testSessions_.get()) 95 for (sessionID in testSessions_.get())
97 [cache removeImageWithSessionID:sessionID]; 96 [cache removeImageWithSessionID:sessionID];
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 EXPECT_TRUE(base::PathExists(retinaFile)); 563 EXPECT_TRUE(base::PathExists(retinaFile));
565 564
566 // Delete the image. 565 // Delete the image.
567 [cache removeImageWithSessionID:kSession]; 566 [cache removeImageWithSessionID:kSession];
568 FlushRunLoops(); // ensure the file is removed. 567 FlushRunLoops(); // ensure the file is removed.
569 568
570 EXPECT_FALSE(base::PathExists(retinaFile)); 569 EXPECT_FALSE(base::PathExists(retinaFile));
571 } 570 }
572 571
573 } // namespace 572 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/snapshots/snapshot_cache.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698