@@ -104,9 +104,15 @@ def _send_latching_switch_named_pipe_command(self, endpoint_id: int, new_positio
104
104
command_dict = {"Name" : "SimulateLatchPosition" , "EndpointId" : endpoint_id , "PositionId" : new_position }
105
105
self ._send_named_pipe_command (command_dict )
106
106
107
- def _ask_for_switch_idle (self ):
107
+ def _send_switch_idle_named_pipe_command (self , endpoint_id : int ):
108
+ command_dict = {"Name" : "SimulateSwitchIdle" , "EndpointId" : endpoint_id }
109
+ self ._send_named_pipe_command (command_dict )
110
+
111
+ def _ask_for_switch_idle (self , endpoint_id : int , omit_for_simulator : bool = False ):
108
112
if not self ._use_button_simulator ():
109
113
self .wait_for_user_input (prompt_msg = "Ensure switch is idle" )
114
+ elif not omit_for_simulator :
115
+ self ._send_switch_idle_named_pipe_command (endpoint_id )
110
116
111
117
def _ask_for_switch_position (self , endpoint_id : int , new_position : int ):
112
118
if not self ._use_button_simulator ():
@@ -283,7 +289,6 @@ async def test_TC_SWTCH_2_2(self):
283
289
# Step 3: Operator sets switch to first position on the DUT.
284
290
self .step (3 )
285
291
self ._ask_for_switch_position (endpoint_id , new_position = 0 )
286
- event_listener .flush_events ()
287
292
288
293
# Step 4: TH reads the CurrentPosition attribute from the DUT.
289
294
# Verify that the value is 0.
@@ -369,7 +374,7 @@ async def test_TC_SWTCH_2_3(self):
369
374
await event_listener .start (self .default_controller , self .dut_node_id , endpoint = endpoint_id )
370
375
371
376
self .step (3 )
372
- self ._ask_for_switch_idle ()
377
+ self ._ask_for_switch_idle (endpoint_id )
373
378
374
379
self .step (4 )
375
380
button_val = await self .read_single_attribute_check_success (cluster = cluster , attribute = cluster .Attributes .CurrentPosition )
@@ -461,7 +466,7 @@ async def test_TC_SWTCH_2_4(self):
461
466
462
467
# Step 3: Operator does not operate switch on the DUT
463
468
self .step (3 )
464
- self ._ask_for_switch_idle ()
469
+ self ._ask_for_switch_idle (endpoint_id )
465
470
466
471
# Step 4: TH reads the CurrentPosition attribute from the DUT
467
472
self .step (4 )
@@ -486,9 +491,9 @@ async def test_TC_SWTCH_2_4(self):
486
491
self ._await_sequence_of_events (event_queue = event_listener .event_queue , endpoint_id = endpoint_id ,
487
492
sequence = expected_events , timeout_sec = post_prompt_settle_delay_seconds )
488
493
489
- # - if MSL or AS feature is supported, expect to see LongPress/LongRelease in that order.
490
- if not has_msl_feature and not has_as_feature :
491
- logging .info ("Since MSL and AS features both unsupported, skipping check for LongPress/LongRelease" )
494
+ # - if MSL feature is supported, expect to see LongPress/LongRelease in that order.
495
+ if not has_msl_feature :
496
+ logging .info ("Since MSL feature unsupported, skipping check for LongPress/LongRelease" )
492
497
else :
493
498
# - TH expects report of LongPress, LongRelease in that order.
494
499
logging .info (f"Starting to wait for { post_prompt_settle_delay_seconds :.1f} seconds for LongPress then LongRelease." )
@@ -538,13 +543,13 @@ def steps_TC_SWTCH_2_5(self):
538
543
TestStep ("6b" , "Operator repeat step 4a 3 times quickly" ,
539
544
"""
540
545
* Verify that the TH receives InitialPress event with NewPosition set to 1 from the DUT
541
- * Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
546
+ * If MSR supported, Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
542
547
* Verify that the TH receives InitialPress event with NewPosition set to 1 from the DUT
543
548
* Verify that the TH receives MultiPressOngoing event with NewPosition set to 1 and CurrentNumberOfPressesCounted set to 2 from the DUT
544
- * Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
549
+ * If MSR supported, Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
545
550
* Verify that the TH receives InitialPress event with NewPosition set to 1 from the DUT
546
551
* Verify that the TH receives MultiPressOngoing event with NewPosition set to 1 and CurrentNumberOfPressesCounted set to 3 from the DUT
547
- * Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT +
552
+ * If MSR supported, Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT +
548
553
549
554
The events sequence from the subscription SHALL follow the same sequence as expressed above, in the exact order of events specified.
550
555
""" ),
@@ -561,11 +566,11 @@ def steps_TC_SWTCH_2_5(self):
561
566
"""
562
567
563
568
* Verify that the TH receives InitialPress event with NewPosition set to 1 from the DUT
564
- * Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
569
+ * If MSR supported, Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
565
570
* Verify that the TH receives InitialPress event with NewPosition set to 1 from the DUT
566
571
567
572
* Verify that the TH receives MultiPressOngoing event with NewPosition set to 1 and CurrentNumberOfPressesCounted set to 2 from the DUT
568
- * Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
573
+ * If MSR supported, verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
569
574
* Verify that the TH does not receive LongPress event from the DUT
570
575
* Verify that the TH does not receive LongRelease event from the DUT
571
576
@@ -586,7 +591,7 @@ def steps_TC_SWTCH_2_5(self):
586
591
* Verify that the TH receives (one, not more than one) LongPress event with NewPosition set to 1 from the DUT
587
592
* Verify that the TH receives LongRelease event with PreviousPosition set to 1 from the DUT
588
593
* Verify that the TH receives InitialPress event with NewPosition set to 1 from the DUT
589
- * Verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
594
+ * If MSR supported, verify that the TH receives ShortRelease event with PreviousPosition set to 1 from the DUT
590
595
* Verify that the TH does not receive MultiPressOngoing event from the DUT
591
596
592
597
The events sequence from the subscription SHALL follow the same sequence as expressed above, in the exact order of events specified.
@@ -610,6 +615,7 @@ async def test_TC_SWTCH_2_5(self):
610
615
cluster = Clusters .Switch
611
616
feature_map = await self .read_single_attribute_check_success (cluster , attribute = cluster .Attributes .FeatureMap )
612
617
has_msl_feature = (feature_map & cluster .Bitmaps .Feature .kMomentarySwitchLongPress )
618
+ has_msr_feature = (feature_map & cluster .Bitmaps .Feature .kMomentarySwitchRelease )
613
619
multi_press_max = await self .read_single_attribute_check_success (cluster , attribute = cluster .Attributes .MultiPressMax )
614
620
615
621
endpoint_id = self .matter_test_config .endpoint
@@ -620,7 +626,7 @@ async def test_TC_SWTCH_2_5(self):
620
626
await event_listener .start (self .default_controller , self .dut_node_id , endpoint = endpoint_id )
621
627
622
628
self .step (3 )
623
- self ._ask_for_switch_idle ()
629
+ self ._ask_for_switch_idle (endpoint_id )
624
630
625
631
def test_multi_press_sequence (starting_step : str , count : int , short_long : bool = False ):
626
632
step = starting_step
@@ -640,12 +646,13 @@ def test_multi_press_sequence(starting_step: str, count: int, short_long: bool =
640
646
asserts .assert_equal (event .newPosition , pressed_position , "Unexpected NewPosition on MultiPressOngoing" )
641
647
asserts .assert_equal (event .currentNumberOfPressesCounted , pos_idx + 1 ,
642
648
"Unexpected CurrentNumberOfPressesCounted on MultiPressOngoing" )
643
- event = event_listener .wait_for_event_report (cluster .Events .ShortRelease )
644
- asserts .assert_equal (event .previousPosition , pressed_position , "Unexpected PreviousPosition on ShortRelease" )
649
+ if has_msr_feature :
650
+ event = event_listener .wait_for_event_report (cluster .Events .ShortRelease )
651
+ asserts .assert_equal (event .previousPosition , pressed_position , "Unexpected PreviousPosition on ShortRelease" )
645
652
646
653
step = bump_substep (step )
647
654
self .step (step )
648
- self ._ask_for_switch_idle ()
655
+ self ._ask_for_switch_idle (endpoint_id , omit_for_simulator = True )
649
656
event = event_listener .wait_for_event_report (cluster .Events .MultiPressComplete )
650
657
asserts .assert_equal (event .previousPosition , pressed_position , "Unexpected PreviousPosition on MultiPressComplete" )
651
658
asserts .assert_equal (event .totalNumberOfPressesCounted , count , "Unexpected count on MultiPressComplete" )
@@ -687,13 +694,15 @@ def test_multi_press_sequence(starting_step: str, count: int, short_long: bool =
687
694
688
695
event = event_listener .wait_for_event_report (cluster .Events .InitialPress )
689
696
asserts .assert_equal (event .newPosition , pressed_position , "Unexpected NewPosition on InitialEvent" )
690
- event = event_listener .wait_for_event_report (cluster .Events .ShortRelease )
691
- asserts .assert_equal (event .previousPosition , pressed_position , "Unexpected PreviousPosition on ShortRelease" )
697
+
698
+ if has_msr_feature :
699
+ event = event_listener .wait_for_event_report (cluster .Events .ShortRelease )
700
+ asserts .assert_equal (event .previousPosition , pressed_position , "Unexpected PreviousPosition on ShortRelease" )
692
701
693
702
# Because this is a queue, we verify that no multipress ongoing is received by verifying that the next event is the multipress complete
694
703
695
704
self .step ("9b" )
696
- self ._ask_for_switch_idle ()
705
+ self ._ask_for_switch_idle (endpoint_id , omit_for_simulator = True )
697
706
event = event_listener .wait_for_event_report (cluster .Events .MultiPressComplete )
698
707
asserts .assert_equal (event .previousPosition , pressed_position , "Unexpected PreviousPosition on MultiPressComplete" )
699
708
asserts .assert_equal (event .totalNumberOfPressesCounted , 1 , "Unexpected count on MultiPressComplete" )
@@ -795,7 +804,7 @@ async def test_TC_SWTCH_2_6(self):
795
804
await event_listener .start (self .default_controller , self .dut_node_id , endpoint = endpoint_id )
796
805
797
806
self .step (3 )
798
- self ._ask_for_switch_idle ()
807
+ self ._ask_for_switch_idle (endpoint_id )
799
808
800
809
def test_multi_press_sequence (starting_step : str , count : int , short_long : bool = False ):
801
810
step = starting_step
@@ -813,7 +822,7 @@ def test_multi_press_sequence(starting_step: str, count: int, short_long: bool =
813
822
814
823
step = bump_substep (step )
815
824
self .step (step )
816
- self ._ask_for_switch_idle ()
825
+ self ._ask_for_switch_idle (endpoint_id , omit_for_simulator = True )
817
826
event = event_listener .wait_for_event_report (cluster .Events .MultiPressComplete )
818
827
asserts .assert_equal (event .previousPosition , pressed_position , "Unexpected PreviousPosition on MultiPressComplete" )
819
828
expected_count = 0 if count > multi_press_max else count
@@ -853,7 +862,7 @@ def test_multi_press_sequence(starting_step: str, count: int, short_long: bool =
853
862
854
863
# Verify that we don't receive the multi-press ongoing or short release by verifying that the next event in the sequence is the multi-press complete
855
864
self .step ("9b" )
856
- self ._ask_for_switch_idle ()
865
+ self ._ask_for_switch_idle (endpoint_id , omit_for_simulator = True )
857
866
event = event_listener .wait_for_event_report (cluster .Events .MultiPressComplete )
858
867
asserts .assert_equal (event .previousPosition , pressed_position , "Unexpected PreviousPosition on MultiPressComplete" )
859
868
asserts .assert_equal (event .totalNumberOfPressesCounted , 1 , "Unexpected count on MultiPressComplete" )
0 commit comments