270
271
c.SetMaxBytes(4 * 1024);
271
272
CHECK_EQUAL(4 * 1024, c.GetMaxBytes());
275
TEST(CacheDisk_Set_Max_Bytes)
277
// Create cache object (using platform /temp/ directory)
278
CacheDisk c("", "PPM", 1.0, 0.25);
280
// Add frames to disk cache
281
for (int i = 0; i < 20; i++)
283
// Add blank frame to the cache
284
tr1::shared_ptr<Frame> f(new Frame());
286
// Add some picture data
287
f->AddColor(1280, 720, "Blue");
288
f->ResizeAudio(2, 500, 44100, LAYOUT_STEREO);
289
f->AddAudioSilence(500);
293
CHECK_EQUAL(0, c.GetMaxBytes()); // Cache defaults max frames to -1, unlimited frames
296
c.SetMaxBytes(8 * 1024);
297
CHECK_EQUAL(8 * 1024, c.GetMaxBytes());
300
c.SetMaxBytes(4 * 1024);
301
CHECK_EQUAL(4 * 1024, c.GetMaxBytes());
303
// Read frames from disk cache
304
tr1::shared_ptr<Frame> f = c.GetFrame(5);
305
CHECK_EQUAL(320, f->GetWidth());
306
CHECK_EQUAL(180, f->GetHeight());
307
CHECK_EQUAL(2, f->GetAudioChannelsCount());
308
CHECK_EQUAL(500, f->GetAudioSamplesCount());
309
CHECK_EQUAL(LAYOUT_STEREO, f->ChannelsLayout());
310
CHECK_EQUAL(44100, f->SampleRate());
316
// Create cache object (using platform /temp/ directory)
317
CacheDisk c("", "PPM", 1.0, 0.25);
319
// Add some frames (out of order)
320
tr1::shared_ptr<Frame> f3(new Frame(3, 1280, 720, "Blue", 500, 2));
322
CHECK_EQUAL(1, c.JsonValue()["ranges"].size());
323
CHECK_EQUAL("1", c.JsonValue()["version"].asString());
325
// Add some frames (out of order)
326
tr1::shared_ptr<Frame> f1(new Frame(1, 1280, 720, "Blue", 500, 2));
328
CHECK_EQUAL(2, c.JsonValue()["ranges"].size());
329
CHECK_EQUAL("2", c.JsonValue()["version"].asString());
331
// Add some frames (out of order)
332
tr1::shared_ptr<Frame> f2(new Frame(2, 1280, 720, "Blue", 500, 2));
334
CHECK_EQUAL(1, c.JsonValue()["ranges"].size());
335
CHECK_EQUAL("3", c.JsonValue()["version"].asString());
337
// Add some frames (out of order)
338
tr1::shared_ptr<Frame> f5(new Frame(5, 1280, 720, "Blue", 500, 2));
340
CHECK_EQUAL(2, c.JsonValue()["ranges"].size());
341
CHECK_EQUAL("4", c.JsonValue()["version"].asString());
343
// Add some frames (out of order)
344
tr1::shared_ptr<Frame> f4(new Frame(4, 1280, 720, "Blue", 500, 2));
346
CHECK_EQUAL(1, c.JsonValue()["ranges"].size());
347
CHECK_EQUAL("5", c.JsonValue()["version"].asString());
351
TEST(CacheMemory_JSON)
353
// Create memory cache object
356
// Add some frames (out of order)
357
tr1::shared_ptr<Frame> f3(new Frame(3, 1280, 720, "Blue", 500, 2));
359
CHECK_EQUAL(1, c.JsonValue()["ranges"].size());
360
CHECK_EQUAL("1", c.JsonValue()["version"].asString());
362
// Add some frames (out of order)
363
tr1::shared_ptr<Frame> f1(new Frame(1, 1280, 720, "Blue", 500, 2));
365
CHECK_EQUAL(2, c.JsonValue()["ranges"].size());
366
CHECK_EQUAL("2", c.JsonValue()["version"].asString());
368
// Add some frames (out of order)
369
tr1::shared_ptr<Frame> f2(new Frame(2, 1280, 720, "Blue", 500, 2));
371
CHECK_EQUAL(1, c.JsonValue()["ranges"].size());
372
CHECK_EQUAL("3", c.JsonValue()["version"].asString());
374
// Add some frames (out of order)
375
tr1::shared_ptr<Frame> f5(new Frame(5, 1280, 720, "Blue", 500, 2));
377
CHECK_EQUAL(2, c.JsonValue()["ranges"].size());
378
CHECK_EQUAL("4", c.JsonValue()["version"].asString());
380
// Add some frames (out of order)
381
tr1::shared_ptr<Frame> f4(new Frame(4, 1280, 720, "Blue", 500, 2));
383
CHECK_EQUAL(1, c.JsonValue()["ranges"].size());
384
CHECK_EQUAL("5", c.JsonValue()["version"].asString());
b'\\ No newline at end of file'