@@ -53,6 +53,7 @@ def desc_TC_SWTCH_2_4(self) -> str:
53
53
"""Returns a description of this test"""
54
54
return "[TC-SWTCH-2.4] Momentary Switch Long Press Verification"
55
55
56
+ # TODO(#34656): Fill test steps
56
57
# def steps_TC_SWTCH_2_4(self) -> list[TestStep]:
57
58
# steps = [
58
59
# TestStep("0", "Commissioning, already done", is_commissioning=True),
@@ -79,10 +80,6 @@ def _send_named_pipe_command(self, command_dict: dict[str, Any]):
79
80
def _use_button_simulator (self ) -> bool :
80
81
return self .check_pics ("PICS_SDK_CI_ONLY" ) or self .user_params .get ("use_button_simulator" , False )
81
82
82
- def _ask_for_switch_idle (self ):
83
- if not self ._use_button_simulator ():
84
- self .wait_for_user_input (prompt_msg = "Ensure switch is idle" )
85
-
86
83
def _send_multi_press_named_pipe_command (self , endpoint_id : int , number_of_presses : int , pressed_position : int , feature_map : uint , multi_press_max : uint ):
87
84
command_dict = {"Name" : 'SimulateMultiPress' , "EndpointId" : endpoint_id ,
88
85
"ButtonId" : pressed_position , "MultiPressPressedTimeMillis" : 500 , "MultiPressReleasedTimeMillis" : 500 ,
@@ -94,6 +91,20 @@ def _send_long_press_named_pipe_command(self, endpoint_id: int, pressed_position
94
91
"ButtonId" : pressed_position , "LongPressDelayMillis" : 5000 , "LongPressDurationMillis" : 5500 , "FeatureMap" : feature_map }
95
92
self ._send_named_pipe_command (command_dict )
96
93
94
+ def _send_latching_switch_named_pipe_command (self , endpoint_id : int , new_position : int ):
95
+ command_dict = {"Name" : "SimulateLatchPosition" , "EndpointId" : endpoint_id , "PositionId" : new_position }
96
+ self ._send_named_pipe_command (command_dict )
97
+
98
+ def _ask_for_switch_idle (self ):
99
+ if not self ._use_button_simulator ():
100
+ self .wait_for_user_input (prompt_msg = "Ensure switch is idle" )
101
+
102
+ def _ask_for_switch_position (self , endpoint_id : int , new_position : int ):
103
+ if not self ._use_button_simulator ():
104
+ self .wait_for_user_input (prompt_msg = f"Move latched switch to position { new_position } , if it is not already there." )
105
+ else :
106
+ self ._send_latching_switch_named_pipe_command (endpoint_id , new_position )
107
+
97
108
def _ask_for_multi_press_short_long (self , endpoint_id : int , pressed_position : int , feature_map : uint , multi_press_max : uint ):
98
109
if not self ._use_button_simulator ():
99
110
msg = f"""
@@ -105,7 +116,8 @@ def _ask_for_multi_press_short_long(self, endpoint_id: int, pressed_position: in
105
116
self .wait_for_user_input (msg )
106
117
else :
107
118
# This is just a simulator, ignore the long press instruction for now, it doesn't matter for the CI. It does for cert.
108
- self ._send_multi_press_named_pipe_command (endpoint_id , 2 , pressed_position , feature_map , multi_press_max )
119
+ self ._send_multi_press_named_pipe_command (
120
+ endpoint_id , number_of_presses = 2 , pressed_position = pressed_position , feature_map = feature_map , multi_press_max = multi_press_max )
109
121
110
122
def _ask_for_multi_press_long_short (self , endpoint_id , pressed_position , feature_map : int ):
111
123
if not self ._use_button_simulator ():
@@ -153,7 +165,7 @@ def _ask_for_release(self):
153
165
time .sleep (self .keep_pressed_delay / 1000 )
154
166
155
167
def _placeholder_for_step (self , step_id : str ):
156
- # TODO: Global search an replace of `self._placeholder_for_step` with `self.step` when done.
168
+ # TODO(#34656) : Global search an replace of `self._placeholder_for_step` with `self.step` when done.
157
169
logging .info (f"Step { step_id } " )
158
170
pass
159
171
@@ -259,7 +271,7 @@ def _expect_no_events_for_cluster(self, event_queue: queue.Queue, endpoint_id: i
259
271
260
272
@per_endpoint_test (has_feature (Clusters .Switch , Clusters .Switch .Bitmaps .Feature .kMomentarySwitch ))
261
273
async def test_TC_SWTCH_2_4 (self ):
262
- # TODO: Make this come from PIXIT
274
+ # TODO(#34656) : Make this come from PIXIT
263
275
switch_pressed_position = 1
264
276
post_prompt_settle_delay_seconds = 10.0
265
277
@@ -361,6 +373,90 @@ def _received_event(self, event_listener: EventChangeCallback, target_event: Clu
361
373
remaining = end_time - datetime .now ()
362
374
return False
363
375
376
+ def steps_TC_SWTCH_2_2 (self ):
377
+ return [TestStep (1 , test_plan_support .commission_if_required (), "" , is_commissioning = True ),
378
+ TestStep (2 , "Set up subscription to all events of Switch cluster on the endpoint" ),
379
+ TestStep (3 , "Operator sets switch to first position on the DUT" ),
380
+ TestStep (4 , "TH reads the CurrentPosition attribute from the DUT" , "Verify that the value is 0" ),
381
+ TestStep (5 , "Operator sets switch to second position (one) on the DUT" ,
382
+ "Verify that the TH receives SwitchLatched event with NewPosition set to 1 from the DUT" ),
383
+ TestStep (6 , "TH reads the CurrentPosition attribute from the DUT" , "Verify that the value is 1" ),
384
+ TestStep (7 , "If there are more than 2 positions, test subsequent positions of the DUT" ),
385
+ TestStep (8 , "Operator sets switch to first position on the DUT." ),
386
+ TestStep (9 , "Wait 10 seconds for event reports stable." "Verify that last SwitchLatched event received is for NewPosition 0." ),
387
+ TestStep (10 , "TH reads the CurrentPosition attribute from the DUT" , "Verify that the value is 0" ),
388
+ ]
389
+
390
+ @per_endpoint_test (has_feature (Clusters .Switch , Clusters .Switch .Bitmaps .Feature .kLatchingSwitch ))
391
+ async def test_TC_SWTCH_2_2 (self ):
392
+ post_prompt_settle_delay_seconds = 10.0
393
+
394
+ # Step 1: Commissioning - already done
395
+ self .step (1 )
396
+
397
+ cluster = Clusters .Switch
398
+ endpoint_id = self .matter_test_config .endpoint
399
+
400
+ # Step 2: Set up subscription to all events of Switch cluster on the endpoint.
401
+ self .step (2 )
402
+ event_listener = EventChangeCallback (cluster )
403
+ await event_listener .start (self .default_controller , self .dut_node_id , endpoint = endpoint_id )
404
+
405
+ # Step 3: Operator sets switch to first position on the DUT.
406
+ self .step (3 )
407
+ self ._ask_for_switch_position (endpoint_id , new_position = 0 )
408
+ event_listener .flush_events ()
409
+
410
+ # Step 4: TH reads the CurrentPosition attribute from the DUT.
411
+ # Verify that the value is 0.
412
+ self .step (4 )
413
+ button_val = await self .read_single_attribute_check_success (cluster = cluster , attribute = cluster .Attributes .CurrentPosition )
414
+ asserts .assert_equal (button_val , 0 , "Switch position value is not 0" )
415
+
416
+ # Step 5: Operator sets switch to second position (one) on the DUT",
417
+ # Verify that the TH receives SwitchLatched event with NewPosition set to 1 from the DUT
418
+ self .step (5 )
419
+ expected_switch_position = 1
420
+ self ._ask_for_switch_position (endpoint_id , expected_switch_position )
421
+
422
+ data = event_listener .wait_for_event_report (cluster .Events .SwitchLatched , timeout_sec = post_prompt_settle_delay_seconds )
423
+ logging .info (f"-> SwitchLatched event last received: { data } " )
424
+ asserts .assert_equal (data , cluster .Events .SwitchLatched (
425
+ newPosition = expected_switch_position ), "Did not get expected switch position" )
426
+
427
+ # Step 6: TH reads the CurrentPosition attribute from the DUT", "Verify that the value is 1
428
+ self .step (6 )
429
+ button_val = await self .read_single_attribute_check_success (cluster = cluster , attribute = cluster .Attributes .CurrentPosition )
430
+ asserts .assert_equal (button_val , expected_switch_position , f"Switch position is not { expected_switch_position } " )
431
+
432
+ # Step 7: If there are more than 2 positions, test subsequent positions of the DUT
433
+ # # TODO(#34656): Implement loop for > 2 total positions
434
+ self .skip_step (7 )
435
+
436
+ # Step 8: Operator sets switch to first position on the DUT.
437
+ self .step (8 )
438
+ event_listener .flush_events ()
439
+ self ._ask_for_switch_position (endpoint_id , new_position = 0 )
440
+
441
+ # Step 9: Wait 10 seconds for event reports stable.
442
+ # Verify that last SwitchLatched event received is for NewPosition 0.
443
+ self .step (9 )
444
+ time .sleep (10.0 )
445
+
446
+ expected_switch_position = 0
447
+ last_event = event_listener .get_last_event ()
448
+ asserts .assert_is_not_none (last_event , "Did not get SwitchLatched events since last operator action." )
449
+ last_event_data = last_event .Data
450
+ logging .info (f"-> SwitchLatched event last received: { last_event_data } " )
451
+ asserts .assert_equal (last_event_data , cluster .Events .SwitchLatched (
452
+ newPosition = expected_switch_position ), "Did not get expected switch position" )
453
+
454
+ # Step 10: TH reads the CurrentPosition attribute from the DUT.
455
+ # Verify that the value is 0
456
+ self .step (10 )
457
+ button_val = await self .read_single_attribute_check_success (cluster = cluster , attribute = cluster .Attributes .CurrentPosition )
458
+ asserts .assert_equal (button_val , 0 , "Button value is not 0" )
459
+
364
460
def steps_TC_SWTCH_2_3 (self ):
365
461
return [TestStep (1 , test_plan_support .commission_if_required (), "" , is_commissioning = True ),
366
462
TestStep (2 , "Set up subscription to all events of Switch cluster on the endpoint" ),
0 commit comments