19
19
#include < app-common/zap-generated/ids/Attributes.h>
20
20
#include < app/ConcreteClusterPath.h>
21
21
#include < app/server-cluster/DefaultServerCluster.h>
22
+ #include < app/server-cluster/ServerClusterContext.h>
23
+ #include < app/server-cluster/testing/TestServerClusterContext.h>
22
24
#include < data-model-providers/codegen/ServerClusterInterfaceRegistry.h>
23
25
#include < lib/core/CHIPError.h>
24
26
#include < lib/core/DataModelTypes.h>
29
31
#include < random>
30
32
31
33
using namespace chip ;
34
+ using namespace chip ::Test;
32
35
using namespace chip ::app;
33
36
using namespace chip ::app::DataModel;
34
37
using namespace chip ::app::Clusters;
@@ -348,8 +351,8 @@ TEST_F(TestServerClusterInterfaceRegistry, Context)
348
351
EXPECT_FALSE (cluster1.HasContext ());
349
352
350
353
// set up the registry
351
- ServerClusterContext nullContext; // not valid, however we do not care
352
- EXPECT_EQ (registry.SetContext (nullContext ), CHIP_NO_ERROR);
354
+ TestServerClusterContext context;
355
+ EXPECT_EQ (registry.SetContext (context. Create () ), CHIP_NO_ERROR);
353
356
354
357
EXPECT_TRUE (cluster1.HasContext ());
355
358
EXPECT_FALSE (cluster2.HasContext ());
@@ -365,7 +368,7 @@ TEST_F(TestServerClusterInterfaceRegistry, Context)
365
368
EXPECT_FALSE (cluster2.HasContext ());
366
369
EXPECT_FALSE (cluster3.HasContext ());
367
370
368
- EXPECT_EQ (registry.SetContext (nullContext ), CHIP_NO_ERROR);
371
+ EXPECT_EQ (registry.SetContext (context. Create () ), CHIP_NO_ERROR);
369
372
EXPECT_TRUE (cluster1.HasContext ());
370
373
EXPECT_TRUE (cluster2.HasContext ());
371
374
EXPECT_FALSE (cluster3.HasContext ());
@@ -380,17 +383,15 @@ TEST_F(TestServerClusterInterfaceRegistry, Context)
380
383
EXPECT_TRUE (cluster3.HasContext ());
381
384
382
385
// re-setting context works
383
- EXPECT_EQ (registry.SetContext (nullContext ), CHIP_NO_ERROR);
386
+ EXPECT_EQ (registry.SetContext (context. Create () ), CHIP_NO_ERROR);
384
387
EXPECT_TRUE (cluster1.HasContext ());
385
388
EXPECT_FALSE (cluster2.HasContext ());
386
389
EXPECT_TRUE (cluster3.HasContext ());
387
390
388
391
// also not valid, but different
389
- ServerClusterContext otherContext;
390
- InteractionModelContext modelContext;
391
- otherContext.interactionContext = &modelContext;
392
+ TestServerClusterContext otherContext;
392
393
393
- EXPECT_EQ (registry.SetContext (otherContext), CHIP_NO_ERROR);
394
+ EXPECT_EQ (registry.SetContext (otherContext. Create () ), CHIP_NO_ERROR);
394
395
EXPECT_TRUE (cluster1.HasContext ());
395
396
EXPECT_FALSE (cluster2.HasContext ());
396
397
EXPECT_TRUE (cluster3.HasContext ());
@@ -412,7 +413,6 @@ TEST_F(TestServerClusterInterfaceRegistry, StartupErrors)
412
413
413
414
{
414
415
ServerClusterInterfaceRegistry registry;
415
-
416
416
EXPECT_FALSE (cluster1.HasContext ());
417
417
EXPECT_FALSE (cluster2.HasContext ());
418
418
@@ -423,8 +423,8 @@ TEST_F(TestServerClusterInterfaceRegistry, StartupErrors)
423
423
EXPECT_FALSE (cluster1.HasContext ());
424
424
EXPECT_FALSE (cluster2.HasContext ());
425
425
426
- ServerClusterContext nullContext; // not valid, however we do not care
427
- EXPECT_EQ (registry.SetContext (nullContext ), CHIP_ERROR_HAD_FAILURES);
426
+ TestServerClusterContext context;
427
+ EXPECT_EQ (registry.SetContext (context. Create () ), CHIP_ERROR_HAD_FAILURES);
428
428
EXPECT_TRUE (cluster1.HasContext ());
429
429
EXPECT_FALSE (cluster2.HasContext ());
430
430
0 commit comments