Skip to content

Commit 6b93a30

Browse files
authoredSep 4, 2024··
Update TC-CC-2_2 to match latest test plan (#35361)
* Update TC-CC-2_2 to match latest test plan * Remove unused import
1 parent 9533925 commit 6b93a30

File tree

1 file changed

+151
-108
lines changed

1 file changed

+151
-108
lines changed
 

‎src/python_testing/TC_CC_2_2.py

+151-108
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from matter_testing_support import (ClusterAttributeChangeAccumulator, MatterBaseTest, TestStep, default_matter_test_main,
3636
has_cluster, run_if_endpoint_matches)
3737
from mobly import asserts
38-
from test_plan_support import commission_if_required, if_feature_supported, read_attribute, verify_success
38+
from test_plan_support import commission_if_required, read_attribute, verify_success
3939

4040

4141
class TC_CC_2_3(MatterBaseTest):
@@ -48,62 +48,80 @@ def default_timeout(self) -> int:
4848
def steps_TC_CC_2_2(self):
4949
THcommand = "Test Harness sends the"
5050

51-
def store_values(attr: str) -> str:
52-
return f"TH stores the reported values of _{attr}_ in all incoming reports for _{attr}_ attribute, that contains data in _reportedCurrentHueValuesList_, over a period of 20 seconds."
51+
def store_values(reportList: str, attr: str) -> str:
52+
return f"TH stores the reported values of _{attr}_ in all incoming reports for _{attr}_ attribute, that contains data in _{reportList}_, over a period of 20 seconds."
5353

54-
def verify_entry_count(attr: str) -> str:
55-
return f'TH verifies that _reportedCurrentHueValuesList_ does not contain more than 10 entries for _{attr}_'
54+
def verify_entry_count(reportList: str, attr: str) -> str:
55+
return f'TH verifies that _{reportList}_ does not contain more than 12 entries for _{attr}_'
5656

57-
def entry_count_verification() -> str:
58-
return '_reportedCurrentHueValuesList_ has 10 or less entries in the list'
57+
def entry_count_verification(reportList: str) -> str:
58+
return f'_{reportList}_ has 12 or less entries in the list'
5959

6060
return [TestStep(1, commission_if_required(), is_commissioning=True),
6161
TestStep(2, read_attribute('FeatureMap')),
6262
TestStep(3, read_attribute('AttributeList')),
6363
TestStep(4, read_attribute('ServerList', 'Descriptor')),
6464
TestStep(
6565
5, f"If OnOff cluster is present in _ServerList_, {THcommand} On command on OnOff cluster", verify_success()),
66-
TestStep(
67-
6, f'{if_feature_supported("HS")}, {THcommand} MoveHue with _MoveMode_ field set to Down, _Rate_ field set to 255 and remaining fields set to 0', verify_success()),
68-
TestStep(7, f'{if_feature_supported("HS")}, {THcommand} MoveSaturation with _MoveMode_ field set to Down, _Rate_ field set to 255 and remaining fields set to 0', verify_success()),
69-
TestStep(8, 'Set up a subscription wildcard subscription for the Color Control Cluster, with MinIntervalFloor set to 0, MaxIntervalCeiling set to 30 and KeepSubscriptions set to false',
66+
TestStep(6, 'Set up a subscription wildcard subscription for the Color Control Cluster, with MinIntervalFloor set to 0, MaxIntervalCeiling set to 30 and KeepSubscriptions set to false',
7067
'Subscription successfully established'),
71-
TestStep(9, 'If the HS feature is not supported, skip step 10 to 15'),
72-
TestStep(10, f'{THcommand} MoveToHue with _Hue_ field set to 254, _TransitionTime_ field set to 100, _Direction_ field set to Shortest and remaining fields set to 0', verify_success()),
73-
TestStep(11, store_values('CurrentHue')),
74-
TestStep(12, verify_entry_count('CurrentHue'), entry_count_verification()),
68+
TestStep(7, 'If the CT feature is not supported, skip step 8 to 12'),
69+
TestStep(
70+
8, f'{THcommand} MoveColorTemperature with _MoveMode_ field set to Down, _Rate_ field set to 65535 and remaining fields set to 0', verify_success()),
71+
TestStep(
72+
9, 'TH reads from the DUT the ColorTempPhysicalMaxMireds and stores the returned value as colorTempPhysicalMaxMireds', verify_success()),
73+
TestStep(10, f'{THcommand} MoveToColorTemperature with ColorTemperatureMireds field set to the value of colorTempPhysicalMaxMireds, TransitionTime field set to 100, remaining fields set to 0', verify_success()),
74+
TestStep(11, store_values('reportedColorTemperatureMiredsValuesList', 'ColorTemperatureMireds')),
75+
TestStep(12, verify_entry_count('reportedColorTemperatureMiredsValuesList', 'ColorTemperatureMireds'),
76+
entry_count_verification('reportedColorTemperatureMiredsValuesList')),
77+
TestStep(13, 'If the HS feature is not supported, skip step 14 to 21'),
78+
TestStep(
79+
14, f'{THcommand} MoveHue with _MoveMode_ field set to Down, _Rate_ field set to 255 and remaining fields set to 0', verify_success()),
80+
TestStep(
81+
15, f'{THcommand} MoveSaturation with _MoveMode_ field set to Down, _Rate_ field set to 255 and remaining fields set to 0', verify_success()),
82+
TestStep(16, f'{THcommand} MoveToHue with _Hue_ field set to 254, _TransitionTime_ field set to 100, _Direction_ field set to Shortest and remaining fields set to 0', verify_success()),
83+
TestStep(17, store_values('reportedCurrentHueValuesList', 'CurrentHue')),
84+
TestStep(18, verify_entry_count('reportedCurrentHueValuesList', 'CurrentHue'),
85+
entry_count_verification('reportedCurrentHueValuesList')),
86+
TestStep(
87+
19, f"{THcommand} MoveToSaturation with _Saturation_ field set to 254, _TransitionTime_ field set to 100 and remaining fields set to 0"),
88+
TestStep(20, store_values('reportedCurrentSaturationValuesList', 'CurrentSaturation')),
89+
TestStep(21, verify_entry_count('reportedCurrentSaturationValuesList',
90+
'CurrentSaturation'), entry_count_verification('reportedCurrentSaturationValuesList')),
91+
TestStep(22, 'If XY feature is not supported, skip steps 23-28'),
92+
TestStep(
93+
23, f"{THcommand} MoveToColor with _ColorX_ field set to 32768, _ColorY_ set to 19660, _TransitionTime_ field set to 0 and remaining fields set to 0"),
7594
TestStep(
76-
13, f"{THcommand} MoveToSaturation with _Saturation_ field set to 254, _TransitionTime_ field set to 100 and remaining fields set to 0"),
77-
TestStep(14, store_values('CurrentSaturation')),
78-
TestStep(15, verify_entry_count('CurrentSaturation'), entry_count_verification()),
79-
TestStep(16, 'If XY feature is not supported, skip steps 17-21'),
95+
24, f"{THcommand} MoveToColor with _ColorX_ field set to 13107, _ColorY_ set to 13107, _TransitionTime_ field set to 100 and remaining fields set to 0"),
96+
TestStep(25, store_values('reportedCurrentXValuesList', 'CurrentX')),
97+
TestStep(26, store_values('reportedCurrentYValuesList', 'CurrentY')),
98+
TestStep(27, verify_entry_count('reportedCurrentXValuesList', 'CurrentX'),
99+
entry_count_verification('reportedCurrentXValuesList')),
100+
TestStep(28, verify_entry_count('reportedCurrentYValuesList', 'CurrentY'),
101+
entry_count_verification('reportedCurrentYValuesList')),
102+
TestStep(29, "If the EHUE feature is not supported, skip steps 30 to 32"),
103+
TestStep(30, f"{THcommand} EnhancedMoveToHue with _EnhancedHue_ field set to 0, _TransitionTime_ field set to 100, _Direction_ field set to Shortest and remaining fields set to 0", verify_success()),
104+
TestStep(31, store_values('reportedEnhancedCurrentHueValuesList', 'EnhancedCurrentHue')),
105+
TestStep(32, verify_entry_count('reportedEnhancedCurrentHueValuesList',
106+
'EnhancedCurrentHue'), entry_count_verification('reportedEnhancedCurrentHueValuesList')),
80107
TestStep(
81-
"17a", f"{THcommand} MoveToColor with _ColorX_ field set to 32768, _ColorY_ set to 19660, _TransitionTime_ field set to 0 and remaining fields set to 0"),
108+
33, 'If the RemainingTime attribute is not supported or the CT feature is not supported, skip the remaining steps and end test case'),
82109
TestStep(
83-
"17b", f"{THcommand} MoveToColor with _ColorX_ field set to 13107, _ColorY_ set to 13107, _TransitionTime_ field set to 100 and remaining fields set to 0"),
84-
TestStep(18, store_values('CurrentX')),
85-
TestStep(19, store_values('CurrentY')),
86-
TestStep(20, verify_entry_count('CurrentX'), entry_count_verification()),
87-
TestStep(21, verify_entry_count('CurrentY'), entry_count_verification()),
88-
TestStep(22, "If the EHUE feature is not supported, skip steps 23 to 25"),
89-
TestStep(23, f"{THcommand} EnhancedMoveToHue with _EnhancedHue_ field set to 0, _TransitionTime_ field set to 100, _Direction_ field set to Shortest and remaining fields set to 0", verify_success()),
90-
TestStep(24, store_values('EnhancedCurrentHue')),
91-
TestStep(25, verify_entry_count('EnhancedCurrentHue'), entry_count_verification()),
92-
TestStep(26, "If the RemainingTime attribute is not supported, skip the remaining steps and end test case"),
93-
TestStep(27, store_values('RemainingTime')),
110+
34, f'{THcommand} MoveColorTemperature with MoveMode field set to Down, Rate field set to 65535 and remaining fields set to 0', verify_success()),
111+
TestStep(35, 'TH stores the reported values of RemainingTime in all incoming reports for RemainingTime attribute, for steps 36 to 39 that contains data in reportedRemainingTimeValuesList.'),
94112
TestStep(
95-
29, f"If the XY feature is supported and the HS feature is not supported, {THcommand} MoveToColor with _ColorX_ field set to 32768, _ColorY_ set to 19660, _TransitionTime_ field set to 100 and remaining fields set to 0", verify_success()),
96-
TestStep(30, "Wait for 5 seconds"),
113+
36, f'{THcommand} MoveToColorTemperature with ColorTemperatureMireds field set to the value of colorTempPhysicalMaxMireds / 2, TransitionTime field set to 100, remaining fields set to 0', verify_success()),
114+
TestStep(37, "Wait for 5 seconds"),
97115
TestStep(
98-
32, f"If the XY feature is supported and the HS feature is not supported, {THcommand} MoveToColor with _ColorX_ field set to 13107, _ColorY_ set to 13107, _TransitionTime_ field set to 150 and remaining fields set to 0", verify_success()),
99-
TestStep(33, "Wait for 20 seconds"),
100-
TestStep(34, "TH verifies _reportedRemainingTimeValuesList_ contains three entries",
116+
38, f'{THcommand} MoveToColorTemperature with ColorTemperatureMireds field set to the value of colorTempPhysicalMaxMireds, TransitionTime field set to 150, remaining fields set to 0', verify_success()),
117+
TestStep(39, "Wait for 20 seconds"),
118+
TestStep(40, "TH verifies _reportedRemainingTimeValuesList_ contains three entries",
101119
"_reportedRemainingTimeValuesList_ has 3 entries in the list"),
102-
TestStep(35, "TH verifies the first entry in _reportedRemainingTimeValuesList_ is 100",
103-
"The first entry in _reportedRemainingTimeValuesList_ is equal to 100"),
104-
TestStep(36, "TH verifies the second entry in _reportedRemainingTimeValuesList_ is approximately 150",
105-
"The second entry in _reportedRemainingTimeValuesList_ is approximately equal to 150"),
106-
TestStep(37, "TH verifies the third entry in _reportedRemainingTimeValuesList_ is 0",
120+
TestStep(41, "TH verifies the first entry in _reportedRemainingTimeValuesList_ is 100",
121+
"The first entry in reportedRemainingTimeValuesList is in the range of 95 to 100"),
122+
TestStep(42, "TH verifies the second entry in _reportedRemainingTimeValuesList_ is approximately 150",
123+
"The second entry in reportedRemainingTimeValuesList is in the range of 145 to 150"),
124+
TestStep(43, "TH verifies the third entry in _reportedRemainingTimeValuesList_ is 0",
107125
"The third entry in _reportedRemainingTimeValuesList_ is equal to 0")
108126
]
109127

