| Index: ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
|
| diff --git a/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm b/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
|
| index c77a9ae94f56d7d2b24d2c93758101c6001a9901..40189d4ebf6269f2089a225aafcd848a575d99fd 100644
|
| --- a/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
|
| +++ b/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
|
| @@ -16,6 +16,7 @@
|
| #include "base/run_loop.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #include "base/time/time.h"
|
| +#include "ios/chrome/browser/experimental_flags.h"
|
| #include "ios/chrome/browser/ui/ui_util.h"
|
| #include "ios/web/public/test/test_web_thread_bundle.h"
|
| #include "ios/web/public/web_thread.h"
|
| @@ -33,20 +34,6 @@ static const NSUInteger kSnapshotPixelSize = 8;
|
| - (void)handleLowMemory;
|
| @end
|
|
|
| -@interface SnapshotCache (TestingAdditions)
|
| -- (BOOL)hasImageInMemory:(NSString*)sessionID;
|
| -- (BOOL)hasGreyImageInMemory:(NSString*)sessionID;
|
| -@end
|
| -
|
| -@implementation SnapshotCache (TestingAdditions)
|
| -- (BOOL)hasImageInMemory:(NSString*)sessionID {
|
| - return [imageDictionary_ objectForKey:sessionID] != nil;
|
| -}
|
| -- (BOOL)hasGreyImageInMemory:(NSString*)sessionID {
|
| - return [greyImageDictionary_ objectForKey:sessionID] != nil;
|
| -}
|
| -@end
|
| -
|
| namespace {
|
|
|
| class SnapshotCacheTest : public PlatformTest {
|
| @@ -235,8 +222,12 @@ TEST_F(SnapshotCacheTest, Cache) {
|
|
|
| SnapshotCache* cache = GetSnapshotCache();
|
|
|
| + NSUInteger expectedCacheSize = kSessionCount;
|
| + if (experimental_flags::IsLRUSnapshotCacheEnabled())
|
| + expectedCacheSize = MIN(kSessionCount, [cache lruCacheMaxSize]);
|
| +
|
| // Put all images in the cache.
|
| - for (NSUInteger i = 0; i < kSessionCount; ++i) {
|
| + for (NSUInteger i = 0; i < expectedCacheSize; ++i) {
|
| UIImage* image = [testImages_ objectAtIndex:i];
|
| NSString* sessionID = [testSessions_ objectAtIndex:i];
|
| [cache setImage:image withSessionID:sessionID];
|
| @@ -244,7 +235,7 @@ TEST_F(SnapshotCacheTest, Cache) {
|
|
|
| // Get images back.
|
| __block NSUInteger numberOfCallbacks = 0;
|
| - for (NSUInteger i = 0; i < kSessionCount; ++i) {
|
| + for (NSUInteger i = 0; i < expectedCacheSize; ++i) {
|
| NSString* sessionID = [testSessions_ objectAtIndex:i];
|
| UIImage* expectedImage = [testImages_ objectAtIndex:i];
|
| EXPECT_TRUE(expectedImage != nil);
|
| @@ -256,7 +247,7 @@ TEST_F(SnapshotCacheTest, Cache) {
|
| ++numberOfCallbacks;
|
| }];
|
| }
|
| - EXPECT_EQ(kSessionCount, numberOfCallbacks);
|
| + EXPECT_EQ(expectedCacheSize, numberOfCallbacks);
|
| }
|
|
|
| // This test puts all the snapshots in the cache and flushes them to disk.
|
|
|