@@ -2327,7 +2327,7 @@ - (MTRDevice *)getMTRDevice:(NSNumber *)deviceID
2327
2327
XCTAssertTrue ([controller isRunning ]);
2328
2328
2329
2329
XCTAssertEqualObjects (controller.controllerNodeID , nodeID);
2330
-
2330
+
2331
2331
certificateIssuer.nextNodeID = deviceID;
2332
2332
[self commissionWithController: controller newNodeID: deviceID];
2333
2333
@@ -2339,10 +2339,10 @@ - (MTRDevice *)getMTRDevice:(NSNumber *)deviceID
2339
2339
{
2340
2340
// Initialize the endpoint array with endpoint 0.
2341
2341
NSMutableArray <NSNumber *> * endpoints = [NSMutableArray arrayWithObject: @0 ];
2342
-
2342
+
2343
2343
[endpoints addObjectsFromArray: [device arrayOfNumbersFromAttributeValue: [device _dataValueWithoutDataVersion: partsList]]];
2344
2344
return endpoints;
2345
-
2345
+
2346
2346
}
2347
2347
2348
2348
- (void )test011_testDataStorageUpdatesWhenRemovingEndpoints
@@ -2392,7 +2392,7 @@ - (void)test011_testDataStorageUpdatesWhenRemovingEndpoints
2392
2392
XCTAssertNotNil (dataVersionForPartsList);
2393
2393
XCTAssertNotNil (testClusterDataValueForPartsList);
2394
2394
testEndpoints = [self getEndpointArrayFromPartsList: testDataForPartsList forDevice: device];
2395
-
2395
+
2396
2396
// Make sure that the cluster data in the data storage is populated with cluster index and cluster data for endpoints 0, 1 and 2.
2397
2397
// We do not need to check _persistedClusterData here. _persistedClusterData will be paged in from storage when needed so
2398
2398
// just checking data storage should suffice here.
@@ -2404,7 +2404,7 @@ - (void)test011_testDataStorageUpdatesWhenRemovingEndpoints
2404
2404
[initialClusterIndex setObject: [controller.controllerDataStore _fetchClusterIndexForNodeID: deviceID endpointID: endpoint] forKey: endpoint];
2405
2405
}
2406
2406
XCTAssertNotNil (initialClusterIndex);
2407
-
2407
+
2408
2408
for (NSNumber * endpoint in testEndpoints) {
2409
2409
for (NSNumber * cluster in [initialClusterIndex objectForKey: endpoint]) {
2410
2410
XCTAssertNotNil ([controller.controllerDataStore _fetchClusterDataForNodeID: deviceID endpointID: endpoint clusterID: cluster]);
@@ -2417,10 +2417,10 @@ - (void)test011_testDataStorageUpdatesWhenRemovingEndpoints
2417
2417
[device setDelegate: delegate queue: queue];
2418
2418
2419
2419
[self waitForExpectations: @[ subscriptionExpectation ] timeout: 60 ];
2420
-
2420
+
2421
2421
// Inject a fake attribute report deleting endpoint 2 from the parts list at the root endpoint.
2422
2422
dataVersionForPartsList = [NSNumber numberWithUnsignedLongLong: (dataVersionForPartsList.unsignedLongLongValue + 1 )];
2423
-
2423
+
2424
2424
// Delete the last endpoint from the attribute value in parts list.
2425
2425
NSNumber * toBeDeletedEndpoint = @2 ;
2426
2426
__block id endpointData =
@@ -2430,9 +2430,9 @@ - (void)test011_testDataStorageUpdatesWhenRemovingEndpoints
2430
2430
MTRValueKey : toBeDeletedEndpoint,
2431
2431
}
2432
2432
};
2433
-
2433
+
2434
2434
[testClusterDataValueForPartsList removeObject: endpointData];
2435
-
2435
+
2436
2436
NSArray <NSDictionary <NSString *, id > *> * attributeReport = @[ @{
2437
2437
MTRAttributePathKey : [MTRAttributePath attributePathWithEndpointID: rootEndpoint clusterID: @(MTRClusterIDTypeDescriptorID) attributeID: @(MTRAttributeIDTypeClusterDescriptorAttributePartsListID)],
2438
2438
MTRDataKey : @ {
@@ -2447,7 +2447,7 @@ - (void)test011_testDataStorageUpdatesWhenRemovingEndpoints
2447
2447
delegate.onAttributeDataReceived = ^(NSArray <NSDictionary <NSString *, id > *> * attributeReport) {
2448
2448
attributeReportsReceived += attributeReport.count ;
2449
2449
XCTAssert (attributeReportsReceived > 0 );
2450
-
2450
+
2451
2451
for (NSDictionary <NSString *, id > * attributeDict in attributeReport) {
2452
2452
MTRAttributePath * attributePath = attributeDict[MTRAttributePathKey];
2453
2453
XCTAssertNotNil (attributePath);
@@ -2510,13 +2510,13 @@ - (void)test012_testDataStorageUpdatesWhenRemovingClusters
2510
2510
__auto_type queue = dispatch_get_main_queue ();
2511
2511
__auto_type * delegate = [[MTRDeviceTestDelegate alloc ] init ];
2512
2512
__auto_type * controller = device.deviceController ;
2513
-
2513
+
2514
2514
XCTestExpectation * subscriptionExpectation = [self expectationWithDescription: @" Subscription has been set up" ];
2515
-
2515
+
2516
2516
__block unsigned attributeReportsReceived = 0 ;
2517
2517
__block NSNumber * dataVersionForServerList;
2518
2518
__block NSNumber * testEndpoint = @1 ;
2519
-
2519
+
2520
2520
// This test will do the following -
2521
2521
// 1. Get the data version and attribute value of the server list for endpoint 1 to inject a fake report. The attribute report will delete cluster ID - MTRClusterIDTypeIdentifyID.
2522
2522
// That should cause the cluster to be removed from cluster index and cluster data for that cluster to be removed from data storage.
@@ -2528,11 +2528,11 @@ - (void)test012_testDataStorageUpdatesWhenRemovingClusters
2528
2528
delegate.onAttributeDataReceived = ^(NSArray <NSDictionary <NSString *, id > *> * attributeReport) {
2529
2529
attributeReportsReceived += attributeReport.count ;
2530
2530
XCTAssert (attributeReportsReceived > 0 );
2531
-
2531
+
2532
2532
for (NSDictionary <NSString *, id > * attributeDict in attributeReport) {
2533
2533
MTRAttributePath * attributePath = attributeDict[MTRAttributePathKey];
2534
2534
XCTAssertNotNil (attributePath);
2535
-
2535
+
2536
2536
if ([attributePath.endpoint isEqualToNumber: testEndpoint] && attributePath.cluster .unsignedLongValue == MTRClusterIDTypeDescriptorID && attributePath.attribute .unsignedLongValue == MTRAttributeIDTypeClusterDescriptorAttributeServerListID) {
2537
2537
NSDictionary * data = attributeDict[MTRDataKey];
2538
2538
XCTAssertNotNil (data);
@@ -2543,7 +2543,7 @@ - (void)test012_testDataStorageUpdatesWhenRemovingClusters
2543
2543
}
2544
2544
}
2545
2545
};
2546
-
2546
+
2547
2547
__block NSMutableArray <NSNumber *> * initialClusterIndex = [[NSMutableArray alloc ] init ];
2548
2548
__block NSNumber * toBeDeletedCluster = @(MTRClusterIDTypeIdentifyID);
2549
2549
__block id identifyClusterData =
@@ -2553,11 +2553,11 @@ - (void)test012_testDataStorageUpdatesWhenRemovingClusters
2553
2553
MTRValueKey : toBeDeletedCluster,
2554
2554
}
2555
2555
};
2556
-
2556
+
2557
2557
delegate.onReportEnd = ^{
2558
2558
XCTAssertNotNil (dataVersionForServerList);
2559
2559
XCTAssertNotNil (testClusterDataValue);
2560
-
2560
+
2561
2561
// Make sure that the cluster data in the data storage has cluster ID - MTRClusterIDTypeIdentifyID in the cluster index for endpoint 1
2562
2562
// and cluster data for MTRClusterIDTypeIdentifyID exists
2563
2563
// We do not need to check _persistedClusterData here. _persistedClusterData will be paged in from storage when needed so
@@ -2571,15 +2571,15 @@ - (void)test012_testDataStorageUpdatesWhenRemovingClusters
2571
2571
});
2572
2572
[subscriptionExpectation fulfill ];
2573
2573
};
2574
-
2574
+
2575
2575
[device setDelegate: delegate queue: queue];
2576
-
2576
+
2577
2577
[self waitForExpectations: @[ subscriptionExpectation ] timeout: 60 ];
2578
-
2578
+
2579
2579
// Inject a fake attribute report after removing cluster ID - MTRClusterIDTypeIdentifyID from endpoint 1 to the server list.
2580
2580
dataVersionForServerList = [NSNumber numberWithUnsignedLongLong: (dataVersionForServerList.unsignedLongLongValue + 1 )];
2581
2581
[testClusterDataValue removeObject: identifyClusterData];
2582
-
2582
+
2583
2583
NSArray <NSDictionary <NSString *, id > *> * attributeReport = @[ @{
2584
2584
MTRAttributePathKey : [MTRAttributePath attributePathWithEndpointID: testEndpoint clusterID: @(MTRClusterIDTypeDescriptorID) attributeID: @(MTRAttributeIDTypeClusterDescriptorAttributeServerListID)],
2585
2585
MTRDataKey : @ {
@@ -2687,20 +2687,20 @@ - (void)test013_testDataStorageUpdatesWhenRemovingAttributes
2687
2687
XCTAssertNotNil (initialClusterIndex);
2688
2688
2689
2689
for (NSNumber * cluster in initialClusterIndex) {
2690
-
2690
+
2691
2691
// Make sure that the cluster data in the data storage is populated with cluster data for MTRClusterIDTypeIdentifyID cluster
2692
2692
// and has all attributes including attribute 1.
2693
2693
// We will be paged in the cluster data from storage to check the above.
2694
2694
MTRClusterPath * path = [MTRClusterPath clusterPathWithEndpointID: testEndpoint clusterID: cluster];
2695
-
2695
+
2696
2696
if ([cluster isEqualToNumber: @(MTRClusterIDTypeIdentifyID)]) {
2697
2697
MTRDeviceClusterData * data = [device _getClusterDataForPath: path];
2698
2698
XCTAssertNotNil (data);
2699
2699
XCTAssertNotNil (data.attributes );
2700
-
2700
+
2701
2701
NSDictionary * dict = [data.attributes objectForKey: @(MTRAttributeIDTypeGlobalAttributeAttributeListID)];
2702
2702
XCTAssertNotNil (dict);
2703
-
2703
+
2704
2704
NSMutableArray * persistedAttributes = [device arrayOfNumbersFromAttributeValue: dict];
2705
2705
NSMutableArray * testAttributes = [device arrayOfNumbersFromAttributeValue: @ { MTRTypeKey : MTRArrayValueType, MTRValueKey : testClusterDataValue }];
2706
2706
XCTAssertNotNil (persistedAttributes);
@@ -2741,7 +2741,7 @@ - (void)test013_testDataStorageUpdatesWhenRemovingAttributes
2741
2741
};
2742
2742
2743
2743
delegate.onReportEnd = ^{
2744
-
2744
+
2745
2745
// Make sure that the cluster data in the data storage is populated with cluster data for MTRClusterIDTypeIdentifyID cluster
2746
2746
// and has all attributes except attribute 1 which was deleted.
2747
2747
// We will be paged in the cluster data from storage to check the above.
0 commit comments