Skip to content

Commit 9a2c49e

Browse files
committed
Add stage interface getter
1 parent 1b3de4b commit 9a2c49e

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

include/scratchcpp/stage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class LIBSCRATCHCPP_EXPORT Stage : public Target
2727
Stage(const Stage &) = delete;
2828

2929
void setInterface(IStageHandler *newInterface);
30+
IStageHandler *getInterface() const; // NOTE: This can't be called interface because of... Microsoft... (it wouldn't compile on Windows)
3031

3132
bool isStage() const override;
3233

src/scratch/stage.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ void Stage::setInterface(IStageHandler *newInterface)
2424
impl->iface->init(this);
2525
}
2626

27+
/*! Returns the stage interface. */
28+
IStageHandler *Stage::getInterface() const
29+
{
30+
return impl->iface;
31+
}
32+
2733
/*! Returns true. */
2834
bool Stage::isStage() const
2935
{

test/scratch_classes/stage_test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <scratchcpp/costume.h>
33
#include <enginemock.h>
44
#include <graphicseffectmock.h>
5+
#include <stagehandlermock.h>
56

67
#include "../common.h"
78

@@ -13,6 +14,17 @@ TEST(StageTest, IsStage)
1314
ASSERT_TRUE(stage.isStage());
1415
}
1516

17+
TEST(SpriteTest, Interface)
18+
{
19+
Stage stage;
20+
ASSERT_EQ(stage.getInterface(), nullptr);
21+
22+
StageHandlerMock handler;
23+
EXPECT_CALL(handler, init);
24+
stage.setInterface(&handler);
25+
ASSERT_EQ(stage.getInterface(), &handler);
26+
}
27+
1628
TEST(SpriteTest, CostumeIndex)
1729
{
1830
Stage stage;

0 commit comments

Comments
 (0)