@@ -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
}
@@ -313,8 +315,8 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_Range_Start_Drag_From_Selec
313
315
EXPECT_CALL (m_view, isNoteEnterMode ())
314
316
.WillOnce (Return (false ));
315
317
316
- EXPECT_CALL (*m_playbackController, isPlaying ())
317
- .WillOnce (Return (false ));
318
+ ON_CALL (*m_playbackController, isPlaying ())
319
+ .WillByDefault (Return (false ));
318
320
319
321
// ! [THEN] We will seek and play selected note, but no select again
320
322
EXPECT_CALL (*m_playbackController, seekElement (newContext.element ))
@@ -455,8 +457,8 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_On_Selected_Non_Text_Elemen
455
457
EXPECT_CALL (m_view, isNoteEnterMode ())
456
458
.WillOnce (Return (false ));
457
459
458
- EXPECT_CALL (*m_playbackController, isPlaying ())
459
- .WillOnce (Return (false ));
460
+ ON_CALL (*m_playbackController, isPlaying ())
461
+ .WillByDefault (Return (false ));
460
462
461
463
// ! [THEN] We will seek and play selected hairpin, but no select again
462
464
EXPECT_CALL (*m_playbackController, seekElement (newContext.element ))
@@ -522,8 +524,8 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_Range_Start_Play_From_First
522
524
EXPECT_CALL (m_view, isNoteEnterMode ())
523
525
.WillOnce (Return (false ));
524
526
525
- EXPECT_CALL (*m_playbackController, isPlaying ())
526
- .WillOnce (Return (false ));
527
+ ON_CALL (*m_playbackController, isPlaying ())
528
+ .WillByDefault (Return (false ));
527
529
528
530
// ! [THEN] We will select and play selected note, but no seek
529
531
std::vector<EngravingItem*> selectElements = { newContext.element };
@@ -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
@@ -588,8 +647,8 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_On_Already_Selected_Element
588
647
EXPECT_CALL (m_view, isNoteEnterMode ())
589
648
.WillOnce (Return (false ));
590
649
591
- EXPECT_CALL (*m_playbackController, isPlaying ())
592
- .WillOnce (Return (false ));
650
+ ON_CALL (*m_playbackController, isPlaying ())
651
+ .WillByDefault (Return (false ));
593
652
594
653
// ! [THEN] We will no select already selected note, but play and seek
595
654
std::vector<EngravingItem*> selectElements = { newContext.element };
@@ -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
{
@@ -645,8 +704,8 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_On_Range)
645
704
EXPECT_CALL (m_view, isNoteEnterMode ())
646
705
.WillOnce (Return (false ));
647
706
648
- EXPECT_CALL (*m_playbackController, isPlaying ())
649
- .WillOnce (Return (false ));
707
+ ON_CALL (*m_playbackController, isPlaying ())
708
+ .WillByDefault (Return (false ));
650
709
651
710
// ! [THEN] We will select new measure
652
711
std::vector<EngravingItem*> selectElements = { newContext.element };
0 commit comments