@@ -1721,15 +1721,6 @@ - (void)testControllerServer
1721
1721
],
1722
1722
};
1723
1723
1724
- #if 0
1725
- __auto_type * listOfStructsValue2 = @{
1726
- MTRTypeKey : MTRArrayValueType,
1727
- MTRValueKey : @[
1728
- @{ MTRDataKey: structValue2, },
1729
- ],
1730
- };
1731
- #endif
1732
-
1733
1724
__auto_type responsePathFromRequestPath = ^(MTRAttributeRequestPath * path) {
1734
1725
return [MTRAttributePath attributePathWithEndpointID: path.endpoint clusterID: path.cluster attributeID: path.attribute];
1735
1726
};
@@ -2007,32 +1998,60 @@ - (void)testControllerServer
2007
1998
2008
1999
// Now do a wildcard read on the endpoint and check that this does the right
2009
2000
// thing (gets the right things from descriptor, gets both clusters, etc).
2010
- #if 0
2011
- // Unused bits ifdefed out until we doing more testing on the actual values
2012
- // we get back.
2013
2001
__auto_type globalAttributePath = ^(NSNumber * clusterID, MTRAttributeIDType attributeID) {
2014
2002
return [MTRAttributePath attributePathWithEndpointID: endpointId1 clusterID: clusterID attributeID: @(attributeID)];
2015
2003
};
2004
+ __auto_type descriptorAttributePath = ^(MTRAttributeIDType attributeID) {
2005
+ return [MTRAttributePath attributePathWithEndpointID: endpointId1 clusterID: @(MTRClusterIDTypeDescriptorID) attributeID: @(attributeID)];
2006
+ };
2016
2007
__auto_type unsignedIntValue = ^(NSUInteger value) {
2017
2008
return @{
2018
- MTRTypeKey: MTRUnsignedIntegerValueType,
2019
- MTRValueKey: @(value),
2009
+ MTRTypeKey : MTRUnsignedIntegerValueType,
2010
+ MTRValueKey : @(value),
2020
2011
};
2021
2012
};
2022
2013
__auto_type arrayOfUnsignedIntegersValue = ^(NSArray <NSNumber *> * values) {
2023
2014
__auto_type * mutableArray = [[NSMutableArray alloc ] init ];
2024
2015
for (NSNumber * value in values) {
2025
- [mutableArray addObject:@{ MTRDataKey: @{
2026
- MTRTypeKey: MTRUnsignedIntegerValueType,
2027
- MTRValueKey: value,
2028
- }, }];
2016
+ [mutableArray addObject: @{
2017
+ MTRDataKey : @ {
2018
+ MTRTypeKey : MTRUnsignedIntegerValueType,
2019
+ MTRValueKey : value,
2020
+ },
2021
+ }];
2029
2022
}
2030
2023
return @{
2031
- MTRTypeKey: MTRArrayValueType,
2032
- MTRValueKey: [mutableArray copy],
2033
- };
2024
+ MTRTypeKey : MTRArrayValueType,
2025
+ MTRValueKey : [mutableArray copy ],
2026
+ };
2034
2027
};
2035
- #endif
2028
+ __auto_type endpoint1DeviceTypeValue = @{
2029
+ MTRTypeKey : MTRArrayValueType,
2030
+ MTRValueKey : @[
2031
+ @{
2032
+ MTRDataKey : @ {
2033
+ MTRTypeKey : MTRStructureValueType,
2034
+ MTRValueKey : @[
2035
+ @{
2036
+ MTRContextTagKey : @(0 ),
2037
+ MTRDataKey : @ {
2038
+ MTRTypeKey : MTRUnsignedIntegerValueType,
2039
+ MTRValueKey : deviceType1.deviceTypeID ,
2040
+ },
2041
+ },
2042
+ @{
2043
+ MTRContextTagKey : @(1 ),
2044
+ MTRDataKey : @ {
2045
+ MTRTypeKey : MTRUnsignedIntegerValueType,
2046
+ MTRValueKey : deviceType1.deviceTypeRevision ,
2047
+ },
2048
+ },
2049
+ ],
2050
+ }
2051
+ },
2052
+ ],
2053
+ };
2054
+
2036
2055
XCTestExpectation * wildcardReadExpectation = [self expectationWithDescription: @" Wildcard read of our endpoint" ];
2037
2056
[baseDevice readAttributePaths: @[ [MTRAttributeRequestPath requestPathWithEndpointID: endpointId1 clusterID: nil attributeID: nil ] ]
2038
2057
eventPaths: nil
@@ -2042,32 +2061,118 @@ - (void)testControllerServer
2042
2061
XCTAssertNil (error);
2043
2062
XCTAssertNotNil (values);
2044
2063
2045
- // TODO: Figure out how to test that values is correct that's not
2046
- // too fragile if things get returned in different valid order.
2047
- // For now just check that every path we got has a value, not an
2048
- // error.
2049
2064
for (NSDictionary <NSString *, id > * value in values) {
2050
2065
XCTAssertNotNil (value[MTRAttributePathKey]);
2051
2066
XCTAssertNil (value[MTRErrorKey]);
2052
2067
XCTAssertNotNil (value[MTRDataKey]);
2053
2068
}
2054
- #if 0
2055
- XCTAssertEqualObjects(values, @[
2056
- // cluster1
2057
- @{ MTRAttributePathKey: attribute1ResponsePath,
2058
- MTRDataKey: unsignedIntValue2, },
2059
- @{ MTRAttributePathKey: globalAttributePath(clusterId1, MTRAttributeIDTypeGlobalAttributeFeatureMapID),
2060
- MTRDataKey: unsignedIntValue(0), },
2061
- @{ MTRAttributePathKey: globalAttributePath(clusterId1, MTRAttributeIDTypeGlobalAttributeClusterRevisionID),
2062
- MTRDataKey: clusterRevision1, },
2063
- @{ MTRAttributePathKey: globalAttributePath(clusterId1, MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID),
2064
- MTRDataKey: arrayOfUnsignedIntegersValue(@[]), },
2065
- @{ MTRAttributePathKey: globalAttributePath(clusterId1, MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID),
2066
- MTRDataKey: arrayOfUnsignedIntegersValue(@[]), },
2067
- // etc
2068
-
2069
- ]);
2070
- #endif
2069
+
2070
+ NSSet <NSDictionary <NSString *, id > *> * receivedValues = [NSSet setWithArray: values];
2071
+ NSSet <NSDictionary <NSString *, id > *> * expectedValues = [NSSet setWithArray: @[
2072
+ // cluster1
2073
+ @ {
2074
+ MTRAttributePathKey : attribute1ResponsePath,
2075
+ MTRDataKey : unsignedIntValue2,
2076
+ },
2077
+ // attribute3 requires Operate privileges to read, which we do not have
2078
+ // for this cluster, so it will not be present here.
2079
+ @ {
2080
+ MTRAttributePathKey : globalAttributePath (clusterId1, MTRAttributeIDTypeGlobalAttributeFeatureMapID),
2081
+ MTRDataKey : unsignedIntValue (0 ),
2082
+ },
2083
+ @ {
2084
+ MTRAttributePathKey : globalAttributePath (clusterId1, MTRAttributeIDTypeGlobalAttributeClusterRevisionID),
2085
+ MTRDataKey : unsignedIntValue (clusterRevision1.unsignedIntegerValue ),
2086
+ },
2087
+ @{
2088
+ MTRAttributePathKey : globalAttributePath (clusterId1, MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID),
2089
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[]),
2090
+ },
2091
+ @{
2092
+ MTRAttributePathKey : globalAttributePath (clusterId1, MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID),
2093
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[]),
2094
+ },
2095
+ @{
2096
+ MTRAttributePathKey : globalAttributePath (clusterId1, MTRAttributeIDTypeGlobalAttributeAttributeListID),
2097
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[
2098
+ attributeId1, @(0xFFF8 ), @(0xFFF9 ), @(0xFFFB ), attributeId2, @(0xFFFC ), @(0xFFFD )
2099
+ ]),
2100
+ },
2101
+
2102
+ // cluster2
2103
+ @ {
2104
+ MTRAttributePathKey : attribute2ResponsePath,
2105
+ MTRDataKey : listOfStructsValue1,
2106
+ },
2107
+ @ {
2108
+ MTRAttributePathKey : globalAttributePath (clusterId2, MTRAttributeIDTypeGlobalAttributeFeatureMapID),
2109
+ MTRDataKey : unsignedIntValue (0 ),
2110
+ },
2111
+ @ {
2112
+ MTRAttributePathKey : globalAttributePath (clusterId2, MTRAttributeIDTypeGlobalAttributeClusterRevisionID),
2113
+ MTRDataKey : unsignedIntValue (clusterRevision2.unsignedIntegerValue ),
2114
+ },
2115
+ @{MTRAttributePathKey : globalAttributePath (clusterId2, MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID),
2116
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[]),
2117
+ },
2118
+ @{
2119
+ MTRAttributePathKey : globalAttributePath (clusterId2, MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID),
2120
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[]),
2121
+ },
2122
+ @{
2123
+ MTRAttributePathKey : globalAttributePath (clusterId2, MTRAttributeIDTypeGlobalAttributeAttributeListID),
2124
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[
2125
+ @0xFFF8 , @(0xFFF9 ), @(0xFFFB ), attributeId2, @(0xFFFC ), @(0xFFFD )
2126
+ ]),
2127
+ },
2128
+
2129
+ // descriptor
2130
+ @ {
2131
+ MTRAttributePathKey : descriptorAttributePath (MTRAttributeIDTypeClusterDescriptorAttributeDeviceTypeListID),
2132
+ MTRDataKey : endpoint1DeviceTypeValue,
2133
+ },
2134
+ @{
2135
+ MTRAttributePathKey : descriptorAttributePath (MTRAttributeIDTypeClusterDescriptorAttributeServerListID),
2136
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[ clusterId1, clusterId2, @(MTRClusterIDTypeDescriptorID) ]),
2137
+ },
2138
+ @{
2139
+ MTRAttributePathKey : descriptorAttributePath (MTRAttributeIDTypeClusterDescriptorAttributeClientListID),
2140
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[]),
2141
+ },
2142
+ @{
2143
+ MTRAttributePathKey : descriptorAttributePath (MTRAttributeIDTypeClusterDescriptorAttributePartsListID),
2144
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[]),
2145
+ },
2146
+ // No TagList attribute on this descriptor.
2147
+ @ {
2148
+ MTRAttributePathKey : descriptorAttributePath (MTRAttributeIDTypeGlobalAttributeFeatureMapID),
2149
+ MTRDataKey : unsignedIntValue (0 ),
2150
+ },
2151
+ @ {
2152
+ MTRAttributePathKey : descriptorAttributePath (MTRAttributeIDTypeGlobalAttributeClusterRevisionID),
2153
+ // Would be nice if we could get the Descriptor cluster revision
2154
+ // from somewhere intead of hardcoding it...
2155
+ MTRDataKey : unsignedIntValue (2 ),
2156
+ },
2157
+ @{
2158
+ MTRAttributePathKey : globalAttributePath (@(MTRClusterIDTypeDescriptorID), MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID),
2159
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[]),
2160
+ },
2161
+ @{
2162
+ MTRAttributePathKey : globalAttributePath (@(MTRClusterIDTypeDescriptorID), MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID),
2163
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[]),
2164
+ },
2165
+ @{
2166
+ MTRAttributePathKey : globalAttributePath (@(MTRClusterIDTypeDescriptorID), MTRAttributeIDTypeGlobalAttributeAttributeListID),
2167
+ MTRDataKey : arrayOfUnsignedIntegersValue (@[
2168
+ @(0 ), @(1 ), @(2 ), @(3 ), @(0xFFF8 ), @(0xFFF9 ), @(0xFFFB ), @(0xFFFC ), @(0xFFFD )
2169
+ ]),
2170
+ },
2171
+
2172
+ ]];
2173
+
2174
+ XCTAssertEqualObjects (receivedValues, expectedValues);
2175
+
2071
2176
[wildcardReadExpectation fulfill ];
2072
2177
}];
2073
2178
[self waitForExpectations: @[ wildcardReadExpectation ] timeout: kTimeoutInSeconds ];
0 commit comments