File tree Expand file tree Collapse file tree 8 files changed +58
-0
lines changed Expand file tree Collapse file tree 8 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ class LIBSCRATCHCPP_EXPORT Drawable
1717 Drawable ();
1818 Drawable (const Drawable &) = delete ;
1919
20+ /* ! Returns true if this Drawable is a Target. */
21+ virtual bool isTarget () const { return false ; }
22+
23+ /* ! Returns true if this Drawable is a TextBubble. */
24+ virtual bool isTextBubble () const { return false ; }
25+
2026 int layerOrder () const ;
2127 virtual void setLayerOrder (int newLayerOrder);
2228
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ class LIBSCRATCHCPP_EXPORT Target : public Drawable
3131 Target (const Target &) = delete ;
3232 virtual ~Target () { }
3333
34+ bool isTarget () const override final ;
35+
3436 /* ! Returns true if this Target is the stage. */
3537 virtual bool isStage () const { return false ; }
3638
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ class TextBubble : public Drawable
2323 TextBubble ();
2424 TextBubble (const TextBubble &) = delete ;
2525
26+ bool isTextBubble () const override final ;
27+
2628 Type type () const ;
2729 virtual void setType (Type type);
2830 sigslot::signal<Type> &typeChanged () const ;
Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ Target::Target() :
2929{
3030}
3131
32+ /* ! Returns true. */
33+ bool Target::isTarget () const
34+ {
35+ return true ;
36+ }
37+
3238/* ! Returns the name of the target. */
3339const std::string &Target::name () const
3440{
Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ TextBubble::TextBubble() :
1313{
1414}
1515
16+ /* ! Returns true. */
17+ bool TextBubble::isTextBubble () const
18+ {
19+ return true ;
20+ }
21+
1622/* ! Returns the type of the TextBubble (say or think). */
1723TextBubble::Type TextBubble::type () const
1824{
Original file line number Diff line number Diff line change 44
55using namespace libscratchcpp ;
66
7+ TEST (DrawableTest, IsTarget)
8+ {
9+ Drawable drawable;
10+ ASSERT_FALSE (drawable.isTarget ());
11+ }
12+
13+ TEST (DrawableTest, IsTextBubble)
14+ {
15+ Drawable drawable;
16+ ASSERT_FALSE (drawable.isTextBubble ());
17+ }
18+
719TEST (DrawableTest, LayerOrder)
820{
921 Drawable drawable;
Original file line number Diff line number Diff line change @@ -25,6 +25,18 @@ using ::testing::WithArgs;
2525using ::testing::Invoke;
2626using ::testing::_;
2727
28+ TEST (TargetTest, IsTarget)
29+ {
30+ Target target;
31+ ASSERT_TRUE (target.isTarget ());
32+ }
33+
34+ TEST (TargetTest, IsTextBubble)
35+ {
36+ Target target;
37+ ASSERT_FALSE (target.isTextBubble ());
38+ }
39+
2840TEST (TargetTest, IsStage)
2941{
3042 Target target;
Original file line number Diff line number Diff line change 44
55using namespace libscratchcpp ;
66
7+ TEST (TextBubbleTest, IsTarget)
8+ {
9+ TextBubble bubble;
10+ ASSERT_FALSE (bubble.isTarget ());
11+ }
12+
13+ TEST (TextBubbleTest, IsTextBubble)
14+ {
15+ TextBubble bubble;
16+ ASSERT_TRUE (bubble.isTextBubble ());
17+ }
18+
719TEST (TextBubbleTest, BubbleType)
820{
921 TextBubble bubble;
You can’t perform that action at this time.
0 commit comments