18
18
import logging
19
19
20
20
import chip .clusters as Clusters
21
- from matter_testing_support import MatterBaseTest , async_test_body , default_matter_test_main , type_matches
21
+ from matter_testing_support import MatterBaseTest , TestStep , async_test_body , default_matter_test_main
22
22
from mobly import asserts
23
23
24
24
@@ -34,6 +34,34 @@ async def send_change_to_mode_cmd(self, newMode) -> Clusters.Objects.DishwasherM
34
34
"Unexpected return type for ChangeToMode" )
35
35
return ret
36
36
37
+ def desc_TC_DISHM_2_1 (self ) -> str :
38
+ return "[TC-DISHM-2.1] Change to Mode functionality with DUT as Server"
39
+
40
+ def steps_TC_DISHM_2_1 (self ) -> list [TestStep ]:
41
+ steps = [
42
+ TestStep (1 , "Commissioning, already done" , is_commissioning = True ),
43
+ TestStep (2 , "TH reads from the DUT the SupportedModes attribute." ),
44
+ TestStep (3 , "TH reads from the DUT the CurrentMode attribute." ),
45
+ TestStep (4 , "TH sends a ChangeToMode command to the DUT with NewMode set to old_current_mode_dut" ),
46
+ TestStep (5 , "Manually put the device in a state from which it will FAIL to transition to PIXIT.DISHM.MODE_CHANGE_FAIL" ),
47
+ TestStep (6 , "TH reads from the DUT the CurrentMode attribute." ),
48
+ TestStep (7 , "TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.DISHM.MODE_CHANGE_FAIL" ),
49
+ TestStep (8 , "TH reads from the DUT the CurrentMode attribute." ),
50
+ TestStep (9 , "Manually put the device in a state from which it will SUCCESSFULLY transition to PIXIT.DISHM.MODE_CHANGE_OK" ),
51
+ TestStep (10 , "TH reads from the DUT the CurrentMode attribute." ),
52
+ TestStep (11 , "TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.DISHM.MODE_CHANGE_OK" ),
53
+ TestStep (12 , "TH reads from the DUT the CurrentMode attribute." ),
54
+ TestStep (13 , "TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th" ),
55
+ TestStep (14 , "TH reads from the DUT the CurrentMode attribute." ),
56
+ ]
57
+ return steps
58
+
59
+ def pics_TC_DISHM_2_1 (self ) -> list [str ]:
60
+ pics = [
61
+ "DISHM.S" ,
62
+ ]
63
+ return pics
64
+
37
65
@async_test_body
38
66
async def test_TC_DISHM_2_1 (self ):
39
67
@@ -57,23 +85,23 @@ async def test_TC_DISHM_2_1(self):
57
85
58
86
attributes = Clusters .DishwasherMode .Attributes
59
87
60
- self .print_step ( 1 , "Commissioning, already done" )
88
+ self .step ( 1 )
61
89
62
- self .print_step (2 , "Read SupportedModes attribute" )
90
+ self .step (2 )
91
+ # read the supported modes
63
92
supported_modes = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .SupportedModes )
64
-
65
93
logging .info ("SupportedModes: %s" % (supported_modes ))
66
-
94
+ # need at least 2 modes
67
95
asserts .assert_greater_equal (len (supported_modes ), 2 , "SupportedModes must have at least two entries!" )
68
-
96
+ # save them
69
97
supported_modes_dut = [m .mode for m in supported_modes ]
98
+ # check that mode change fail is present
99
+ asserts .assert_true (self .modeFail in supported_modes_dut , "SupportedModes must include MODE_CHANGE_FAIL" )
70
100
71
- self .print_step ( 3 , "Read CurrentMode attribute" )
72
-
101
+ self .step ( 3 )
102
+ # Read the current mode
73
103
old_current_mode_dut = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .CurrentMode )
74
-
75
104
logging .info ("CurrentMode: %s" % (old_current_mode_dut ))
76
-
77
105
# pick a value that's not in the list of supported modes
78
106
invalid_mode_th = max (supported_modes_dut ) + 1
79
107
@@ -85,73 +113,71 @@ class CommonCodes(Enum):
85
113
GENERIC_FAILURE = 0x02
86
114
INVALID_IN_MODE = 0x03
87
115
88
- self .print_step ( 4 , "Send ChangeToMode command with NewMode set to %d" % ( old_current_mode_dut ) )
89
-
116
+ self .step ( 4 )
117
+ logging . info ( "Send ChangeToMode command with NewMode set to %d" % ( old_current_mode_dut ))
90
118
ret = await self .send_change_to_mode_cmd (newMode = old_current_mode_dut )
91
119
asserts .assert_true (ret .status == CommonCodes .SUCCESS .value , "Changing the mode to the current mode should be a no-op" )
92
120
93
121
if self .check_pics ("DISHM.S.M.CAN_TEST_MODE_FAILURE" ):
94
- self .print_step (5 , "Manually put the device in a state from which it will FAIL to transition to mode %d" % (self .modeFail ))
122
+ self .step (5 )
123
+ logging .info ("Manually put the device in a state from which it will FAIL to transition to mode %d" % (self .modeFail ))
95
124
input ("Press Enter when done.\n " )
96
125
97
- self .print_step ( 6 , "Read CurrentMode attribute" )
126
+ self .step ( 6 )
98
127
old_current_mode_dut = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .CurrentMode )
99
-
100
128
logging .info ("CurrentMode: %s" % (old_current_mode_dut ))
101
129
102
- self .print_step (7 , "Send ChangeToMode command with NewMode set to %d" % (self .modeFail ))
130
+ self .step (7 )
131
+ logging .info ("Send ChangeToMode command with NewMode set to %d" % (self .modeFail ))
103
132
104
133
ret = await self .send_change_to_mode_cmd (newMode = self .modeFail )
105
134
st = ret .status
106
135
logging .info ("ChangeToMode Status: %s" % (ret .status ))
107
- is_mfg_code = st in range (0x80 , 0xC0 )
136
+ is_mfg_code = st in range (0x80 , 0xBF )
108
137
is_err_code = (st == CommonCodes .GENERIC_FAILURE .value ) or (st == CommonCodes .INVALID_IN_MODE .value ) or is_mfg_code
109
138
asserts .assert_true (
110
139
is_err_code , "Changing to mode %d must fail due to the current state of the device" % (self .modeFail ))
111
140
logging .info ("Status Text: %s" % (ret .statusText ))
112
141
st_text_len = len (ret .statusText )
113
142
asserts .assert_true (st_text_len in range (1 , 65 ), "StatusText length (%d) must be between 1 and 64" % (st_text_len ))
114
143
115
- self .print_step ( 8 , "Read CurrentMode attribute" )
144
+ self .step ( 8 )
116
145
current_mode = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .CurrentMode )
117
-
118
146
logging .info ("CurrentMode: %s" % (current_mode ))
119
-
120
147
asserts .assert_true (current_mode == old_current_mode_dut , "CurrentMode changed after failed ChangeToMode command!" )
148
+ else :
149
+ for x in range (5 , 9 ):
150
+ self .skip (x )
121
151
122
- self .print_step (9 , "Manually put the device in a state from which it will SUCCESSFULLY transition to mode %d" % (self .modeOk ))
152
+ self .step (9 )
153
+ logging .info ("Manually put the device in a state from which it will SUCCESSFULLY transition to mode %d" % (self .modeOk ))
123
154
input ("Press Enter when done.\n " )
124
155
125
- self .print_step (10 , "Read CurrentMode attribute" )
156
+ self .step (10 )
126
157
old_current_mode_dut = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .CurrentMode )
127
-
128
158
logging .info ("CurrentMode: %s" % (old_current_mode_dut ))
129
159
130
- self .print_step (11 , "Send ChangeToMode command with NewMode set to %d" % ( self . modeOk ) )
131
-
160
+ self .step (11 )
161
+ logging . info ( "Send ChangeToMode command with NewMode set to %d" % ( self . modeOk ))
132
162
ret = await self .send_change_to_mode_cmd (newMode = self .modeOk )
133
163
asserts .assert_true (ret .status == CommonCodes .SUCCESS .value ,
134
164
"Changing to mode %d must succeed due to the current state of the device" % (self .modeOk ))
135
165
136
- self .print_step (12 , "Read CurrentMode attribute" )
166
+ self .step (12 )
137
167
current_mode = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .CurrentMode )
138
-
139
168
logging .info ("CurrentMode: %s" % (current_mode ))
140
-
141
169
asserts .assert_true (current_mode == self .modeOk ,
142
170
"CurrentMode doesn't match the argument of the successful ChangeToMode command!" )
143
171
144
- self .print_step (13 , "Send ChangeToMode command with NewMode set to %d" % ( invalid_mode_th ) )
145
-
172
+ self .step (13 )
173
+ logging . info ( "Send ChangeToMode command with NewMode set to %d" % ( invalid_mode_th ))
146
174
ret = await self .send_change_to_mode_cmd (newMode = invalid_mode_th )
147
175
asserts .assert_true (ret .status == CommonCodes .UNSUPPORTED_MODE .value ,
148
176
"Attempt to change to invalid mode %d didn't fail as expected" % (invalid_mode_th ))
149
177
150
- self .print_step (14 , "Read CurrentMode attribute" )
178
+ self .step (14 )
151
179
current_mode = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .CurrentMode )
152
-
153
180
logging .info ("CurrentMode: %s" % (current_mode ))
154
-
155
181
asserts .assert_true (current_mode == self .modeOk , "CurrentMode changed after failed ChangeToMode command!" )
156
182
157
183
0 commit comments