@@ -305,7 +305,10 @@ TEST_F(RenderedTargetTest, HullPoints)
305305 SpriteModel model;
306306 model.init (&sprite);
307307
308- RenderedTarget target;
308+ QQuickItem parent;
309+ parent.setWidth (200 );
310+ parent.setHeight (100 );
311+ RenderedTarget target (&parent);
309312 target.setEngine (&engine);
310313 target.setSpriteModel (&model);
311314
@@ -315,14 +318,17 @@ TEST_F(RenderedTargetTest, HullPoints)
315318 createContextAndSurface (&context, &surface);
316319
317320 // Load costume
318- EXPECT_CALL (engine, stageWidth ()).WillOnce (Return (480 ));
319- EXPECT_CALL (engine, stageHeight ()).WillOnce (Return (360 ));
321+ EXPECT_CALL (engine, stageWidth ()).WillRepeatedly (Return (480 ));
322+ EXPECT_CALL (engine, stageHeight ()).WillRepeatedly (Return (360 ));
320323 auto costume = std::make_shared<Costume>(" " , " " , " png" );
321324 std::string costumeData = readFileStr (" image.png" );
322325 costume->setData (costumeData.size (), static_cast <void *>(costumeData.data ()));
323326 sprite.addCostume (costume);
324327 target.loadCostumes ();
325328 target.updateCostume (costume.get ());
329+ target.setStageScale (2 );
330+ target.setX (25 );
331+ target.setY (30 );
326332
327333 // Test hull points
328334 target.setWidth (3 );
@@ -351,6 +357,28 @@ TEST_F(RenderedTargetTest, HullPoints)
351357 ASSERT_TRUE (target.contains ({ 3 , 3 }));
352358 ASSERT_FALSE (target.contains ({ 3.3 , 3.5 }));
353359
360+ // Test containsScratchPoint()
361+ ASSERT_FALSE (target.containsScratchPoint (-227.5 , 165 )); // [0, 0]
362+ ASSERT_FALSE (target.containsScratchPoint (-226.5 , 165 )); // [1, 0]
363+ ASSERT_FALSE (target.containsScratchPoint (-225.5 , 165 )); // [2, 0]
364+ ASSERT_FALSE (target.containsScratchPoint (-224.5 , 165 )); // [3, 0]
365+
366+ ASSERT_FALSE (target.containsScratchPoint (-227.5 , 164 )); // [0, 1]
367+ ASSERT_TRUE (target.containsScratchPoint (-226.5 , 164 )); // [1, 1]
368+ ASSERT_TRUE (target.containsScratchPoint (-226.1 , 163.75 )); // [1.4, 1.25]
369+ ASSERT_TRUE (target.containsScratchPoint (-225.5 , 164 )); // [2, 1]
370+ ASSERT_TRUE (target.containsScratchPoint (-224.5 , 164 )); // [3, 1]
371+
372+ ASSERT_TRUE (target.containsScratchPoint (-226.5 , 163 )); // [1, 2]
373+ ASSERT_FALSE (target.containsScratchPoint (-225.5 , 163 )); // [2, 2]
374+ ASSERT_TRUE (target.containsScratchPoint (-224.5 , 163 )); // [3, 2]
375+ ASSERT_FALSE (target.containsScratchPoint (-224 , 162.9 )); // [3.5, 2.1]
376+
377+ ASSERT_TRUE (target.containsScratchPoint (-226.5 , 162 )); // [1, 3]
378+ ASSERT_TRUE (target.containsScratchPoint (-225.5 , 162 )); // [2, 3]
379+ ASSERT_TRUE (target.containsScratchPoint (-224.5 , 162 )); // [3, 3]
380+ ASSERT_FALSE (target.containsScratchPoint (-224.2 , 161.5 )); // [3.3, 3.5]
381+
354382 // Cleanup
355383 context.doneCurrent ();
356384}
0 commit comments