@@ -118,6 +136,7 @@ async def test_TC_CC_2_2(self):
118136

119137
self.step(2)
120138
feature_map = await self.read_single_attribute_check_success(cluster=cc, attribute=cc.Attributes.FeatureMap)
139+
supports_ct = (feature_map & cc.Bitmaps.Feature.kColorTemperature) != 0
121140
supports_hs = (feature_map & cc.Bitmaps.Feature.kHueAndSaturation) != 0
122141
supports_xy = (feature_map & cc.Bitmaps.Feature.kXy) != 0
123142
supports_ehue = (feature_map & cc.Bitmaps.Feature.kEnhancedHue) != 0
@@ -136,20 +155,6 @@ async def test_TC_CC_2_2(self):
136155
self.mark_current_step_skipped()
137156

138157
self.step(6)
139-
if supports_hs:
140-
cmd = cc.Commands.MoveHue(moveMode=cc.Enums.MoveModeEnum.kDown, rate=225)
141-
await self.send_single_cmd(cmd)
142-
else:
143-
self.mark_current_step_skipped()
144-
145-
self.step(7)
146-
if supports_hs:
147-
cmd = cc.Commands.MoveSaturation(moveMode=cc.Enums.MoveModeEnum.kDown, rate=225)
148-
await self.send_single_cmd(cmd)
149-
else:
150-
self.mark_current_step_skipped()
151-
152-
self.step(8)
153158
sub_handler = ClusterAttributeChangeAccumulator(cc)
154159
await sub_handler.start(self.default_controller, self.dut_node_id, self.matter_test_config.endpoint)
155160

