All Classes Namespaces Functions Variables Enumerations Properties Pages
test_layer.cpp
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2012-2020 Matthew Chiawen Chang
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 */
16 #include "catch.hpp"
17 
18 #include "layer.h"
19 #include "layerbitmap.h"
20 #include "layervector.h"
21 #include "layercamera.h"
22 #include "layersound.h"
23 #include "bitmapimage.h"
24 #include "object.h"
25 #include "util.h"
26 
27 TEST_CASE("LayerType")
28 {
29  Object* object = new Object;
30 
31  SECTION("Bitmap Layer")
32  {
33  Layer* bitmapLayer = new LayerBitmap(object);
34  REQUIRE(bitmapLayer->type() == Layer::BITMAP);
35  delete bitmapLayer;
36  }
37  SECTION("Vector Layer")
38  {
39  Layer* vecLayer = new LayerVector(object);
40  REQUIRE(vecLayer->type() == Layer::VECTOR);
41  delete vecLayer;
42  }
43  SECTION("Camera Layer")
44  {
45  Layer* cameraLayer = new LayerCamera(object);
46  REQUIRE(cameraLayer->type() == Layer::CAMERA);
47  delete cameraLayer;
48  }
49  SECTION("Sound Layer")
50  {
51  Layer* soundLayer = new LayerSound(object);
52  REQUIRE(soundLayer->type() == Layer::SOUND);
53  delete soundLayer;
54  }
55 
56  delete object;
57 }
58 
59 SCENARIO("Add key frames into a Layer", "[Layer]")
60 {
61  Object* object = new Object;
62 
63  GIVEN("A Bitmap Layer")
64  {
65  Layer* layer = new LayerBitmap(object);
66 
67  REQUIRE(layer->addNewKeyFrameAt(0) == false); // first key position is 1.
68  REQUIRE(layer->keyFrameCount() == 0);
69 
70  WHEN("Add a keyframe")
71  {
72  REQUIRE(layer->addNewKeyFrameAt(1) == true);
73 
74  THEN("keyframe can be found in the layer")
75  {
76  REQUIRE(layer->getMaxKeyFramePosition() == 1);
77  REQUIRE(layer->keyFrameCount() == 1);
78  REQUIRE(layer->getKeyFrameAt(1) != nullptr);
79  }
80  }
81 
82  WHEN("Add 2 keyframes")
83  {
84  REQUIRE(layer->addNewKeyFrameAt(1) == true);
85  REQUIRE(layer->addNewKeyFrameAt(3) == true);
86 
87  THEN("2 keyframes are in the layer")
88  {
89  REQUIRE(layer->getMaxKeyFramePosition() == 3);
90  REQUIRE(layer->getKeyFrameAt(3) != nullptr);
91  REQUIRE(layer->keyFrameCount() == 2);
92  }
93  }
94  delete layer;
95  }
96 
97  GIVEN("A Vector Layer")
98  {
99  Layer* layer = new LayerVector(object);
100 
101  REQUIRE(layer->addNewKeyFrameAt(0) == false); // first key position is 1.
102  REQUIRE(layer->keyFrameCount() == 0);
103 
104  WHEN("Add a keyframe")
105  {
106  REQUIRE(layer->addNewKeyFrameAt(1) == true);
107 
108  THEN("keyframe can be found in the layer")
109  {
110  REQUIRE(layer->getMaxKeyFramePosition() == 1);
111  REQUIRE(layer->keyFrameCount() == 1);
112  REQUIRE(layer->getKeyFrameAt(1) != nullptr);
113  }
114  }
115  delete layer;
116  }
117 
118  GIVEN("A Camera Layer")
119  {
120  Layer* layer = new LayerCamera(object);
121 
122  REQUIRE(layer->addNewKeyFrameAt(0) == false); // first key position is 1.
123  REQUIRE(layer->keyFrameCount() == 0);
124 
125  WHEN("Add a keyframe")
126  {
127  REQUIRE(layer->addNewKeyFrameAt(1) == true);
128 
129  THEN("keyframe can be found in the layer")
130  {
131  REQUIRE(layer->getMaxKeyFramePosition() == 1);
132  REQUIRE(layer->keyFrameCount() == 1);
133  REQUIRE(layer->getKeyFrameAt(1) != nullptr);
134  }
135  }
136  delete layer;
137  }
138  delete object;
139 }
140 
141 TEST_CASE("Test Layer::keyExists()", "[Layer]")
142 {
143  Object* obj = new Object;
144 
145  SECTION("Fresh new Layer")
146  {
147  Layer* layer = obj->addNewBitmapLayer();
148  REQUIRE(layer->keyExists(1) == true); // there is a frame at 1 in default.
149 
150  }
151  SECTION("Key exists at 15")
152  {
153  Layer* layer = obj->addNewBitmapLayer();
154  REQUIRE(layer->addNewKeyFrameAt(15));
155  REQUIRE(layer->keyExists(16) == false);
156  REQUIRE(layer->keyExists(15) == true);
157  REQUIRE(layer->keyExists(14) == false);
158  REQUIRE(layer->keyExists(13) == false);
159  REQUIRE(layer->keyExists(12) == false);
160  }
161  SECTION("Key exists 10 20 30")
162  {
163  Layer* layer = obj->addNewBitmapLayer();
164 
165  REQUIRE(layer->addNewKeyFrameAt(10));
166  REQUIRE(layer->keyExists(10) == true);
167 
168  REQUIRE(layer->addNewKeyFrameAt(20));
169  REQUIRE(layer->keyExists(20) == true);
170 
171  REQUIRE(layer->addNewKeyFrameAt(30));
172  REQUIRE(layer->keyExists(30) == true);
173 
174  // test false case
175  REQUIRE(layer->keyExists(0) == false);
176  REQUIRE(layer->keyExists(21) == false);
177  REQUIRE(layer->keyExists(31) == false);
178  REQUIRE(layer->keyExists(1000) == false);
179  REQUIRE(layer->keyExists(-333) == false);
180  }
181 
182  delete obj;
183 }
184 
185 TEST_CASE("Layer::firstKeyFramePosition()")
186 {
187  Object* obj = new Object;
188 
189  SECTION("At least one key")
190  {
191  Layer* layer = obj->addNewBitmapLayer();
192  REQUIRE(layer->firstKeyFramePosition() == 1);
193 
194  layer->addNewKeyFrameAt(99);
195  REQUIRE(layer->firstKeyFramePosition() != 0);
196 
197  layer->moveKeyFrame(1, 1);
198  REQUIRE(layer->firstKeyFramePosition() != 0); // one keyframe has to exist
199  }
200 
201  delete obj;
202 }
203 
204 TEST_CASE("Layer::getMaxKeyFramePosition()")
205 {
206  Object* obj = new Object;
207 
208  SECTION("Bitmap")
209  {
210  Layer* layer = obj->addNewBitmapLayer();
211 
212  // 1 at beginning.
213  REQUIRE(layer->getMaxKeyFramePosition() == 1);
214 
215  CHECK(layer->addNewKeyFrameAt(3));
216  REQUIRE(layer->getMaxKeyFramePosition() == 3);
217 
218  CHECK(layer->addNewKeyFrameAt(8));
219  REQUIRE(layer->getMaxKeyFramePosition() == 8);
220 
221  CHECK(layer->addNewKeyFrameAt(100));
222  REQUIRE(layer->getMaxKeyFramePosition() == 100);
223 
224  CHECK(layer->addNewKeyFrameAt(80));
225  REQUIRE(layer->getMaxKeyFramePosition() == 100);
226  }
227 
228  delete obj;
229 }
230 
231 
232 TEST_CASE("Layer::removeKeyFrame()")
233 {
234  Object* obj = new Object;
235  SECTION("Bitmap")
236  {
237  Layer* layer = obj->addNewBitmapLayer();
238 
239  // there is always a key at position 1 at beginning
240  CHECK(layer->removeKeyFrame(1));
241  REQUIRE(layer->getMaxKeyFramePosition() == 0);
242 
243  for (int i = 2; i <= 20; ++i)
244  {
245  CHECK(layer->addNewKeyFrameAt(i));
246  }
247 
248  REQUIRE(layer->keyExists(20) == true);
249  layer->removeKeyFrame(20); // after deleting it, the key will no longer exist.
250  REQUIRE(layer->keyExists(20) == false);
251 
252  REQUIRE(layer->keyExists(8) == true);
253  layer->removeKeyFrame(8);
254  REQUIRE(layer->keyExists(8) == false);
255 
256  REQUIRE(layer->keyExists(19) == true);
257  layer->removeKeyFrame(19);
258  REQUIRE(layer->keyExists(19) == false);
259  REQUIRE(layer->getMaxKeyFramePosition() == 18); // also decrease the max position if we delete the last key.
260 
261  layer->removeKeyFrame(18);
262  REQUIRE(layer->getMaxKeyFramePosition() == 17);
263  }
264  delete obj;
265 }
266 
267 TEST_CASE("Layer::getPreviousKeyFramePosition()")
268 {
269  Object* obj = new Object;
270  SECTION("KeyFrame 1")
271  {
272  Layer* layer = obj->addNewBitmapLayer();
273  CHECK(layer->keyFrameCount() == 1);
274 
275  REQUIRE(layer->getPreviousKeyFramePosition(1) == 1);
276  REQUIRE(layer->getPreviousKeyFramePosition(10) == 1);
277  REQUIRE(layer->getPreviousKeyFramePosition(100) == 1);
278  REQUIRE(layer->getPreviousKeyFramePosition(1000) == 1);
279  }
280 
281  SECTION("KeyFrame 1, 2, 8")
282  {
283  Layer* layer = obj->addNewBitmapLayer();
284  layer->addNewKeyFrameAt(2);
285  layer->addNewKeyFrameAt(8);
286  REQUIRE(layer->getPreviousKeyFramePosition(2) == 1);
287  REQUIRE(layer->getPreviousKeyFramePosition(8) == 2);
288  }
289 
290  SECTION("KeyFrame 1, 15")
291  {
292  Layer* layer = obj->addNewBitmapLayer();
293  REQUIRE(layer->getPreviousKeyFramePosition(-5) == 1);
294 
295  layer->addNewKeyFrameAt(15);
296  REQUIRE(layer->getPreviousKeyFramePosition(16) == 15);
297  REQUIRE(layer->getPreviousKeyFramePosition(17) == 15);
298  }
299 
300  SECTION("KeyFrame 1, 10, Add 20 Remove 20")
301  {
302  Layer* layer = obj->addNewBitmapLayer();
303  layer->addNewKeyFrameAt(10);
304  layer->addNewKeyFrameAt(20);
305 
306  REQUIRE(layer->getPreviousKeyFramePosition(21) == 20);
307  layer->removeKeyFrame(20);
308  REQUIRE(layer->getPreviousKeyFramePosition(21) == 10);
309  }
310  delete obj;
311 }
312 
313 TEST_CASE("Layer::getNextKeyFramePosition()")
314 {
315  Object* obj = new Object;
316  SECTION("KeyFrame 1, 5")
317  {
318  Layer* layer = obj->addNewBitmapLayer();
319 
320  REQUIRE(layer->getNextKeyFramePosition(1) == 1);
321  REQUIRE(layer->getNextKeyFramePosition(10) == 1);
322  REQUIRE(layer->getNextKeyFramePosition(100) == 1);
323 
324  CHECK(layer->addNewKeyFrameAt(5));
325  REQUIRE(layer->getNextKeyFramePosition(1) == 5);
326  REQUIRE(layer->getNextKeyFramePosition(2) == 5);
327  }
328  delete obj;
329 }
330 
331 TEST_CASE("Layer::getPreviousFrameNumber()")
332 {
333  Object* obj = new Object;
334  SECTION("KeyFrame 1")
335  {
336  Layer* layer = obj->addNewVectorLayer();
337  REQUIRE(layer->getPreviousFrameNumber(1, true) == -1); // couldn't find previous frame
338 
339  REQUIRE(layer->getPreviousFrameNumber(3, true) == 1);
340  REQUIRE(layer->getPreviousFrameNumber(3, false) == 2);
341  }
342  delete obj;
343 }
344 
345 TEST_CASE("Layer::moveKeyFrame(int position, int offset)")
346 {
347  Object* obj = new Object;
348  SECTION("move one to the left")
349  {
350  Layer* layer = obj->addNewBitmapLayer();
351  layer->addNewKeyFrameAt(1);
352  layer->addNewKeyFrameAt(2);
353  layer->addNewKeyFrameAt(3);
354 
355  layer->setFrameSelected(2, true);
356  layer->setFrameSelected(3, true);
357 
358  KeyFrame* frame1 = layer->getKeyFrameAt(2);
359  KeyFrame* frame2 = layer->getKeyFrameAt(3);
360 
361  layer->moveKeyFrame(2, 1);
362 
363  // Confirm that both frames are still selected.
364  REQUIRE(layer->getKeyFrameAt(2)->isSelected());
365  REQUIRE(layer->getKeyFrameAt(3)->isSelected());
366 
367  // Verify that poiners has been swapped
368  REQUIRE(frame1 == layer->getKeyFrameAt(3));
369  REQUIRE(frame2 == layer->getKeyFrameAt(2));
370  }
371 
372  SECTION("move non selected frame")
373  {
374  Layer* layer = obj->addNewBitmapLayer();
375  layer->addNewKeyFrameAt(1);
376  layer->addNewKeyFrameAt(2);
377  layer->addNewKeyFrameAt(3);
378 
379  layer->setFrameSelected(2, false);
380  layer->setFrameSelected(3, true);
381 
382  layer->moveKeyFrame(2, 1);
383 
384  // Confirm that both frames are still selected.
385  REQUIRE(layer->getKeyFrameAt(2)->isSelected());
386  REQUIRE_FALSE(layer->getKeyFrameAt(3)->isSelected());
387  }
388 
389  SECTION("move non selected frame across multiple selected frames")
390  {
391  Layer* layer = obj->addNewBitmapLayer();
392  layer->addNewKeyFrameAt(4);
393  layer->addNewKeyFrameAt(5);
394  layer->addNewKeyFrameAt(6);
395  layer->addNewKeyFrameAt(7);
396  layer->addNewKeyFrameAt(8);
397 
398  layer->setFrameSelected(4, false);
399  layer->setFrameSelected(5, true);
400  layer->setFrameSelected(6, true);
401  layer->setFrameSelected(7, true);
402  layer->setFrameSelected(8, true);
403 
404  layer->moveKeyFrame(4, 1);
405  layer->moveKeyFrame(5, 1);
406  layer->moveKeyFrame(6, 1);
407  layer->moveKeyFrame(7, 1);
408  layer->moveKeyFrame(8, 1);
409 
410  // Confirm that both frames are still selected.
411  REQUIRE(layer->getKeyFrameAt(4)->isSelected());
412  REQUIRE(layer->getKeyFrameAt(5)->isSelected());
413  REQUIRE(layer->getKeyFrameAt(6)->isSelected());
414  REQUIRE(layer->getKeyFrameAt(7)->isSelected());
415  REQUIRE_FALSE(layer->getKeyFrameAt(9)->isSelected());
416  }
417 
418  SECTION("move selected frame across multiple not selected frames")
419  {
420  Layer* layer = obj->addNewBitmapLayer();
421  layer->addNewKeyFrameAt(4);
422  layer->addNewKeyFrameAt(5);
423  layer->addNewKeyFrameAt(6);
424  layer->addNewKeyFrameAt(7);
425  layer->addNewKeyFrameAt(8);
426 
427  layer->setFrameSelected(4, false);
428  layer->setFrameSelected(5, false);
429  layer->setFrameSelected(6, true);
430  layer->setFrameSelected(7, false);
431  layer->setFrameSelected(8, false);
432 
433  layer->moveKeyFrame(6, 1);
434  layer->moveKeyFrame(7, 1);
435  layer->moveKeyFrame(8, -1);
436  layer->moveKeyFrame(7, -1);
437  layer->moveKeyFrame(6, -1);
438  layer->moveKeyFrame(5, -1);
439  layer->moveKeyFrame(4, -1);
440 
441  // Confirm that both frames are still selected.
442  REQUIRE(layer->getKeyFrameAt(3)->isSelected());
443  REQUIRE_FALSE(layer->getKeyFrameAt(5)->isSelected());
444  REQUIRE_FALSE(layer->getKeyFrameAt(6)->isSelected());
445  REQUIRE_FALSE(layer->getKeyFrameAt(7)->isSelected());
446  REQUIRE_FALSE(layer->getKeyFrameAt(8)->isSelected());
447  }
448 
449  delete obj;
450 }
451 
452 TEST_CASE("Layer::setExposureForSelectedFrames")
453 {
454  Object* obj = new Object;
455  SECTION("Add exposure: linear")
456  {
457  Layer* layer = obj->addNewBitmapLayer();
458  layer->addNewKeyFrameAt(1);
459  layer->addNewKeyFrameAt(2);
460  layer->addNewKeyFrameAt(3);
461 
462  layer->addNewKeyFrameAt(5);
463  layer->addNewKeyFrameAt(6);
464 
465  layer->setFrameSelected(1, true);
466  layer->setFrameSelected(2, true);
467  layer->setFrameSelected(3, true);
468 
470 
471  REQUIRE(layer->selectedKeyFrameCount() == 3);
472  REQUIRE(layer->isFrameSelected(1));
473  REQUIRE(layer->isFrameSelected(3));
474  REQUIRE(layer->isFrameSelected(5));
475 
476  // Check that the frames that was in front of the last element in the selection
477  // has also been moved
478  REQUIRE(layer->keyExists(8));
479  REQUIRE(layer->keyExists(9));
480  }
481 
482  SECTION("Add exposure: irregular spacing")
483  {
484  Layer* layer = obj->addNewBitmapLayer();
485  layer->addNewKeyFrameAt(15);
486  layer->addNewKeyFrameAt(18);
487  layer->addNewKeyFrameAt(20);
488 
489  layer->addNewKeyFrameAt(21);
490  layer->addNewKeyFrameAt(24);
491 
492  layer->setFrameSelected(24, true);
493  layer->setFrameSelected(21, true);
494  layer->setFrameSelected(18, true);
495  layer->setFrameSelected(15, true);
496  layer->setFrameSelected(20, true);
497 
499 
500  REQUIRE(layer->selectedKeyFrameCount() == 5);
501  REQUIRE(layer->isFrameSelected(15));
502  REQUIRE(layer->isFrameSelected(20));
503  REQUIRE(layer->isFrameSelected(24));
504  REQUIRE(layer->isFrameSelected(27));
505  REQUIRE(layer->isFrameSelected(32));
506 
507  REQUIRE(layer->selectedKeyFramesByLast().at(0) == 24);
508  REQUIRE(layer->selectedKeyFramesByLast().at(1) == 15);
509  REQUIRE(layer->selectedKeyFramesByLast().at(2) == 20);
510  REQUIRE(layer->selectedKeyFramesByLast().at(3) == 27);
511  REQUIRE(layer->selectedKeyFramesByLast().at(4) == 32);
512  }
513 
514  SECTION("Add exposure: frames in between")
515  {
516  Layer* layer = obj->addNewBitmapLayer();
517  layer->addNewKeyFrameAt(19);
518  layer->addNewKeyFrameAt(22);
519  layer->addNewKeyFrameAt(24);
520  layer->addNewKeyFrameAt(27);
521  layer->addNewKeyFrameAt(30);
522 
523  layer->setFrameSelected(19, true);
524  layer->setFrameSelected(24, true);
525 
527 
528  REQUIRE(layer->selectedKeyFrameCount() == 2);
529  REQUIRE(layer->isFrameSelected(19));
530  REQUIRE(layer->isFrameSelected(26));
531 
532  REQUIRE(layer->selectedKeyFramesByLast().at(0) == 26);
533  REQUIRE(layer->selectedKeyFramesByLast().at(1) == 19);
534 
535  REQUIRE(layer->keyExists(31));
536  REQUIRE(layer->keyExists(34));
537  }
538 
539  SECTION("Subtract exposure: linear")
540  {
541  Layer* layer = obj->addNewBitmapLayer();
542  layer->addNewKeyFrameAt(6);
543  layer->addNewKeyFrameAt(9);
544  layer->addNewKeyFrameAt(22);
545  layer->addNewKeyFrameAt(23);
546 
547  layer->setFrameSelected(6, true);
548  layer->setFrameSelected(9, true);
549  layer->setFrameSelected(22, true);
550  layer->setFrameSelected(23, true);
551 
552  layer->setExposureForSelectedFrames(-1);
553 
554  REQUIRE(layer->selectedKeyFrameCount() == 4);
555  REQUIRE(layer->isFrameSelected(6));
556  REQUIRE(layer->isFrameSelected(8));
557  REQUIRE(layer->isFrameSelected(20));
558  REQUIRE(layer->isFrameSelected(21));
559  }
560 
561 
562  SECTION("Subtract exposure: frames inbetween")
563  {
564  Layer* layer = obj->addNewBitmapLayer();
565  layer->addNewKeyFrameAt(6);
566  layer->addNewKeyFrameAt(9);
567  layer->addNewKeyFrameAt(22);
568  layer->addNewKeyFrameAt(23);
569 
570  layer->setFrameSelected(6, true);
571  layer->setFrameSelected(9, false);
572  layer->setFrameSelected(22, false);
573  layer->setFrameSelected(23, true);
574 
575  layer->setExposureForSelectedFrames(-1);
576 
577  REQUIRE(layer->selectedKeyFrameCount() == 2);
578  REQUIRE(layer->isFrameSelected(6));
579  REQUIRE(layer->isFrameSelected(22));
580 
581  REQUIRE(layer->keyExists(8));
582  REQUIRE(layer->keyExists(21));
583  }
584  delete obj;
585 }
586 
587 TEST_CASE("layer::reverseOrderOfSelection()") {
588  Object* obj = new Object;
589 
590  SECTION("No frames selected") {
591  Layer* layer = obj->addNewBitmapLayer();
592  layer->addNewKeyFrameAt(6);
593  layer->addNewKeyFrameAt(9);
594  layer->addNewKeyFrameAt(13);
595  layer->addNewKeyFrameAt(15);
596  layer->addNewKeyFrameAt(18);
597 
598  REQUIRE(layer->reverseOrderOfSelection() == false);
599  }
600 
603  SECTION("Reverse selection") {
604  LayerBitmap* layer = obj->addNewBitmapLayer();
605 
606  BitmapImage* image1 = new BitmapImage(QRect(0,0,10,10), QColor(255,255,0));
607  BitmapImage* image2 = new BitmapImage(QRect(0,0,10,10), QColor(100,255,0));
608  BitmapImage* image3 = new BitmapImage(QRect(0,0,10,10), QColor(255,0,0));
609  BitmapImage* image4 = new BitmapImage(QRect(0,0,10,10), QColor(255,255,255));
610  layer->addKeyFrame(6, image1);
611  layer->addKeyFrame(9, image2);
612  layer->addKeyFrame(13, image3);
613  layer->addKeyFrame(15, image4);
614 
615  layer->setFrameSelected(6, true);
616  layer->setFrameSelected(9, true);
617  layer->setFrameSelected(13, true);
618  layer->setFrameSelected(15, true);
619 
620  CHECK(layer->reverseOrderOfSelection());
621 
622 // // Check that the content has been swapped properly
623  bool test1 = layer->getBitmapImageAtFrame(15)->image() == image1->image();
624  bool test2 = layer->getBitmapImageAtFrame(13)->image() == image2->image();
625  bool test3 = layer->getBitmapImageAtFrame(9)->image() == image3->image();
626  bool test4 = layer->getBitmapImageAtFrame(6)->image() == image4->image();
627 
628  bool test5 = layer->getBitmapImageAtFrame(6)->image() == image1->image();
629  bool test6 = layer->getBitmapImageAtFrame(9)->image() == image2->image();
630  bool test7 = layer->getBitmapImageAtFrame(13)->image() == image3->image();
631  bool test8 = layer->getBitmapImageAtFrame(15)->image() == image4->image();
632 
633  REQUIRE(test1);
634  REQUIRE(test2);
635  REQUIRE(test3);
636  REQUIRE(test4);
637 
638  REQUIRE_FALSE(test5);
639  REQUIRE_FALSE(test6);
640  REQUIRE_FALSE(test7);
641  REQUIRE_FALSE(test8);
642  }
643  delete obj;
644 }
645 
646 TEST_CASE("layer::insertExposureAt(int position)") {
647  Object* obj = new Object;
648 
649  SECTION("Add exposure to frame 3") {
650  Layer* layer = obj->addNewBitmapLayer();
651  layer->addNewKeyFrameAt(3);
652  layer->addNewKeyFrameAt(4);
653  layer->addNewKeyFrameAt(5);
654 
655  layer->insertExposureAt(3);
656 
657  // Check that frames has been moved
658  REQUIRE(layer->keyExists(3));
659  REQUIRE(layer->keyExists(5));
660  REQUIRE(layer->keyExists(6));
661 
662  // Check that newly exposed frame position doesn't contain a frame
663  REQUIRE(layer->keyExists(4) == false);
664  }
665 
666  SECTION("invalid frame") {
667  Layer* layer = obj->addNewBitmapLayer();
668  layer->addNewKeyFrameAt(3);
669  layer->addNewKeyFrameAt(4);
670  layer->addNewKeyFrameAt(5);
671 
672  REQUIRE(layer->insertExposureAt(-1) == false);
673  }
674 
675 
676  SECTION("Insert next to frame") {
677  Layer* layer = obj->addNewBitmapLayer();
678  layer->addNewKeyFrameAt(3);
679  layer->addNewKeyFrameAt(4);
680 
681  REQUIRE(layer->insertExposureAt(2) == false);
682  REQUIRE(layer->keyExists(3));
683  REQUIRE(layer->keyExists(4));
684  }
685  delete obj;
686 }
687 
688 
689 //TEST_CASE("Layer::")
bool insertExposureAt(int position)
Will insert an empty frame (exposure) after the given position.
Definition: layer.cpp:205
const T & at(int i) const const
void setExposureForSelectedFrames(int offset)
Add or subtract exposure from selected frames.
Definition: layer.cpp:520
Definition: layer.h:38
bool reverseOrderOfSelection()
Reverse order of selected frames.
Definition: layer.cpp:610
Definition: object.h:41
QList< int > selectedKeyFramesByLast() const
Get selected keyframe positions based on the order they were selected.
Definition: layer.h:74