18
18
19
19
#include < app/clusters/scenes-server/SceneTableImpl.h>
20
20
#include < app/util/mock/Constants.h>
21
+ #include < app/util/mock/MockNodeConfigImpl.h>
21
22
#include < crypto/DefaultSessionKeystore.h>
22
23
#include < lib/core/TLV.h>
23
24
#include < lib/support/Span.h>
26
27
#include < nlunit-test.h>
27
28
28
29
using namespace chip ;
30
+ using namespace chip ::Test;
31
+ using namespace chip ::app::Clusters::Globals::Attributes;
29
32
30
33
using SceneTable = scenes::SceneTable<scenes::ExtensionFieldSetsImpl>;
31
34
using SceneTableEntry = scenes::DefaultSceneTableImpl::SceneTableEntry;
@@ -45,6 +48,7 @@ constexpr uint8_t defaultTestFabricCapacity = (defaultTestTableSize - 1) / 2;
45
48
constexpr chip::ClusterId kOnOffClusterId = 0x0006 ;
46
49
constexpr chip::ClusterId kLevelControlClusterId = 0x0008 ;
47
50
constexpr chip::ClusterId kColorControlClusterId = 0x0300 ;
51
+ constexpr chip::ClusterId kScenesClusterId = 0x0062 ;
48
52
49
53
// Test Endpoint ID
50
54
constexpr chip::EndpointId kTestEndpoint1 = chip::Test::kMockEndpoint1 ;
@@ -152,6 +156,43 @@ static uint32_t OO_buffer_serialized_length = 0;
152
156
static uint32_t LC_buffer_serialized_length = 0 ;
153
157
static uint32_t CC_buffer_serialized_length = 0 ;
154
158
159
+ // clang-format off
160
+ static const MockNodeConfig SceneMockNodeConfig ({
161
+ MockEndpointConfig (kTestEndpoint1 , {
162
+ MockClusterConfig (kScenesClusterId , {}),
163
+ MockClusterConfig (kOnOffClusterId , {
164
+ kOnOffAttId
165
+ }),
166
+ MockClusterConfig (kLevelControlClusterId , {
167
+ kCurrentLevelId , kCurrentFrequencyId
168
+ }),
169
+ }),
170
+ MockEndpointConfig (kTestEndpoint2 , {
171
+ MockClusterConfig (kScenesClusterId , {}),
172
+ MockClusterConfig (kOnOffClusterId , {
173
+ kOnOffAttId
174
+ }),
175
+ MockClusterConfig (kColorControlClusterId , {
176
+ kCurrentSaturationId , kCurrentXId ,kCurrentYId , kColorTemperatureMiredsId ,
177
+ kEnhancedCurrentHueId ,kColorLoopActiveId , kColorLoopDirectionId , kColorLoopTimeId
178
+ }),
179
+ }),
180
+ MockEndpointConfig (kTestEndpoint3 , {
181
+ MockClusterConfig (kScenesClusterId , {}),
182
+ MockClusterConfig (kOnOffClusterId , {
183
+ kOnOffAttId
184
+ }),
185
+ MockClusterConfig (kLevelControlClusterId , {
186
+ kCurrentLevelId , kCurrentFrequencyId
187
+ }),
188
+ MockClusterConfig (kColorControlClusterId , {
189
+ kCurrentSaturationId , kCurrentXId ,kCurrentYId , kColorTemperatureMiredsId ,
190
+ kEnhancedCurrentHueId ,kColorLoopActiveId , kColorLoopDirectionId , kColorLoopTimeId
191
+ }),
192
+ }),
193
+ });
194
+ // clang-format on
195
+
155
196
// / @brief Simulates a Handler where Endpoint 1 supports onoff and level control and Endpoint 2 supports onoff and color control
156
197
class TestSceneHandler : public scenes ::DefaultSceneHandlerImpl
157
198
{
@@ -208,15 +249,15 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl
208
249
}
209
250
}
210
251
211
- if (endpoint == kTestEndpoint1 )
252
+ if (endpoint == kTestEndpoint2 )
212
253
{
213
254
if (cluster == kOnOffClusterId || cluster == kColorControlClusterId )
214
255
{
215
256
return true ;
216
257
}
217
258
}
218
259
219
- if (endpoint == kTestEndpoint1 )
260
+ if (endpoint == kTestEndpoint3 )
220
261
{
221
262
if (cluster == kOnOffClusterId || cluster == kLevelControlClusterId || cluster == kColorControlClusterId )
222
263
{
@@ -258,7 +299,7 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl
258
299
break ;
259
300
}
260
301
}
261
- if (endpoint == kTestEndpoint1 )
302
+ if (endpoint == kTestEndpoint2 )
262
303
{
263
304
switch (cluster)
264
305
{
@@ -280,7 +321,7 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl
280
321
break ;
281
322
}
282
323
}
283
- if (endpoint == kTestEndpoint1 )
324
+ if (endpoint == kTestEndpoint3 )
284
325
{
285
326
switch (cluster)
286
327
{
@@ -347,7 +388,7 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl
347
388
}
348
389
349
390
// Takes values from cluster in Endpoint 2
350
- if (endpoint == kTestEndpoint1 )
391
+ if (endpoint == kTestEndpoint2 )
351
392
{
352
393
switch (cluster)
353
394
{
@@ -369,7 +410,7 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl
369
410
}
370
411
371
412
// Takes values from cluster in Endpoint 3
372
- if (endpoint == kTestEndpoint1 )
413
+ if (endpoint == kTestEndpoint3 )
373
414
{
374
415
switch (cluster)
375
416
{
@@ -600,8 +641,8 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext)
600
641
NL_TEST_ASSERT (aSuite, CHIP_NO_ERROR == reader.Next ());
601
642
NL_TEST_ASSERT (aSuite, CHIP_NO_ERROR == extensionFieldSetIn.attributeValueList .Decode (reader));
602
643
603
- NL_TEST_ASSERT (aSuite, sHandler .SupportsCluster (kTestEndpoint1 , extensionFieldSetIn.clusterID ));
604
- NL_TEST_ASSERT (aSuite, CHIP_NO_ERROR == sHandler .SerializeAdd (kTestEndpoint1 , extensionFieldSetIn, buff_span));
644
+ NL_TEST_ASSERT (aSuite, sHandler .SupportsCluster (kTestEndpoint2 , extensionFieldSetIn.clusterID ));
645
+ NL_TEST_ASSERT (aSuite, CHIP_NO_ERROR == sHandler .SerializeAdd (kTestEndpoint2 , extensionFieldSetIn, buff_span));
605
646
606
647
// Verify the handler extracted buffer matches the initial field sets
607
648
NL_TEST_ASSERT (aSuite, 0 == memcmp (CC_list.data (), buff_span.data (), buff_span.size ()));
@@ -632,9 +673,9 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext)
632
673
memset (buffer, 0 , buff_span.size ());
633
674
634
675
// Verify Deserializing is properly filling out output extension field set for color control
635
- NL_TEST_ASSERT (aSuite, sHandler .SupportsCluster (kTestEndpoint1 , kColorControlClusterId ));
676
+ NL_TEST_ASSERT (aSuite, sHandler .SupportsCluster (kTestEndpoint2 , kColorControlClusterId ));
636
677
NL_TEST_ASSERT (aSuite,
637
- CHIP_NO_ERROR == sHandler .Deserialize (kTestEndpoint1 , kColorControlClusterId , CC_list, extensionFieldSetOut));
678
+ CHIP_NO_ERROR == sHandler .Deserialize (kTestEndpoint2 , kColorControlClusterId , CC_list, extensionFieldSetOut));
638
679
639
680
// Verify Encoding the Extension field set returns the same data as the one serialized for color control previously
640
681
writer.Init (buff_span);
@@ -1818,6 +1859,8 @@ int TestSetup(void * inContext)
1818
1859
{
1819
1860
VerifyOrReturnError (CHIP_NO_ERROR == chip::Platform::MemoryInit (), FAILURE);
1820
1861
1862
+ SetMockNodeConfig (&TestScenes::SceneMockNodeConfig);
1863
+
1821
1864
// Initialize Scene Table
1822
1865
SceneTable * sceneTable = scenes::GetSceneTableImpl ();
1823
1866
VerifyOrReturnError (nullptr != sceneTable, FAILURE);
0 commit comments