|
1 | 1 | #include <scratchcpp/broadcast.h> |
2 | 2 | #include <scratchcpp/block.h> |
3 | 3 | #include <scratchcpp/project.h> |
| 4 | +#include <scratchcpp/sprite.h> |
| 5 | +#include <scratchcpp/stage.h> |
4 | 6 | #include <scratchcpp/variable.h> |
5 | 7 | #include <scratchcpp/list.h> |
6 | 8 | #include <timermock.h> |
@@ -369,6 +371,33 @@ TEST(EngineTest, Targets) |
369 | 371 | ASSERT_EQ(block2->engine(), &engine); |
370 | 372 | } |
371 | 373 |
|
| 374 | +TEST(EngineTest, Stage) |
| 375 | +{ |
| 376 | + Engine engine; |
| 377 | + ASSERT_EQ(engine.stage(), nullptr); |
| 378 | + |
| 379 | + auto t1 = std::make_shared<Sprite>(); |
| 380 | + t1->setName("Sprite1"); |
| 381 | + engine.setTargets({ t1 }); |
| 382 | + ASSERT_EQ(engine.stage(), nullptr); |
| 383 | + |
| 384 | + auto t2 = std::make_shared<Stage>(); |
| 385 | + t2->setName("Stage"); |
| 386 | + engine.setTargets({ t1, t2 }); |
| 387 | + ASSERT_EQ(engine.stage(), t2.get()); |
| 388 | + |
| 389 | + auto t3 = std::make_shared<Sprite>(); |
| 390 | + t3->setName("Sprite2"); |
| 391 | + engine.setTargets({ t1, t2, t3 }); |
| 392 | + ASSERT_EQ(engine.stage(), t2.get()); |
| 393 | + |
| 394 | + engine.setTargets({ t2, t3 }); |
| 395 | + ASSERT_EQ(engine.stage(), t2.get()); |
| 396 | + |
| 397 | + engine.setTargets({ t1, t3 }); |
| 398 | + ASSERT_EQ(engine.stage(), nullptr); |
| 399 | +} |
| 400 | + |
372 | 401 | TEST(EngineTest, VariableOwner) |
373 | 402 | { |
374 | 403 | Engine engine; |
|
0 commit comments