@@ -305,7 +305,10 @@ TEST_F(RenderedTargetTest, HullPoints)
305
305
SpriteModel model;
306
306
model.init (&sprite);
307
307
308
- RenderedTarget target;
308
+ QQuickItem parent;
309
+ parent.setWidth (200 );
310
+ parent.setHeight (100 );
311
+ RenderedTarget target (&parent);
309
312
target.setEngine (&engine);
310
313
target.setSpriteModel (&model);
311
314
@@ -315,14 +318,17 @@ TEST_F(RenderedTargetTest, HullPoints)
315
318
createContextAndSurface (&context, &surface);
316
319
317
320
// 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 ));
320
323
auto costume = std::make_shared<Costume>(" " , " " , " png" );
321
324
std::string costumeData = readFileStr (" image.png" );
322
325
costume->setData (costumeData.size (), static_cast <void *>(costumeData.data ()));
323
326
sprite.addCostume (costume);
324
327
target.loadCostumes ();
325
328
target.updateCostume (costume.get ());
329
+ target.setStageScale (2 );
330
+ target.setX (25 );
331
+ target.setY (30 );
326
332
327
333
// Test hull points
328
334
target.setWidth (3 );
@@ -351,6 +357,28 @@ TEST_F(RenderedTargetTest, HullPoints)
351
357
ASSERT_TRUE (target.contains ({ 3 , 3 }));
352
358
ASSERT_FALSE (target.contains ({ 3.3 , 3.5 }));
353
359
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
+
354
382
// Cleanup
355
383
context.doneCurrent ();
356
384
}
0 commit comments