6
6
#include < stagemodel.h>
7
7
#include < spritemodel.h>
8
8
#include < scenemousearea.h>
9
+ #include < penlayer.h>
9
10
#include < scratchcpp/stage.h>
10
11
#include < scratchcpp/sprite.h>
11
12
#include < scratchcpp/costume.h>
12
13
#include < scratchcpp/rect.h>
13
14
#include < scratchcpp/value.h>
14
15
#include < enginemock.h>
15
16
#include < renderedtargetmock.h>
17
+ #include < penlayermock.h>
16
18
17
19
#include " ../common.h"
18
20
@@ -1023,6 +1025,9 @@ TEST_F(RenderedTargetTest, TouchingColor)
1023
1025
parent.setWidth (480 );
1024
1026
parent.setHeight (360 );
1025
1027
1028
+ PenLayerMock penLayer;
1029
+ PenLayer::addPenLayer (&engine, &penLayer);
1030
+
1026
1031
RenderedTarget target (&parent);
1027
1032
target.setEngine (&engine);
1028
1033
target.setSpriteModel (&model);
@@ -1049,7 +1054,12 @@ TEST_F(RenderedTargetTest, TouchingColor)
1049
1054
target.updateCostume (costume.get ());
1050
1055
target.beforeRedraw ();
1051
1056
1057
+ Rect penBounds (5 , 1 , 6 , -5 );
1052
1058
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));
1053
1063
1054
1064
static const Value color1 = 4286611711 ; // "purple"
1055
1065
static const Value color2 = 596083443 ; // close to color1 and transparent
@@ -1071,6 +1081,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
1071
1081
EXPECT_CALL (target1, colorAtScratchPoint (2 , -1 )).WillOnce (Return (color3Int));
1072
1082
EXPECT_CALL (target2, colorAtScratchPoint (3 , -1 )).WillOnce (Return (color4.toInt ()));
1073
1083
EXPECT_CALL (target1, colorAtScratchPoint (3 , -1 )).WillOnce (Return (color4.toInt ()));
1084
+ EXPECT_CALL (penLayer, colorAtScratchPoint (3 , -1 )).WillOnce (Return (color4.toInt ()));
1074
1085
EXPECT_CALL (stageTarget, colorAtScratchPoint (3 , -1 )).WillOnce (Return (color4.toInt ()));
1075
1086
ASSERT_FALSE (target.touchingColor (color1));
1076
1087
@@ -1134,6 +1145,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
1134
1145
EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 , -6 , 2 , -8 )));
1135
1146
EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
1136
1147
EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1148
+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
1137
1149
EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
1138
1150
ASSERT_FALSE (target.touchingColor (color3));
1139
1151
@@ -1145,6 +1157,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
1145
1157
EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 - 300 , -6.5 + 200 , 1.8 - 300 , -8 + 200 )));
1146
1158
EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
1147
1159
EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1160
+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
1148
1161
EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
1149
1162
ASSERT_FALSE (target.touchingColor (color1));
1150
1163
@@ -1156,6 +1169,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
1156
1169
EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 + 300 , -6.5 + 200 , 1.8 + 300 , -8 + 200 )));
1157
1170
EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
1158
1171
EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1172
+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
1159
1173
EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
1160
1174
ASSERT_FALSE (target.touchingColor (color1));
1161
1175
@@ -1167,6 +1181,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
1167
1181
EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 + 300 , -6.5 - 200 , 1.8 + 300 , -8 - 200 )));
1168
1182
EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
1169
1183
EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1184
+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
1170
1185
EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
1171
1186
ASSERT_FALSE (target.touchingColor (color1));
1172
1187
@@ -1178,6 +1193,7 @@ TEST_F(RenderedTargetTest, TouchingColor)
1178
1193
EXPECT_CALL (target2, getFastBounds ()).WillOnce (Return (Rect (-5 - 300 , -6.5 - 200 , 1.8 - 300 , -8 - 200 )));
1179
1194
EXPECT_CALL (target2, colorAtScratchPoint).Times (0 );
1180
1195
EXPECT_CALL (target1, colorAtScratchPoint).Times (0 );
1196
+ EXPECT_CALL (penLayer, colorAtScratchPoint).Times (0 );
1181
1197
EXPECT_CALL (stageTarget, colorAtScratchPoint).Times (0 );
1182
1198
ASSERT_FALSE (target.touchingColor (color1));
1183
1199
0 commit comments