@@ -1926,6 +1926,51 @@ - (void)test019_MTRDeviceMultipleCommands
1926
1926
}];
1927
1927
1928
1928
[self waitForExpectations:@[ readFabricLabelExpectation ] timeout:kTimeoutInSeconds];
1929
+
1930
+ // Now test doing the UpdateFabricLabel command but directly via the
1931
+ // MTRDevice API.
1932
+ XCTestExpectation * updateLabelExpectation2 = [self expectationWithDescription:@"Fabric label updated a second time"];
1933
+ // IMPORTANT: commandFields here uses hardcoded strings, not MTR* constants
1934
+ // for the strings, to check for places that are doing string equality wrong.
1935
+ __auto_type * commandFields = @{
1936
+ @"type" : @"Structure",
1937
+ @"value" : @[
1938
+ @{
1939
+ @"contextTag" : @0,
1940
+ @"data" : @ {
1941
+ @"type" : @"UTF8String",
1942
+ @"value" : @"Test2",
1943
+ },
1944
+ },
1945
+ ],
1946
+ };
1947
+
1948
+ [device invokeCommandWithEndpointID:@(0)
1949
+ clusterID:@(MTRClusterIDTypeOperationalCredentialsID)
1950
+ commandID:@(MTRCommandIDTypeClusterOperationalCredentialsCommandUpdateFabricLabelID)
1951
+ commandFields:commandFields
1952
+ expectedValues:nil
1953
+ expectedValueInterval:nil
1954
+ queue:queue
1955
+ completion:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
1956
+ XCTAssertNil(error);
1957
+ [updateLabelExpectation2 fulfill];
1958
+ }];
1959
+
1960
+ [self waitForExpectations:@[ updateLabelExpectation2 ] timeout:kTimeoutInSeconds];
1961
+
1962
+ // And again, make sure our fabric label got updated.
1963
+ readFabricLabelExpectation = [self expectationWithDescription:@"Read fabric label third time"];
1964
+ [baseOpCredsCluster readAttributeFabricsWithParams:nil completion:^(NSArray * _Nullable value, NSError * _Nullable error) {
1965
+ XCTAssertNil(error);
1966
+ XCTAssertNotNil(value);
1967
+ XCTAssertEqual(value.count, 1);
1968
+ MTROperationalCredentialsClusterFabricDescriptorStruct * entry = value[0];
1969
+ XCTAssertEqualObjects(entry.label, @"Test2");
1970
+ [readFabricLabelExpectation fulfill];
1971
+ }];
1972
+
1973
+ [self waitForExpectations:@[ readFabricLabelExpectation ] timeout:kTimeoutInSeconds];
1929
1974
}
1930
1975
1931
1976
- (void)test020_ReadMultipleAttributes
0 commit comments