Skip to content

Commit 10d653d

Browse files
[OO] Scenes Integration Tests (#34447)
* Added test for scenes integration in onoff cluster * Made onoff and scenes behaviors independant in scenes interaction * Added the test to the CI
1 parent 20c251b commit 10d653d

File tree

4 files changed

+280
-20
lines changed

4 files changed

+280
-20
lines changed

src/app/clusters/level-control/level-control.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,9 @@ class DefaultLevelControlSceneHandler : public scenes::DefaultSceneHandlerImpl
256256

257257
if (!NumericAttributeTraits<uint8_t>::IsNullValue(level))
258258
{
259-
CommandId command = LevelControlHasFeature(endpoint, LevelControl::Feature::kOnOff) ? Commands::MoveToLevelWithOnOff::Id
260-
: Commands::MoveToLevel::Id;
261-
262-
moveToLevelHandler(endpoint, command, level, DataModel::MakeNullable(static_cast<uint16_t>(timeMs / 100)),
263-
chip::Optional<BitMask<OptionsBitmap>>(), chip::Optional<BitMask<OptionsBitmap>>(),
264-
INVALID_STORED_LEVEL);
259+
moveToLevelHandler(
260+
endpoint, Commands::MoveToLevel::Id, level, DataModel::MakeNullable(static_cast<uint16_t>(timeMs / 100)),
261+
chip::Optional<BitMask<OptionsBitmap>>(1), chip::Optional<BitMask<OptionsBitmap>>(1), INVALID_STORED_LEVEL);
265262
}
266263

267264
return CHIP_NO_ERROR;

src/app/clusters/on-off-server/on-off-server.cpp

+2-13
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,8 @@ class DefaultOnOffSceneHandler : public scenes::DefaultSceneHandlerImpl
213213
return err;
214214
}
215215

