@@ -151,6 +151,8 @@ class NotationViewInputControllerTests : public ::testing::Test
151
151
}
152
152
break ;
153
153
}
154
+ case ElementType::MEASURE:
155
+ return chord->segment ()->measure ();
154
156
default :
155
157
break ;
156
158
}
@@ -553,6 +555,63 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_Range_Start_Play_From_First
553
555
m_controller->mousePressEvent (make_mousePressEvent (Qt::LeftButton, Qt::ShiftModifier, QPoint (100 , 100 )));
554
556
}
555
557
558
+ /* *
559
+ * @brief Mouse_Press_On_Selected_Selected_Range
560
+ * @details User pressed left mouse button on already selected range
561
+ * The selection shouldn't be changed, but the first measure in the range should be seeked
562
+ */
563
+ TEST_F (NotationViewInputControllerTests, Mouse_Press_On_Already_Selected_Range)
564
+ {
565
+ // ! [GIVEN] There is a test score
566
+ engraving::MasterScore* score = engraving::ScoreRW::readScore (TEST_SCORE_PATH);
567
+
568
+ // ! [GIVEN] Previous selected measure
569
+ INotationInteraction::HitElementContext oldContext = hitContext (score, { ElementType::MEASURE });
570
+
571
+ // ! [GIVEN] User selected measure that is already selected
572
+ INotationInteraction::HitElementContext newContext = oldContext;
573
+ newContext.element ->setSelected (true );
574
+
575
+ std::vector<EngravingItem*> selectedElements {
576
+ newContext.element
577
+ };
578
+
579
+ EXPECT_CALL (*m_interaction, hitElement (_, _))
580
+ .WillOnce (Return (newContext.element ));
581
+
582
+ EXPECT_CALL (*m_interaction, hitStaff (_))
583
+ .WillOnce (Return (newContext.element ->staff ()));
584
+
585
+ // ! [GIVEN] The new hit element context with new measure will be set
586
+ EXPECT_CALL (*m_interaction, setHitElementContext (newContext))
587
+ .Times (1 );
588
+
589
+ EXPECT_CALL (*m_interaction, hitElementContext ())
590
+ .Times (2 )
591
+ .WillOnce (ReturnRef (oldContext))
592
+ .WillOnce (ReturnRef (oldContext));
593
+
594
+ // ! [GIVEN] There is a range selection
595
+ ON_CALL (*m_selection, isRange ())
596
+ .WillByDefault (Return (true ));
597
+ ON_CALL (*m_selectionRange, containsPoint (_))
598
+ .WillByDefault (Return (true ));
599
+
600
+ EXPECT_CALL (*m_selection, elements ())
601
+ .WillOnce (ReturnRef (selectedElements));
602
+
603
+ // ! [THEN] We should seek measure from the range
604
+ EXPECT_CALL (*m_playbackController, seekElement (newContext.element ))
605
+ .Times (1 );
606
+
607
+ // ! [THEN] No selection change
608
+ EXPECT_CALL (*m_interaction, select (_, _, _))
609
+ .Times (0 );
610
+
611
+ // ! [WHEN] User pressed left mouse button
612
+ m_controller->mousePressEvent (make_mousePressEvent (Qt::LeftButton, Qt::NoModifier, QPoint (100 , 100 )));
613
+ }
614
+
556
615
/* *
557
616
* @brief Mouse_Press_On_Already_Selected_Element
558
617
* @details User pressed on already selected note
@@ -614,7 +673,7 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_On_Already_Selected_Element
614
673
/* *
615
674
* @brief Mouse_Press_On_Range
616
675
* @details User pressed selected new measure with ShiftModifier
617
- * The new meausure should be selected, shouldn't be played, previous meausure should be seeked
676
+ * The new measure should be selected, shouldn't be played, previous measure should be seeked
618
677
*/
619
678
TEST_F (NotationViewInputControllerTests, Mouse_Press_On_Range)
620
679
{
0 commit comments