@@ -163,124 +168,162 @@ def check_report_counts(attr: ClusterObjects.ClusterAttributeDescriptor):
163168
asserts.assert_less_equal(count, 12, "More than 12 reports received")
164169
asserts.assert_less_equal(count, gather_time, f"More than {gather_time} reports received")
165170

166-
self.step(9)
167-
if not supports_hs:
171+
self.step(7)
172+
if not supports_ct:
173+
self.skip_step(8)
174+
self.skip_step(9)
168175
self.skip_step(10)
169176
self.skip_step(11)
170177
self.skip_step(12)
171-
self.skip_step(13)
172-
self.skip_step(14)
173-
self.skip_step(15)
174178
else:
179+
self.step(8)
180+
cmd = cc.Commands.MoveColorTemperature(moveMode=cc.Enums.MoveModeEnum.kDown, rate=65535)
181+
await self.send_single_cmd(cmd)
182+
183+
self.step(9)
184+
colorTempPhysicalMaxMireds = await self.read_single_attribute_check_success(cluster=cc, attribute=cc.Attributes.ColorTempPhysicalMaxMireds)
185+
175186
self.step(10)
176-
cmd = cc.Commands.MoveToHue(hue=254, transitionTime=100, direction=cc.Enums.DirectionEnum.kShortest)
187+
cmd = cc.Commands.MoveToColorTemperature(colorTemperatureMireds=colorTempPhysicalMaxMireds, transitionTime=100)
177188
await self.send_single_cmd(cmd)
178189

