MCPcopy Create free account
hub / github.com/Snapchat/Valdi / SetUpBase

Method SetUpBase

valdi/test/snap_drawing/ImageCache_tests.cpp:25–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23class ImageCacheTestsBase {
24protected:
25 void SetUpBase() {
26 auto img = Image::makeFromBitmap(createTestBitmap(), true).value();
27 // NOTE(rjaber): We are relying on the fact that image cache will never evict in use images
28 _cache = std::make_unique<ImageCache>(ConsoleLogger::getLogger(), ImageCacheItem::imageSize(img));
29 _cache->setMaxAge(_maxAge);
30
31 auto zeroBitmap = loadResourceFromDisk("testdata/0x0.bmp");
32 ASSERT_FALSE(zeroBitmap.failure())
33 << "Failed to load testdata/0x0.bmp (ensure the file is in test data/runfiles)";
34
35 _width = img->width();
36 _height = img->height();
37
38 auto cancel = makeShared<SimpleAtomicCancelable>();
39 _cache->setCachedItemAndGetResizedImage(_url, img, _width, _height);
40
41 _imgSize = ImageCacheItem::imageSize(img);
42 }
43
44 Result<Valdi::Ref<Image>> getImage(const StringBox& url, int32_t width, int32_t height) {
45 auto result = _cache->getResizedCachedImage(url, width, height);

Callers

nothing calls this directly

Calls 8

createTestBitmapFunction · 0.85
loadResourceFromDiskFunction · 0.85
setMaxAgeMethod · 0.80
valueMethod · 0.65
failureMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected