66#include < stagemodel.h>
77#include < spritemodel.h>
88#include < scenemousearea.h>
9+ #include < penlayer.h>
910#include < scratchcpp/stage.h>
1011#include < scratchcpp/sprite.h>
1112#include < scratchcpp/costume.h>
1213#include < scratchcpp/rect.h>
1314#include < scratchcpp/value.h>
1415#include < enginemock.h>
1516#include < renderedtargetmock.h>
17+ #include < penlayermock.h>
1618
1719#include " ../common.h"
1820
@@ -1023,6 +1025,9 @@ TEST_F(RenderedTargetTest, TouchingColor)
10231025 parent.setWidth (480 );
10241026 parent.setHeight (360 );
10251027
1028+ PenLayerMock penLayer;
1029+ PenLayer::addPenLayer (&engine, &penLayer);
1030+
10261031 RenderedTarget target (&parent);
10271032 target.setEngine (&engine);
10281033 target.setSpriteModel (&model);
@@ -1049,7 +1054,12 @@ TEST_F(RenderedTargetTest, TouchingColor)
10491054 target.updateCostume (costume.get ());
10501055 target.beforeRedraw ();
10511056
1057+ Rect penBounds (5 , 1 , 6 , -5 );
10521058 EXPECT_CALL (engine, targets ()).WillRepeatedly (ReturnRef (targets));
1059+ EXPECT_CALL (stageTarget, stageModel ()).WillRepeatedly (Return (&stageModel));
1060+ EXPECT_CALL (target1, stageModel ()).WillRepeatedly (Return (nullptr ));
1061+ EXPECT_CALL (target2, stageModel ()).WillRepeatedly (Return (nullptr ));
1062+ EXPECT_CALL (penLayer, getBounds ()).WillRepeatedly (ReturnRef (penBounds));
10531063
10541064 static const Value color1 = 4286611711 ; // "purple"
10551065 static const Value color2 = 596083443 ; // close to color1 and transparent
@@ -1071,6 +1081,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
10711081 EXPECT_CALL (target1, colorAtScratchPoint (2 , -1 )).WillOnce (Return (color3Int));
10721082 EXPECT_CALL (target2, colorAtScratchPoint (3 , -1 )).WillOnce (Return (color4.toInt ()));
10731083 EXPECT_CALL (target1, colorAtScratchPoint (3 , -1 )).WillOnce (Return (color4.toInt ()));
1084+ EXPECT_CALL (penLayer, colorAtScratchPoint (3 , -1 )).WillOnce (Return (color4.toInt ()));
10741085 EXPECT_CALL (stageTarget, colorAtScratchPoint (3 , -1 )).WillOnce (Return (color4.toInt ()));
10751086 ASSERT_FALSE (target.touchingColor (color1));
10761087
@@ -1134,6 +1145,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
11341145 EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 , -6 , 2 , -8 )));
11351146 EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
11361147 EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1148+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
11371149 EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
11381150 ASSERT_FALSE (target.touchingColor (color3));
11391151
@@ -1145,6 +1157,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
11451157 EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 - 300 , -6.5 + 200 , 1.8 - 300 , -8 + 200 )));
11461158 EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
11471159 EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1160+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
11481161 EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
11491162 ASSERT_FALSE (target.touchingColor (color1));
11501163
@@ -1156,6 +1169,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
11561169 EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 + 300 , -6.5 + 200 , 1.8 + 300 , -8 + 200 )));
11571170 EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
11581171 EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1172+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
11591173 EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
11601174 ASSERT_FALSE (target.touchingColor (color1));
11611175
@@ -1167,6 +1181,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
11671181 EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 + 300 , -6.5 - 200 , 1.8 + 300 , -8 - 200 )));
11681182 EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
11691183 EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1184+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
11701185 EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
11711186 ASSERT_FALSE (target.touchingColor (color1));
11721187
@@ -1178,6 +1193,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
11781193 EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 - 300 , -6.5 - 200 , 1.8 - 300 , -8 - 200 )));
11791194 EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
11801195 EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1196+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
11811197 EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
11821198 ASSERT_FALSE (target.touchingColor (color1));
11831199
0 commit comments