179190
self.step(11)
180191
accumulate_reports()
181192

182193
self.step(12)
194+
check_report_counts(cc.Attributes.ColorTemperatureMireds)
195+
196+
self.step(13)
197+
if not supports_hs:
198+
self.skip_step(14)
199+
self.skip_step(15)
200+
self.skip_step(16)
201+
self.skip_step(17)
202+
self.skip_step(18)
203+
self.skip_step(19)
204+
self.skip_step(20)
205+
self.skip_step(21)
206+
else:
207+
self.step(14)
208+
cmd = cc.Commands.MoveHue(moveMode=cc.Enums.MoveModeEnum.kDown, rate=225)
209+
await self.send_single_cmd(cmd)
210+
211+
self.step(15)
212+
cmd = cc.Commands.MoveSaturation(moveMode=cc.Enums.MoveModeEnum.kDown, rate=225)
213+
await self.send_single_cmd(cmd)
214+
215+
self.step(16)
216+
cmd = cc.Commands.MoveToHue(hue=254, transitionTime=100, direction=cc.Enums.DirectionEnum.kShortest)
217+
await self.send_single_cmd(cmd)
218+
219+
self.step(17)
220+
accumulate_reports()
221+
222+
self.step(18)
183223
check_report_counts(cc.Attributes.CurrentHue)
184224

