GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update the test case `test15ThatQueryCacheTypeWork` to ensure the que… · SDWebImage/SDWebImage@b9f7757

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Tests/Tests
    • SDWebImageManagerTests.m
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Tests/Tests/SDWebImageManagerTests.m‎

Copy file name to clipboardExpand all lines: Tests/Tests/SDWebImageManagerTests.m
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,22 @@ - (void)test15ThatQueryCacheTypeWork {
377377
NSURL *url = [NSURL URLWithString:@"https://placehold.co/101x101.png"];
378378
NSString *key = [SDWebImageManager.sharedManager cacheKeyForURL:url];
379379
NSData *testImageData = [NSData dataWithContentsOfFile:[self testJPEGPath]];
380+
UIImage *testImage = [UIImage sd_imageWithData:testImageData];
380381
[SDImageCache.sharedImageCache storeImageDataToDisk:testImageData forKey:key];
381382

382383
// Query memory first
383384
[SDWebImageManager.sharedManager loadImageWithURL:url options:SDWebImageFromCacheOnly context:@{SDWebImageContextQueryCacheType : @(SDImageCacheTypeMemory)} progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
384385
expect(image).beNil();
385386
expect(cacheType).equal(SDImageCacheTypeNone);
387+
// Store the image to memory
388+
[SDImageCache.sharedImageCache storeImageToMemory:testImage forKey:key];
386389
// Query disk secondly
387390
[SDWebImageManager.sharedManager loadImageWithURL:url options:SDWebImageFromCacheOnly context:@{SDWebImageContextQueryCacheType : @(SDImageCacheTypeDisk)} progress:nil completed:^(UIImage * _Nullable image2, NSData * _Nullable data2, NSError * _Nullable error2, SDImageCacheType cacheType2, BOOL finished2, NSURL * _Nullable imageURL2) {
388391
expect(image2).notTo.beNil();
389392
expect(cacheType2).equal(SDImageCacheTypeDisk);
393+
// We should ensure that this image is not the same memory address as image1
394+
expect(image2 != testImage).beTruthy();
395+
[SDImageCache.sharedImageCache removeImageFromMemoryForKey:key];
390396
[SDImageCache.sharedImageCache removeImageFromDiskForKey:key];
391397
[expectation fulfill];
392398
}];

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.