@@ -231,7 +231,10 @@ TEST_F(PenLayerTest, Clear)
231231 painter.endFrame ();
232232 fbo->release ();
233233
234+ penLayer.beginFrame ();
234235 penLayer.clear ();
236+ penLayer.endFrame ();
237+
235238 QImage image2 = fbo->toImage ();
236239
237240 // The image must contain only fully transparent pixels
@@ -275,7 +278,9 @@ TEST_F(PenLayerTest, DrawPoint)
275278 penLayer.drawPoint (attr, -54 , 21 );
276279 };
277280
281+ penLayer.beginFrame ();
278282 draw ();
283+ penLayer.endFrame ();
279284
280285 {
281286 QOpenGLFramebufferObject *fbo = penLayer.framebufferObject ();
@@ -302,8 +307,10 @@ TEST_F(PenLayerTest, DrawPoint)
302307 }
303308
304309 // Test HQ pen - draw
310+ penLayer.beginFrame ();
305311 penLayer.clear ();
306312 draw ();
313+ penLayer.endFrame ();
307314
308315 {
309316 QOpenGLFramebufferObject *fbo = penLayer.framebufferObject ();
@@ -324,7 +331,8 @@ TEST_F(PenLayerTest, DrawLine)
324331 penLayer.setWidth (480 );
325332 penLayer.setHeight (360 );
326333 EngineMock engine;
327- EXPECT_CALL (engine, stageWidth ()).WillOnce (Return (480 ));
334+ EXPECT_CALL (engine, stageWidth ()).WillRepeatedly (Return (480 ));
335+ EXPECT_CALL (engine, stageHeight ()).WillRepeatedly (Return (360 ));
328336 penLayer.setEngine (&engine);
329337
330338 auto draw = [&penLayer]() {
@@ -350,7 +358,9 @@ TEST_F(PenLayerTest, DrawLine)
350358 penLayer.drawLine (attr, -54 , 21 , 88 , -6 );
351359 };
352360
361+ penLayer.beginFrame ();
353362 draw ();
363+ penLayer.endFrame ();
354364
355365 {
356366 QOpenGLFramebufferObject *fbo = penLayer.framebufferObject ();
@@ -364,12 +374,13 @@ TEST_F(PenLayerTest, DrawLine)
364374 }
365375
366376 // Test HQ pen
367- penLayer.clear ();
368- EXPECT_CALL (engine, stageWidth ()).Times (3 ).WillRepeatedly (Return (480 ));
369377 penLayer.setHqPen (true );
370378 penLayer.setWidth (720 );
371379 penLayer.setHeight (540 );
380+ penLayer.beginFrame ();
381+ penLayer.clear ();
372382 draw ();
383+ penLayer.endFrame ();
373384
374385 {
375386 QOpenGLFramebufferObject *fbo = penLayer.framebufferObject ();
@@ -429,9 +440,13 @@ TEST_F(PenLayerTest, Stamp)
429440 i++;
430441 }
431442
443+ penLayer.beginFrame ();
444+
432445 for (const auto &target : targets)
433446 penLayer.stamp (target.get ());
434447
448+ penLayer.endFrame ();
449+
435450 {
436451 QOpenGLFramebufferObject *fbo = penLayer.framebufferObject ();
437452 QImage image = fbo->toImage ().scaled (240 , 180 );
@@ -440,14 +455,17 @@ TEST_F(PenLayerTest, Stamp)
440455 }
441456
442457 // Test HQ pen
443- penLayer.clear ();
444458 penLayer.setHqPen (true );
445459 penLayer.setWidth (720 );
446460 penLayer.setHeight (540 );
461+ penLayer.beginFrame ();
462+ penLayer.clear ();
447463
448464 for (const auto &target : targets)
449465 penLayer.stamp (target.get ());
450466
467+ penLayer.endFrame ();
468+
451469 {
452470 QOpenGLFramebufferObject *fbo = penLayer.framebufferObject ();
453471 QImage image = fbo->toImage ();
@@ -464,8 +482,11 @@ TEST_F(PenLayerTest, TextureData)
464482 penLayer.setAntialiasingEnabled (false );
465483 EngineMock engine;
466484 EXPECT_CALL (engine, stageWidth ()).WillRepeatedly (Return (6 ));
485+ EXPECT_CALL (engine, stageHeight ()).WillRepeatedly (Return (4 ));
467486 penLayer.setEngine (&engine);
468487
488+ penLayer.beginFrame ();
489+
469490 PenAttributes attr;
470491 attr.color = QNanoColor (255 , 0 , 0 );
471492 attr.diameter = 1 ;
@@ -529,13 +550,18 @@ TEST_F(PenLayerTest, TextureData)
529550 ASSERT_EQ (bounds.right (), 2 );
530551 ASSERT_EQ (bounds.bottom (), -2 );
531552
553+ penLayer.endFrame ();
554+
532555 // Test HQ pen
533- penLayer.clear ();
534- EXPECT_CALL (engine, stageWidth ()).Times (3 ).WillRepeatedly (Return (480 ));
535556 penLayer.setHqPen (true );
536557 penLayer.setWidth (720 );
537558 penLayer.setHeight (540 );
538559
560+ penLayer.beginFrame ();
561+ penLayer.clear ();
562+ EXPECT_CALL (engine, stageWidth ()).WillRepeatedly (Return (480 ));
563+ EXPECT_CALL (engine, stageHeight ()).WillRepeatedly (Return (360 ));
564+
539565 attr = PenAttributes ();
540566 attr.color = QNanoColor (255 , 0 , 0 );
541567 attr.diameter = 1 ;
@@ -545,10 +571,10 @@ TEST_F(PenLayerTest, TextureData)
545571 ASSERT_EQ (penLayer.colorAtScratchPoint (-1 , 1 ), qRgb (255 , 0 , 0 ));
546572
547573 bounds = penLayer.getBounds ();
548- ASSERT_EQ (std::round (bounds.left () * 100 ) / 100 , -3.33 );
549- ASSERT_EQ (bounds.top (), 2 );
550- ASSERT_EQ (std::round (bounds.right () * 100 ) / 100 , 3.67 );
551- ASSERT_EQ (bounds.bottom (), -3 );
574+ ASSERT_EQ (std::round (bounds.left () * 100 ) / 100 , -3 );
575+ ASSERT_EQ (bounds.top (), 2.25 );
576+ ASSERT_EQ (std::round (bounds.right () * 100 ) / 100 , 3.99 );
577+ ASSERT_EQ (std::round ( bounds.bottom () * 100 ) / 100 , -3.24 );
552578
553579 attr.color = QNanoColor (0 , 128 , 0 , 128 );
554580 attr.diameter = 2 ;
@@ -558,10 +584,10 @@ TEST_F(PenLayerTest, TextureData)
558584 ASSERT_EQ (penLayer.colorAtScratchPoint (-1 , 1 ), qRgb (255 , 0 , 0 ));
559585
560586 bounds = penLayer.getBounds ();
561- ASSERT_EQ (std::round (bounds.left () * 100 ) / 100 , -3.33 );
562- ASSERT_EQ (std::round (bounds.top () * 100 ) / 100 , 2.67 );
563- ASSERT_EQ (std::round (bounds.right () * 100 ) / 100 , 4.33 );
564- ASSERT_EQ (std::round (bounds.bottom () * 100 ) / 100 , -3.67 );
587+ ASSERT_EQ (std::round (bounds.left () * 100 ) / 100 , -3 );
588+ ASSERT_EQ (std::round (bounds.top () * 100 ) / 100 , 2.25 );
589+ ASSERT_EQ (std::round (bounds.right () * 100 ) / 100 , 3.99 );
590+ ASSERT_EQ (std::round (bounds.bottom () * 100 ) / 100 , -3.24 );
565591
566592 penLayer.clear ();
567593 ASSERT_EQ (penLayer.colorAtScratchPoint (-3 , 2 ), 0 );
@@ -582,10 +608,10 @@ TEST_F(PenLayerTest, TextureData)
582608 ASSERT_EQ (penLayer.colorAtScratchPoint (-3 , 1 ), qRgba (0 , 0 , 0 , 0 ));
583609
584610 bounds = penLayer.getBounds ();
585- ASSERT_EQ (bounds.left (), 0 );
586- ASSERT_EQ (std::round (bounds.top () * 100 ) / 100 , 1.33 );
587- ASSERT_EQ (std::round (bounds.right () * 100 ) / 100 , 1.67 );
588- ASSERT_EQ (std::round (bounds.bottom () * 100 ) / 100 , -1.67 );
611+ ASSERT_EQ (bounds.left (), - 0.5 );
612+ ASSERT_EQ (std::round (bounds.top () * 100 ) / 100 , 1.5 );
613+ ASSERT_EQ (std::round (bounds.right () * 100 ) / 100 , 2.49 );
614+ ASSERT_EQ (std::round (bounds.bottom () * 100 ) / 100 , -2.49 );
589615
590616 attr.diameter = 2 ;
591617 penLayer.drawPoint (attr, -2 , 0 );
@@ -594,8 +620,10 @@ TEST_F(PenLayerTest, TextureData)
594620 ASSERT_EQ (penLayer.colorAtScratchPoint (-3 , 1 ), 0 );
595621
596622 bounds = penLayer.getBounds ();
597- ASSERT_EQ (std::round (bounds.left () * 100 ) / 100 , -2.67 );
598- ASSERT_EQ (std::round (bounds.top () * 100 ) / 100 , 1.33 );
599- ASSERT_EQ (std::round (bounds.right () * 100 ) / 100 , 1.67 );
600- ASSERT_EQ (std::round (bounds.bottom () * 100 ) / 100 , -1.67 );
623+ ASSERT_EQ (std::round (bounds.left () * 100 ) / 100 , -3 );
624+ ASSERT_EQ (std::round (bounds.top () * 100 ) / 100 , 1.5 );
625+ ASSERT_EQ (std::round (bounds.right () * 100 ) / 100 , 2.49 );
626+ ASSERT_EQ (std::round (bounds.bottom () * 100 ) / 100 , -2.49 );
627+
628+ penLayer.endFrame ();
601629}
0 commit comments