216-
// This handler assumes it is being used with the default handler for the level control. Therefore if the level control
217-
// cluster with on off feature is present on the endpoint and the level control handler is registered, it assumes this
218-
// handler will take action on the on-off state. This assumes the level control attributes were also saved in the scene.
219-
// This is to prevent a behavior where the on off state is set by this handler, and then the level control handler or vice
220-
// versa.
221-
#ifdef MATTER_DM_PLUGIN_LEVEL_CONTROL
222-
if (!(LevelControlWithOnOffFeaturePresent(endpoint) &&
223-
ScenesManagement::ScenesServer::Instance().IsHandlerRegistered(endpoint, LevelControlServer::GetSceneHandler())))
224-
#endif
225-
{
226-
VerifyOrReturnError(mTransitionTimeInterface.sceneEventControl(endpoint) != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
227-
OnOffServer::Instance().scheduleTimerCallbackMs(mTransitionTimeInterface.sceneEventControl(endpoint), timeMs);
228-
}
216+
VerifyOrReturnError(mTransitionTimeInterface.sceneEventControl(endpoint) != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
217+
OnOffServer::Instance().scheduleTimerCallbackMs(mTransitionTimeInterface.sceneEventControl(endpoint), timeMs);
229218

230219
return CHIP_NO_ERROR;
231220
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: 4.2.4. [TC-OO-2.7] Scenes Management Cluster Interaction (DUT as Server)
16+
17+
PICS:
18+
- OO.S
19+
- S.S
20+
21+
config:
22+
nodeId: 0x12344321
23+
cluster: "Scenes Management"
24+
endpoint: 1
25+
G1:
26+
type: group_id
27+
defaultValue: 0x0001
28+
29+
tests:
30+
- label: "Wait for the commissioned device to be retrieved"
31+
cluster: "DelayCommands"
32+
command: "WaitForCommissionee"
33+
arguments:
34+
values:
35+
- name: "nodeId"
36+
value: nodeId
37+
38+
- label:
39+
"Step 0a :TH sends KeySetWrite command in the GroupKeyManagement
40+
cluster to DUT using a key that is pre-installed on the TH.
41+
GroupKeySet fields are as follows:"
42+
cluster: "Group Key Management"
43+
endpoint: 0
44+
command: "KeySetWrite"
45+
arguments:
46+
values:
47+
- name: "GroupKeySet"
48+
value:
49+
{
50+
GroupKeySetID: 0x01a1,
51+
GroupKeySecurityPolicy: 0,
52+
EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
53+
EpochStartTime0: 1110000,
54+
EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
55+
EpochStartTime1: 1110001,
56+
EpochKey2: "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
57+
EpochStartTime2: 1110002,
58+
}
59+
60+
- label:
61+
"Step 0b: TH binds GroupIds 0x0001 and 0x0002 with GroupKeySetID
62+
0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster
63+
by writing the GroupKeyMap attribute with two entries as follows:"
64+
cluster: "Group Key Management"
65+
endpoint: 0
66+
command: "writeAttribute"
67+
attribute: "GroupKeyMap"
68+
arguments:
69+
value: [{ FabricIndex: 1, GroupId: G1, GroupKeySetID: 0x01a1 }]
70+
71+
- label: "Step 0c: TH sends a RemoveAllGroups command to DUT."
72+
cluster: "Groups"
73+
endpoint: endpoint
74+
command: "RemoveAllGroups"
75+
76+
- label:
77+
"Step 1a: TH sends a AddGroup command to DUT with the GroupID field
78+
set to G1."
79+
cluster: "Groups"
80+
command: "AddGroup"
81+
arguments:
82+
values:
83+
- name: "GroupID"
84+
value: G1
85+
- name: "GroupName"
86+
value: "Group1"
87+
response:
88+
values:
89+
- name: "Status"
90+
value: 0
91+
- name: "GroupID"
92+
value: G1
93+
94+
- label:
95+
"Step 1b: TH sends a RemoveAllScenes command to DUT with the GroupID
96+
field set to G1."
97+
command: "RemoveAllScenes"
98+
arguments:
99+
values:
100+
- name: "GroupID"
101+
value: G1
102+
response:
103+
values:
104+
- name: "Status"
105+
value: 0x00
106+
- name: "GroupID"
107+
value: G1
108+
- label:
109+
"Step 1c: TH sends a GetSceneMembership command to DUT with the
110+
GroupID field set to G1."
111+
command: "GetSceneMembership"
112+
arguments:
113+
values:
114+
- name: "GroupID"
115+
value: G1
116+
response:
117+
values:
118+
- name: "Status"
119+
value: 0x00
120+
- name: "GroupID"
121+
value: G1
122+
- name: "SceneList"
123+
value: []
124+
125+
- label: "Step 2a: TH sends Off command to DUT"
126+
cluster: "On/Off"
127+
command: "Off"
128+
129+
- label: "Wait 1000ms"
130+
cluster: "DelayCommands"
131+
command: "WaitForMs"
132+
arguments:
133+
values:
134+
- name: "ms"
135+
value: 1000
136+
137+
- label: "Step 2b: after a few seconds, TH reads OnOff attribute from DUT"
138+
cluster: "On/Off"
139+
command: "readAttribute"
140+
attribute: "OnOff"
141+
response:
142+
value: 0
143+
144+
- label:
145+
"Step 2b: TH sends a StoreScene command to DUT with the GroupID field
146+
set to G1 and the SceneID field set to 0x01."
147+
command: "StoreScene"
148+
arguments:
149+
values:
150+
- name: "GroupID"
151+
value: G1
152+
- name: "SceneID"
153+
value: 0x01
154+
response:
155+
values:
156+
- name: "Status"
157+
value: 0x00
158+
- name: "GroupID"
159+
value: G1
160+
- name: "SceneID"
161+
value: 0x01
162+
163+
- label: "Step 3: TH sends a AddScene command to DUT with the GroupID field
164+
set to G1, the SceneID field set to 0x02, the TransitionTime field set
165+
to 1000 (1s) and the ExtensionFieldSets set to: '[{ ClusterID: 0x0006,
166+
AttributeValueList: [{ AttributeID: 0x0000, ValueUnsigned8: 0x01 }]}]'
167+
"
168+
command: "AddScene"
169+
arguments:
170+
values:
171+
- name: "GroupID"
172+
value: G1
173+
- name: "SceneID"
174+
value: 0x02
175+
- name: "TransitionTime"
176+
value: 1000
177+
- name: "SceneName"
178+
value: "Scene1"
179+
- name: "ExtensionFieldSets"
180+
value:
181+
[
182+
{
183+
ClusterID: 0x0006,
184+
AttributeValueList:
185+
[{ AttributeID: 0x0000, ValueUnsigned8: 0x01 }],
186+
},
187+
]
188+
response:
189+
values:
190+
- name: "Status"
191+
value: 0x00
192+
- name: "GroupID"
193+
value: G1
194+
- name: "SceneID"
195+
value: 0x02
196+
197+
- label:
198+
"Step 4a: TH sends a RecallScene command to DUT with the GroupID field
199+
set to G1 and the SceneID field set to 0x02."
200+
PICS: S.S.C05.Rsp
201+
command: "RecallScene"
202+
arguments:
203+
values:
204+
- name: "GroupID"
205+
value: G1
206+
- name: "SceneID"
207+
value: 0x02
208+
209+
- label: "Wait 2000ms"
210+
cluster: "DelayCommands"
211+
command: "WaitForMs"
212+
arguments:
213+
values:
214+
- name: "ms"
215+
value: 2000
216+
217+
- label: "Step 4b: after a few seconds, TH reads OnOff attribute from DUT"
218+
cluster: "On/Off"
219+
command: "readAttribute"
220+
attribute: "OnOff"
221+
response:
222+
value: 1
223+
224+
- label:
225+
"Step 5a: TH sends a RecallScene command to DUT with the GroupID field
226+
set to G1 and the SceneID field set to 0x01."
227+
PICS: S.S.C05.Rsp
228+
command: "RecallScene"
229+
arguments:
230+
values:
231+
- name: "GroupID"
232+
value: G1
233+
- name: "SceneID"
234+
value: 0x01
235+
236+
- label: "Wait 1000ms"
237+
cluster: "DelayCommands"
238+
command: "WaitForMs"
239+
arguments:
240+
values:
241+
- name: "ms"
242+
value: 1000
243+
244+
- label: "Step 5b: after a few seconds, TH reads OnOff attribute from DUT"
245+
cluster: "On/Off"
246+
command: "readAttribute"
247+
attribute: "OnOff"
248+
response:
249+
value: 0
250+
251+
- label:
252+
"Cleanup: TH sends a RemoveAllScenes command to DUT with the GroupID
253+
field set to G1."
254+
command: "RemoveAllScenes"
255+
arguments:
256+
values:
257+
- name: "GroupID"
258+
value: G1
259+
response:
260+
values:
261+
- name: "Status"
262+
value: 0x00
263+
- name: "GroupID"
264+
value: G1
265+
266+
- label: "Cleanup: TH sends a RemoveAllGroups command to DUT."
267+
cluster: "Groups"
268+
endpoint: endpoint
269+
command: "RemoveAllGroups"

src/app/tests/suites/ciTests.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@
144144
"ModeSelect": [],
145145
"MultipleFabrics": [],
146146
"OTASoftwareUpdate": ["OTA_SuccessfulTransfer"],
147-
"OnOff": ["Test_TC_OO_2_1", "Test_TC_OO_2_2", "Test_TC_OO_2_4"],
147+
"OnOff": [
148+
"Test_TC_OO_2_1",
149+
"Test_TC_OO_2_2",
150+
"Test_TC_OO_2_4",
151+
"Test_TC_OO_2_7"
152+
],
148153
"PowerSource": ["Test_TC_PS_2_1"],
149154
"PowerTopology": ["Test_TC_PWRTL_1_1"],
150155
"PressureMeasurement": ["Test_TC_PRS_2_1", "Test_TC_PRS_2_2"],

0 commit comments

Comments
 (0)