@@ -576,11 +576,13 @@ TEST_F(RenderedTargetTest, SpriteDragging)
576
576
QMouseEvent moveEventRightButton (QEvent::MouseMove, QPointF (), QPointF (), Qt::RightButton, Qt::RightButton, Qt::NoModifier);
577
577
QMouseEvent pressEventRightButton (QEvent::MouseButtonPress, QPointF (), QPointF (), Qt::RightButton, Qt::RightButton, Qt::NoModifier);
578
578
QMouseEvent releaseEventRightButton (QEvent::MouseButtonRelease, QPointF (), QPointF (), Qt::RightButton, Qt::RightButton, Qt::NoModifier);
579
+ EXPECT_CALL (engine, clickTarget (&sprite));
579
580
QCoreApplication::sendEvent (&target, &pressEventRightButton);
580
581
QCoreApplication::sendEvent (&target, &moveEventRightButton);
581
582
ASSERT_EQ (sprite.x (), 64.08 );
582
583
ASSERT_EQ (sprite.y (), -6.86 );
583
584
ASSERT_EQ (mouseArea.draggedSprite (), nullptr );
585
+ EXPECT_CALL (engine, clickTarget).Times (0 );
584
586
QCoreApplication::sendEvent (&target, &releaseEventRightButton);
585
587
ASSERT_EQ (mouseArea.draggedSprite (), nullptr );
586
588
@@ -591,11 +593,13 @@ TEST_F(RenderedTargetTest, SpriteDragging)
591
593
592
594
// Try right mouse button with "draggable" set to true (should not work)
593
595
sprite.setDraggable (true );
596
+ EXPECT_CALL (engine, clickTarget).Times (0 );
594
597
QCoreApplication::sendEvent (&target, &pressEventRightButton);
595
598
QCoreApplication::sendEvent (&target, &moveEventRightButton);
596
599
ASSERT_EQ (sprite.x (), 64.08 );
597
600
ASSERT_EQ (sprite.y (), -6.86 );
598
601
ASSERT_EQ (mouseArea.draggedSprite (), nullptr );
602
+ EXPECT_CALL (engine, clickTarget (&sprite));
599
603
QCoreApplication::sendEvent (&target, &releaseEventRightButton);
600
604
ASSERT_EQ (mouseArea.draggedSprite (), nullptr );
601
605
@@ -609,6 +613,7 @@ TEST_F(RenderedTargetTest, SpriteDragging)
609
613
QMouseEvent moveEvent (QEvent::MouseMove, QPointF (), QPointF (), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
610
614
QMouseEvent pressEvent (QEvent::MouseButtonPress, QPointF (), QPointF (), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
611
615
QMouseEvent releaseEvent (QEvent::MouseButtonRelease, QPointF (), QPointF (), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
616
+ EXPECT_CALL (engine, clickTarget (&sprite));
612
617
QCoreApplication::sendEvent (&target, &pressEvent);
613
618
QCoreApplication::sendEvent (&target, &moveEvent);
614
619
ASSERT_EQ (sprite.x (), 64.08 );
@@ -619,10 +624,12 @@ TEST_F(RenderedTargetTest, SpriteDragging)
619
624
ASSERT_EQ (sprite.x (), 64.08 );
620
625
ASSERT_EQ (sprite.y (), -6.86 );
621
626
ASSERT_EQ (mouseArea.draggedSprite (), nullptr );
627
+ EXPECT_CALL (engine, clickTarget).Times (0 );
622
628
QCoreApplication::sendEvent (&target, &releaseEvent);
623
629
624
630
// Try left mouse button with "draggable" set to true
625
631
sprite.setDraggable (true );
632
+ EXPECT_CALL (engine, clickTarget).Times (0 );
626
633
QCoreApplication::sendEvent (&target, &pressEvent);
627
634
EXPECT_CALL (engine, mouseX ()).WillOnce (Return (67.95 ));
628
635
EXPECT_CALL (engine, mouseY ()).WillOnce (Return (2.1 ));
@@ -663,12 +670,15 @@ TEST_F(RenderedTargetTest, SpriteDragging)
663
670
664
671
// Try to drag the second sprite while the first is being dragged
665
672
sprite.setDraggable (true );
673
+ EXPECT_CALL (engine, clickTarget).Times (0 );
666
674
QCoreApplication::sendEvent (&anotherTarget, &pressEvent);
667
675
QCoreApplication::sendEvent (&anotherTarget, &moveEvent);
668
676
ASSERT_EQ (mouseArea.draggedSprite (), &target);
677
+ EXPECT_CALL (engine, clickTarget (&sprite));
669
678
QCoreApplication::sendEvent (&anotherTarget, &releaseEvent);
670
679
671
680
// Stop dragging
681
+ EXPECT_CALL (engine, clickTarget).Times (0 );
672
682
QCoreApplication::sendEvent (&target, &releaseEvent);
673
683
ASSERT_EQ (std::round (sprite.x () * 100 ) / 100 , 68.26 );
674
684
ASSERT_EQ (std::round (sprite.y () * 100 ) / 100 , -1.95 );
0 commit comments