18
18
19
19
#pragma once
20
20
21
+ #include < app-common/zap-generated/attribute-type.h>
21
22
#include < app/util/af-types.h>
22
23
#include < lib/core/DataModelTypes.h>
23
24
28
29
namespace chip {
29
30
namespace Test {
30
31
32
+ namespace internal {
33
+
34
+ constexpr EmberAfAttributeMetadata DefaultAttributeMetadata (chip::AttributeId id)
35
+ {
36
+ return EmberAfAttributeMetadata{
37
+ .defaultValue = EmberAfDefaultOrMinMaxAttributeValue (static_cast <uint32_t >(0 )),
38
+ .attributeId = id,
39
+ .size = 4 ,
40
+ .attributeType = ZCL_INT32U_ATTRIBUTE_TYPE,
41
+ .mask = ATTRIBUTE_MASK_WRITABLE | ATTRIBUTE_MASK_NULLABLE,
42
+ };
43
+ }
44
+
45
+ } // namespace internal
46
+
31
47
struct MockAttributeConfig
32
48
{
33
- MockAttributeConfig (AttributeId aId) : id(aId) {}
49
+ MockAttributeConfig (AttributeId aId) : id(aId), attributeMetaData(internal::DefaultAttributeMetadata(aId)) {}
50
+ MockAttributeConfig (AttributeId aId, EmberAfAttributeType type,
51
+ EmberAfAttributeMask mask = ATTRIBUTE_MASK_WRITABLE | ATTRIBUTE_MASK_NULLABLE) :
52
+ id (aId),
53
+ attributeMetaData (internal::DefaultAttributeMetadata(aId))
54
+ {
55
+ attributeMetaData.attributeType = type;
56
+ attributeMetaData.mask = mask;
57
+ }
58
+
34
59
const AttributeId id;
60
+ EmberAfAttributeMetadata attributeMetaData;
35
61
};
36
62
37
63
struct MockEventConfig
@@ -45,6 +71,10 @@ struct MockClusterConfig
45
71
MockClusterConfig (ClusterId aId, std::initializer_list<MockAttributeConfig> aAttributes = {},
46
72
std::initializer_list<MockEventConfig> aEvents = {});
47
73
74
+ // Cluster-config is self-referential: mEmberCluster.attributes references mAttributeMetaData.data()
75
+ MockClusterConfig (const MockClusterConfig & other);
76
+ MockClusterConfig & operator =(const MockClusterConfig &) = delete ;
77
+
48
78
const MockAttributeConfig * attributeById (AttributeId attributeId, ptrdiff_t * outIndex = nullptr ) const ;
49
79
const EmberAfCluster * emberCluster () const { return &mEmberCluster ; }
50
80
@@ -55,13 +85,14 @@ struct MockClusterConfig
55
85
private:
56
86
EmberAfCluster mEmberCluster ;
57
87
std::vector<EventId> mEmberEventList ;
88
+ std::vector<EmberAfAttributeMetadata> mAttributeMetaData ;
58
89
};
59
90
60
91
struct MockEndpointConfig
61
92
{
62
93
MockEndpointConfig (EndpointId aId, std::initializer_list<MockClusterConfig> aClusters = {});
63
94
64
- // Cluster -config is self-referntial: mEmberCluster .clusters references mEmberClusters
95
+ // Endpoint -config is self-referential: mEmberEndpoint .clusters references mEmberClusters.data()
65
96
MockEndpointConfig (const MockEndpointConfig & other);
66
97
MockEndpointConfig & operator =(const MockEndpointConfig &) = delete ;
67
98
0 commit comments