|
7 | 7 | #include <scratchcpp/thread.h> |
8 | 8 | #include <scratchcpp/executablecode.h> |
9 | 9 | #include <scratchcpp/executioncontext.h> |
| 10 | +#include <scratchcpp/list.h> |
10 | 11 | #include <scratchcpp/scratchconfiguration.h> |
11 | 12 | #include <enginemock.h> |
12 | 13 | #include <graphicseffectmock.h> |
@@ -582,3 +583,38 @@ TEST_F(LooksBlocksTest, SetSizeTo) |
582 | 583 | builder.run(); |
583 | 584 | } |
584 | 585 | } |
| 586 | + |
| 587 | +TEST_F(LooksBlocksTest, Size) |
| 588 | +{ |
| 589 | + { |
| 590 | + auto sprite = std::make_shared<Sprite>(); |
| 591 | + ScriptBuilder builder(m_extension.get(), m_engine, sprite); |
| 592 | + builder.addBlock("looks_size"); |
| 593 | + builder.captureBlockReturnValue(); |
| 594 | + builder.build(); |
| 595 | + |
| 596 | + sprite->setEngine(nullptr); |
| 597 | + sprite->setSize(45.62); |
| 598 | + builder.run(); |
| 599 | + |
| 600 | + List *list = builder.capturedValues(); |
| 601 | + ASSERT_EQ(list->size(), 1); |
| 602 | + ASSERT_EQ(Value(list->data()[0]).toDouble(), 45.62); |
| 603 | + } |
| 604 | + |
| 605 | + m_engine->clear(); |
| 606 | + |
| 607 | + { |
| 608 | + auto stage = std::make_shared<Stage>(); |
| 609 | + ScriptBuilder builder(m_extension.get(), m_engine, stage); |
| 610 | + builder.addBlock("looks_size"); |
| 611 | + builder.captureBlockReturnValue(); |
| 612 | + |
| 613 | + builder.build(); |
| 614 | + builder.run(); |
| 615 | + |
| 616 | + List *list = builder.capturedValues(); |
| 617 | + ASSERT_EQ(list->size(), 1); |
| 618 | + ASSERT_EQ(Value(list->data()[0]).toDouble(), 100); |
| 619 | + } |
| 620 | +} |
0 commit comments