File tree Expand file tree Collapse file tree 6 files changed +37
-0
lines changed
Expand file tree Collapse file tree 6 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class LIBSCRATCHCPP_EXPORT Sprite
2929 Sprite (const Sprite &) = delete ;
3030
3131 void setInterface (ISpriteHandler *newInterface);
32+ ISpriteHandler *getInterface () const ; // NOTE: This can't be called interface because of... Microsoft... (it wouldn't compile on Windows)
3233
3334 std::shared_ptr<Sprite> clone ();
3435 void deleteClone ();
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ void Sprite::setInterface(ISpriteHandler *newInterface)
2929 impl->iface ->init (this );
3030}
3131
32+ /* ! Returns the sprite interface. */
33+ ISpriteHandler *Sprite::getInterface () const
34+ {
35+ return impl->iface ;
36+ }
37+
3238/* ! Creates a clone of the sprite. */
3339std::shared_ptr<Sprite> Sprite::clone ()
3440{
Original file line number Diff line number Diff 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. */
2834bool Stage::isStage () const
2935{
Original file line number Diff line number Diff line change @@ -23,6 +23,17 @@ TEST(SpriteTest, IsStage)
2323 ASSERT_FALSE (sprite.isStage ());
2424}
2525
26+ TEST (SpriteTest, Interface)
27+ {
28+ Sprite sprite;
29+ ASSERT_EQ (sprite.getInterface (), nullptr );
30+
31+ SpriteHandlerMock handler;
32+ EXPECT_CALL (handler, init);
33+ sprite.setInterface (&handler);
34+ ASSERT_EQ (sprite.getInterface (), &handler);
35+ }
36+
2637TEST (SpriteTest, Visible)
2738{
2839 Sprite sprite;
Original file line number Diff line number Diff line change 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+
1628TEST (SpriteTest, CostumeIndex)
1729{
1830 Stage stage;
You can’t perform that action at this time.
0 commit comments