41
41
42
42
logger = logging .getLogger (__name__ )
43
43
44
+
44
45
class TC_SwitchTests (MatterBaseTest ):
45
46
def __init__ (self , * args , ** kwargs ):
46
47
super ().__init__ (* args , ** kwargs )
@@ -85,9 +86,11 @@ def _ask_for_switch_idle(self):
85
86
86
87
def _ask_for_long_press (self , endpoint_id : int , pressed_position : int ):
87
88
if not self ._use_button_simulator ():
88
- self .wait_for_user_input (prompt_msg = f"Press switch position { pressed_position } for a long time (around 5 seconds) on the DUT, then release it." )
89
+ self .wait_for_user_input (
90
+ prompt_msg = f"Press switch position { pressed_position } for a long time (around 5 seconds) on the DUT, then release it." )
89
91
else :
90
- command_dict = {"Name" : "SimulateActionSwitchLongPress" , "EndpointId" : endpoint_id , "ButtonId" : pressed_position , "LongPressDelayMillis" : 5000 , "LongPressDurationMillis" : 5500 }
92
+ command_dict = {"Name" : "SimulateActionSwitchLongPress" , "EndpointId" : endpoint_id ,
93
+ "ButtonId" : pressed_position , "LongPressDelayMillis" : 5000 , "LongPressDurationMillis" : 5500 }
91
94
self ._send_named_pipe_command (command_dict )
92
95
93
96
def _placeholder_for_step (self , step_id : str ):
@@ -120,7 +123,8 @@ def _await_sequence_of_reports(self, report_queue: queue.Queue, endpoint_id: int
120
123
logging .info (f"Got expected attribute change { sequence_idx + 1 } /{ len (sequence )} for attribute { attribute } " )
121
124
sequence_idx += 1
122
125
else :
123
- asserts .assert_equal (item .value , expected_value , msg = "Did not get expected attribute value in correct sequence." )
126
+ asserts .assert_equal (item .value , expected_value ,
127
+ msg = "Did not get expected attribute value in correct sequence." )
124
128
125
129
# We are done waiting when we have accumulated all results.
126
130
if sequence_idx == len (sequence ):
@@ -244,14 +248,17 @@ async def test_TC_SWTCH_2_4(self):
244
248
245
249
# Step 4b: TH expects report of CurrentPosition 1, followed by a report of Current Position 0.
246
250
self ._placeholder_for_step ("4b" )
247
- logging .info (f"Starting to wait for { post_prompt_settle_delay_seconds :.1f} seconds for CurrentPosition to go { switch_pressed_position } , then 0." )
248
- self ._await_sequence_of_reports (report_queue = attrib_listener .attribute_queue , endpoint_id = endpoint_id , attribute = cluster .Attributes .CurrentPosition , sequence = [switch_pressed_position , 0 ], timeout_sec = post_prompt_settle_delay_seconds )
251
+ logging .info (
252
+ f"Starting to wait for { post_prompt_settle_delay_seconds :.1f} seconds for CurrentPosition to go { switch_pressed_position } , then 0." )
253
+ self ._await_sequence_of_reports (report_queue = attrib_listener .attribute_queue , endpoint_id = endpoint_id , attribute = cluster .Attributes .CurrentPosition , sequence = [
254
+ switch_pressed_position , 0 ], timeout_sec = post_prompt_settle_delay_seconds )
249
255
250
256
# Step 4c: TH expects at least InitialPress with NewPosition = 1
251
257
self ._placeholder_for_step ("4c" )
252
258
logging .info (f"Starting to wait for { post_prompt_settle_delay_seconds :.1f} seconds for InitialPress event." )
253
259
expected_events = [cluster .Events .InitialPress (newPosition = switch_pressed_position )]
254
- self ._await_sequence_of_events (event_queue = event_listener .event_queue , endpoint_id = endpoint_id , sequence = expected_events , timeout_sec = post_prompt_settle_delay_seconds )
260
+ self ._await_sequence_of_events (event_queue = event_listener .event_queue , endpoint_id = endpoint_id ,
261
+ sequence = expected_events , timeout_sec = post_prompt_settle_delay_seconds )
255
262
256
263
# Step 4d: For MSL/AS, expect to see LongPress/LongRelease in that order
257
264
if not has_msl_feature and not has_as_feature :
@@ -264,18 +271,21 @@ async def test_TC_SWTCH_2_4(self):
264
271
expected_events = []
265
272
expected_events .append (cluster .Events .LongPress (newPosition = switch_pressed_position ))
266
273
expected_events .append (cluster .Events .LongRelease (previousPosition = switch_pressed_position ))
267
- self ._await_sequence_of_events (event_queue = event_listener .event_queue , endpoint_id = endpoint_id , sequence = expected_events , timeout_sec = post_prompt_settle_delay_seconds )
274
+ self ._await_sequence_of_events (event_queue = event_listener .event_queue , endpoint_id = endpoint_id ,
275
+ sequence = expected_events , timeout_sec = post_prompt_settle_delay_seconds )
268
276
269
277
# Step 4e: For MS & (!MSL & !AS & !MSR), expect no further events for 10 seconds.
270
278
if not has_msl_feature and not has_as_feature and not has_msr_feature :
271
279
self ._placeholder_for_step ("4e" )
272
- self ._expect_no_events_for_cluster (event_queue = event_listener .event_queue , endpoint_id = endpoint_id , expected_cluster = cluster , timeout_sec = 10.0 )
280
+ self ._expect_no_events_for_cluster (event_queue = event_listener .event_queue ,
281
+ endpoint_id = endpoint_id , expected_cluster = cluster , timeout_sec = 10.0 )
273
282
274
283
# Step 4f: For MSR & not MSL, expect to see ShortRelease.
275
284
if not has_msl_feature and has_msr_feature :
276
285
self ._placeholder_for_step ("4f" )
277
286
expected_events = [cluster .Events .ShortRelease (previousPosition = switch_pressed_position )]
278
- self ._await_sequence_of_events (event_queue = event_listener .event_queue , endpoint_id = endpoint_id , sequence = expected_events , timeout_sec = post_prompt_settle_delay_seconds )
287
+ self ._await_sequence_of_events (event_queue = event_listener .event_queue , endpoint_id = endpoint_id ,
288
+ sequence = expected_events , timeout_sec = post_prompt_settle_delay_seconds )
279
289
280
290
281
291
if __name__ == "__main__" :
0 commit comments