File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ class LIBSCRATCHCPP_EXPORT Sprite : public Target
5959 void setRotationStyle (const std::string &newRotationStyle);
6060 void setRotationStyle (const char *newRotationStyle);
6161
62+ protected:
63+ Target *dataSource () const override ;
64+
6265 private:
6366 spimpl::unique_impl_ptr<SpritePrivate> impl;
6467};
Original file line number Diff line number Diff line change @@ -255,3 +255,8 @@ void Sprite::setRotationStyle(const char *newRotationStyle)
255255{
256256 setRotationStyle (std::string (newRotationStyle));
257257}
258+
259+ Target *Sprite::dataSource () const
260+ {
261+ return impl->cloneRoot ;
262+ }
Original file line number Diff line number Diff line change 11#include < scratchcpp/sprite.h>
22#include < scratchcpp/variable.h>
33#include < scratchcpp/list.h>
4+ #include < scratchcpp/costume.h>
45#include < enginemock.h>
56
67#include " ../common.h"
@@ -32,6 +33,8 @@ TEST(SpriteTest, Clone)
3233 auto var2 = std::make_shared<Variable>(" b" , " var2" , " world" );
3334 sprite.addVariable (var1);
3435 sprite.addVariable (var2);
36+ auto c1 = std::make_shared<Costume>(" costume1" , " " , " svg" );
37+ sprite.addCostume (c1);
3538
3639 auto list1 = std::make_shared<List>(" c" , " list1" );
3740 list1->push_back (" item1" );
@@ -173,6 +176,11 @@ TEST(SpriteTest, Clone)
173176 ASSERT_TRUE (clone3->allChildren ().empty ());
174177
175178 ASSERT_TRUE (clone4->allChildren ().empty ());
179+
180+ ASSERT_EQ (clone2->costumes (), sprite.costumes ());
181+ auto c2 = std::make_shared<Costume>(" costume2" , " " , " png" );
182+ clone2->addCostume (c2);
183+ ASSERT_EQ (clone2->costumes (), sprite.costumes ());
176184}
177185
178186TEST (SpriteTest, X)
You can’t perform that action at this time.
0 commit comments