File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 44#include < scratchcpp/variable.h>
55#include < scratchcpp/list.h>
66#include < scratchcpp/block.h>
7+ #include < scratchcpp/iengine.h>
78
89#include " target_p.h"
910
@@ -209,6 +210,11 @@ void Target::setCostumeIndex(int newCostumeIndex)
209210{
210211 if (newCostumeIndex >= 0 && newCostumeIndex < costumes ().size ())
211212 impl->costumeIndex = newCostumeIndex;
213+
214+ if (isStage ()) {
215+ if (impl->engine )
216+ impl->engine ->breakFrame ();
217+ }
212218}
213219
214220/* ! Returns the currently set costume. */
Original file line number Diff line number Diff line change @@ -51,7 +51,9 @@ add_executable(
5151target_link_libraries (
5252 stage_test
5353 GTest::gtest_main
54+ GTest::gmock_main
5455 scratchcpp
56+ scratchcpp_mocks
5557)
5658
5759gtest_discover_tests(stage_test)
Original file line number Diff line number Diff line change 11#include < scratchcpp/stage.h>
2+ #include < scratchcpp/costume.h>
3+ #include < enginemock.h>
24
35#include " ../common.h"
46
@@ -10,6 +12,25 @@ TEST(StageTest, IsStage)
1012 ASSERT_TRUE (stage.isStage ());
1113}
1214
15+ TEST (SpriteTest, CostumeIndex)
16+ {
17+ Stage stage;
18+ EngineMock engine;
19+ stage.setEngine (&engine);
20+ EXPECT_CALL (engine, breakFrame ()).Times (2 );
21+
22+ auto c1 = std::make_shared<Costume>(" " , " " , " " );
23+ auto c2 = std::make_shared<Costume>(" " , " " , " " );
24+ stage.addCostume (c1);
25+ stage.addCostume (c2);
26+
27+ stage.setCostumeIndex (0 );
28+ ASSERT_EQ (stage.costumeIndex (), 0 );
29+
30+ stage.setCostumeIndex (1 );
31+ ASSERT_EQ (stage.costumeIndex (), 1 );
32+ }
33+
1334TEST (StageTest, Tempo)
1435{
1536 Stage stage;
You can’t perform that action at this time.
0 commit comments