185-
self.step(13)
225+
self.step(19)
186226
cmd = cc.Commands.MoveToSaturation(saturation=254, transitionTime=100)
187227
await self.send_single_cmd(cmd)
188228

189-
self.step(14)
229+
self.step(20)
190230
accumulate_reports()
191231

192-
self.step(15)
232+
self.step(21)
193233
check_report_counts(cc.Attributes.CurrentSaturation)
194234

195-
self.step(16)
235+
self.step(22)
196236
if not supports_xy:
197-
self.skip_step(17)
198-
self.skip_step(18)
199-
self.skip_step(19)
200-
self.skip_step(20)
201-
self.skip_step(21)
237+
self.skip_step(23)
238+
self.skip_step(24)
239+
self.skip_step(25)
240+
self.skip_step(26)
241+
self.skip_step(27)
242+
self.skip_step(28)
202243
else:
203-
self.step("17a")
244+
self.step(23)
204245
cmd = cc.Commands.MoveToColor(colorX=32768, colorY=19660, transitionTime=0)
205246
await self.send_single_cmd(cmd)
206247

207-
self.step("17b")
208-
cmd = cc.Commands.MoveToColor(colorX=13107, colorY=13107, transitionTime=0)
248+
self.step(24)
249+
cmd = cc.Commands.MoveToColor(colorX=13107, colorY=13107, transitionTime=100)
209250
await self.send_single_cmd(cmd)
210251

211-
self.step(18)
252+
self.step(25)
212253
accumulate_reports()
213254

214-
self.step(19)
255+
self.step(26)
215256
# reports for x and y are both accumulated in a dict - done above
216257

217-
self.step(20)
258+
self.step(27)
218259
check_report_counts(cc.Attributes.CurrentX)
219260

220-
self.step(21)
261+
self.step(28)
221262
check_report_counts(cc.Attributes.CurrentY)
222263

223-
self.step(22)
264+
self.step(29)
224265
if not supports_ehue:
225-
self.skip_step(23)
226-
self.skip_step(24)
227-
self.skip_step(25)
266+
self.skip_step(30)
267+
self.skip_step(31)
268+
self.skip_step(32)
228269
else:
229-
self.step(23)
270+
self.step(30)
230271
cmd = cc.Commands.EnhancedMoveToHue(enhancedHue=0, transitionTime=100,
231272
direction=cc.Enums.DirectionEnum.kShortest)
232273
await self.send_single_cmd(cmd)
233274

