Skip to content

Commit c6c8e67

Browse files
authored
Fix up mock ember implementation: (project-chip#32928)
- provide data version function as described by attribute-storage.h - fix self-referencing structure copying for mock node configurations
1 parent 5236e27 commit c6c8e67

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/app/util/mock/MockNodeConfig.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ MockEndpointConfig::MockEndpointConfig(EndpointId aId, std::initializer_list<Moc
9191
mEmberEndpoint.cluster = mEmberClusters.data();
9292
}
9393

94+
MockEndpointConfig::MockEndpointConfig(const MockEndpointConfig & other) :
95+
id(other.id), clusters(other.clusters), mEmberClusters(other.mEmberClusters), mEmberEndpoint(other.mEmberEndpoint)
96+
{
97+
// fix self-referencing pointers
98+
mEmberEndpoint.cluster = mEmberClusters.data();
99+
}
100+
94101
const MockClusterConfig * MockEndpointConfig::clusterById(ClusterId clusterId, ptrdiff_t * outIndex) const
95102
{
96103
return findById(clusters, clusterId, outIndex);

src/app/util/mock/MockNodeConfig.h

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ struct MockEndpointConfig
6161
{
6262
MockEndpointConfig(EndpointId aId, std::initializer_list<MockClusterConfig> aClusters = {});
6363

64+
// Cluster-config is self-referntial: mEmberCluster.clusters references mEmberClusters
65+
MockEndpointConfig(const MockEndpointConfig & other);
66+
MockEndpointConfig & operator=(const MockEndpointConfig &) = delete;
67+
6468
const MockClusterConfig * clusterById(ClusterId clusterId, ptrdiff_t * outIndex = nullptr) const;
6569
const EmberAfEndpointType * emberEndpoint() const { return &mEmberEndpoint; }
6670

src/app/util/mock/attribute-storage.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ const EmberAfCluster * emberAfFindServerCluster(EndpointId endpointId, ClusterId
258258
return cluster->emberCluster();
259259
}
260260

261+
DataVersion * emberAfDataVersionStorage(const chip::app::ConcreteClusterPath & aConcreteClusterPath)
262+
{
263+
// shared data version storage
264+
return &dataVersion;
265+
}
266+
261267
namespace chip {
262268
namespace app {
263269

0 commit comments

Comments
 (0)