~mbranton/libopenshot/alpha-channel-fix

« back to all changes in this revision

Viewing changes to tests/Cache_Tests.cpp

  • Committer: Jonathan Thomas
  • Date: 2016-09-08 07:33:24 UTC
  • Revision ID: jonathan@openshot.org-20160908073324-65qzdcd014mgs3ug
Adding additional logging to unittests, to help find an issue on certain systems

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
TEST(Cache_Default_Constructor)
36
36
{
 
37
        cout << "Cache_Default_Constructor" << endl;
37
38
        // Create cache object
38
39
        CacheMemory c;
39
40
 
52
53
 
53
54
TEST(Cache_Max_Bytes_Constructor)
54
55
{
 
56
        cout << "Cache_Max_Bytes_Constructor" << endl;
55
57
        // Create cache object (with a max of 5 previous items)
56
58
        CacheMemory c(250 * 1024);
57
59
 
91
93
 
92
94
TEST(Cache_Clear)
93
95
{
 
96
        cout << "Cache_Clear" << endl;
94
97
        // Create cache object
95
98
        CacheMemory c(250 * 1024);
96
99
 
115
118
 
116
119
TEST(Cache_Add_Duplicate_Frames)
117
120
{
 
121
        cout << "Cache_Add_Duplicate_Frames" << endl;
118
122
        // Create cache object
119
123
        CacheMemory c(250 * 1024);
120
124
 
132
136
 
133
137
TEST(Cache_Check_If_Frame_Exists)
134
138
{
 
139
        cout << "Cache_Check_If_Frame_Exists" << endl;
135
140
        // Create cache object
136
141
        CacheMemory c(250 * 1024);
137
142
 
156
161
 
157
162
TEST(Cache_GetFrame)
158
163
{
 
164
        cout << "Cache_GetFrame" << endl;
159
165
        // Create cache object
160
166
        CacheMemory c(250 * 1024);
161
167
 
181
187
 
182
188
TEST(Cache_GetSmallest)
183
189
{
 
190
        cout << "Cache_GetSmallest" << endl;
184
191
        // Create cache object (with a max of 10 items)
185
192
        CacheMemory c(250 * 1024);
186
193
 
209
216
 
210
217
TEST(Cache_Remove)
211
218
{
 
219
        cout << "Cache_Remove" << endl;
212
220
        // Create cache object (with a max of 10 items)
213
221
        CacheMemory c(250 * 1024);
214
222
 
249
257
 
250
258
TEST(Cache_Set_Max_Bytes)
251
259
{
 
260
        cout << "Cache_Set_Max_Bytes" << endl;
252
261
        // Create cache object
253
262
        CacheMemory c;
254
263
 
272
281
        CHECK_EQUAL(4 * 1024, c.GetMaxBytes());
273
282
}
274
283
 
 
284
TEST(Cache_Multiple_Remove)
 
285
{
 
286
        cout << "Cache_Multiple_Remove" << endl;
 
287
        // Create cache object (using platform /temp/ directory)
 
288
        CacheMemory c;
 
289
 
 
290
        // Add frames to disk cache
 
291
        for (int i = 1; i <= 20; i++)
 
292
        {
 
293
                // Add blank frame to the cache
 
294
                tr1::shared_ptr<Frame> f(new Frame());
 
295
                f->number = i;
 
296
                // Add some picture data
 
297
                f->AddColor(1280, 720, "Blue");
 
298
                f->ResizeAudio(2, 500, 44100, LAYOUT_STEREO);
 
299
                f->AddAudioSilence(500);
 
300
                c.Add(f);
 
301
        }
 
302
 
 
303
        // Should have 20 frames
 
304
        CHECK_EQUAL(20, c.Count());
 
305
 
 
306
        // Remove all 20 frames
 
307
        c.Remove(1, 20);
 
308
 
 
309
        // Should have 20 frames
 
310
        CHECK_EQUAL(0, c.Count());
 
311
}
 
312
 
275
313
TEST(CacheDisk_Set_Max_Bytes)
276
314
{
 
315
        cout << "CacheDisk_Set_Max_Bytes" << endl;
277
316
        // Create cache object (using platform /temp/ directory)
278
317
        CacheDisk c("", "PPM", 1.0, 0.25);
279
318
 
311
350
 
312
351
}
313
352
 
 
353
TEST(CacheDisk_Multiple_Remove)
 
354
{
 
355
        cout << "CacheDisk_Multiple_Remove" << endl;
 
356
        // Create cache object (using platform /temp/ directory)
 
357
        CacheDisk c("", "PPM", 1.0, 0.25);
 
358
 
 
359
        // Add frames to disk cache
 
360
        for (int i = 1; i <= 20; i++)
 
361
        {
 
362
                // Add blank frame to the cache
 
363
                tr1::shared_ptr<Frame> f(new Frame());
 
364
                f->number = i;
 
365
                // Add some picture data
 
366
                f->AddColor(1280, 720, "Blue");
 
367
                f->ResizeAudio(2, 500, 44100, LAYOUT_STEREO);
 
368
                f->AddAudioSilence(500);
 
369
                c.Add(f);
 
370
        }
 
371
 
 
372
        // Should have 20 frames
 
373
        CHECK_EQUAL(20, c.Count());
 
374
 
 
375
        // Remove all 20 frames
 
376
        c.Remove(1, 20);
 
377
 
 
378
        // Should have 20 frames
 
379
        CHECK_EQUAL(0, c.Count());
 
380
}
 
381
 
314
382
TEST(CacheDisk_JSON)
315
383
{
 
384
        cout << "CacheDisk_JSON" << endl;
316
385
        // Create cache object (using platform /temp/ directory)
317
386
        CacheDisk c("", "PPM", 1.0, 0.25);
318
387
 
350
419
 
351
420
TEST(CacheMemory_JSON)
352
421
{
 
422
        cout << "CacheMemory_JSON" << endl;
353
423
        // Create memory cache object
354
424
        CacheMemory c;
355
425