234-
self.step(24)
275+
self.step(31)
235276
accumulate_reports()
236277

237-
self.step(25)
278+
self.step(32)
238279
check_report_counts(cc.Attributes.EnhancedCurrentHue)
239280

240-
self.step(26)
241-
if cc.Attributes.RemainingTime.attribute_id not in attribute_list:
242-
self.skip_all_remaining_steps(27)
281+
self.step(33)
282+
if cc.Attributes.RemainingTime.attribute_id not in attribute_list or not supports_ct:
283+
self.skip_all_remaining_steps(34)
243284
return
244285

245-
self.step(27)
286+
self.step(34)
287+
cmd = cc.Commands.MoveColorTemperature(moveMode=cc.Enums.MoveModeEnum.kDown, rate=65535)
288+
await self.send_single_cmd(cmd)
289+
290+
self.step(35)
246291
accumulate_reports()
247292

248-
self.step(29)
249-
# TODO: If this is mandatory, we should just omit this
250-
if supports_xy:
251-
cmd = cc.Commands.MoveToColor(colorX=32768, colorY=19660, transitionTime=100)
252-
await self.send_single_cmd(cmd)
253-
else:
254-
self.mark_current_step_skipped()
293+
self.step(36)
294+
cmd = cc.Commands.MoveToColorTemperature(colorTemperatureMireds=colorTempPhysicalMaxMireds/2, transitionTime=100)
295+
await self.send_single_cmd(cmd)
255296

256-
self.step(30)
297+
self.step(37)
257298
logging.info("Test will now wait for 5 seconds")
258299
time.sleep(5)
259300

260-
self.step(32)
261-
if supports_xy:
262-
cmd = cc.Commands.MoveToColor(colorX=13107, colorY=13107, transitionTime=150)
263-
await self.send_single_cmd(cmd)
264-
else:
265-
self.mark_current_step_skipped()
301+
self.step(38)
302+
cmd = cc.Commands.MoveToColorTemperature(colorTemperatureMireds=colorTempPhysicalMaxMireds, transitionTime=150)
303+
await self.send_single_cmd(cmd)
266304

267-
self.step(33)
305+
self.step(39)
268306
logging.info("Test will now wait for 20 seconds")
269307
time.sleep(20)
270308

271-
self.step(34)
309+
self.step(40)
272310
logging.info(f'received reports: {sub_handler.attribute_reports[cc.Attributes.RemainingTime]}')
273311
count = sub_handler.attribute_report_counts[cc.Attributes.RemainingTime]
274312
asserts.assert_equal(count, 3, "Unexpected number of reports received")
275313

276-
self.step(35)
277-
asserts.assert_equal(sub_handler.attribute_reports[cc.Attributes.RemainingTime][0].value, 100, "Unexpected first report")
314+
self.step(41)
315+
asserts.assert_less_equal(
316+
sub_handler.attribute_reports[cc.Attributes.RemainingTime][0].value, 100, "Unexpected first report")
317+
asserts.assert_almost_equal(
318+
sub_handler.attribute_reports[cc.Attributes.RemainingTime][0].value, 100, delta=10, msg="Unexpected first report")
278319

279-
self.step(36)
320+
self.step(42)
321+
asserts.assert_less_equal(
322+
sub_handler.attribute_reports[cc.Attributes.RemainingTime][1].value, 150, "Unexpected second report")
280323
asserts.assert_almost_equal(
281324
sub_handler.attribute_reports[cc.Attributes.RemainingTime][1].value, 150, delta=10, msg="Unexpected second report")
282325

283-
self.step(37)
326+
self.step(43)
284327
asserts.assert_equal(sub_handler.attribute_reports[cc.Attributes.RemainingTime][-1].value, 0, "Unexpected last report")
285328

286329

0 commit comments

Comments
 (0)
Please sign in to comment.