From 414519022d0b06c0541a34bbb030aec01b15874d Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 19 Jul 2023 12:14:30 -0400 Subject: [PATCH] Add some tests for SetRegulatoryConfig. (#28063) We didn't seem to have any, apparently. This exercises the code changes made in https://github.com/project-chip/connectedhomeip/pull/27949 --- .../suites/TestGeneralCommissioning.yaml | 89 +++++ .../chip-tool/zap-generated/test/Commands.h | 157 ++++++++- .../zap-generated/test/Commands.h | 308 +++++++++++++++++- 3 files changed, 551 insertions(+), 3 deletions(-) diff --git a/src/app/tests/suites/TestGeneralCommissioning.yaml b/src/app/tests/suites/TestGeneralCommissioning.yaml index 01345d9dbe85d6..c7f50658d1a366 100644 --- a/src/app/tests/suites/TestGeneralCommissioning.yaml +++ b/src/app/tests/suites/TestGeneralCommissioning.yaml @@ -272,3 +272,92 @@ tests: response: constraints: type: boolean + + - label: "Read original regulatory location" + command: "readAttribute" + attribute: "RegulatoryConfig" + response: + saveAs: originalRegulatoryConfig + + - label: "Read original location" + command: "readAttribute" + cluster: "Basic Information" + attribute: "Location" + response: + value: "XX" + saveAs: originalLocation + + - label: "Try to SetRegulatoryConfig with 0-length country code" + command: "SetRegulatoryConfig" + arguments: + values: + - name: "NewRegulatoryConfig" + value: 0 + - name: "CountryCode" + value: "" + - name: "Breadcrumb" + value: 0 + response: + error: CONSTRAINT_ERROR + + - label: "Read back location" + command: "readAttribute" + cluster: "Basic Information" + attribute: "Location" + response: + value: originalLocation + + - label: "Try to SetRegulatoryConfig with length-1 country code" + command: "SetRegulatoryConfig" + arguments: + values: + - name: "NewRegulatoryConfig" + value: 0 + - name: "CountryCode" + value: "U" + - name: "Breadcrumb" + value: 0 + response: + error: CONSTRAINT_ERROR + + - label: "Read back location second time" + command: "readAttribute" + cluster: "Basic Information" + attribute: "Location" + response: + value: originalLocation + + - label: "Try to SetRegulatoryConfig with length-2 country code" + command: "SetRegulatoryConfig" + arguments: + values: + - name: "NewRegulatoryConfig" + value: 0 + - name: "CountryCode" + value: "US" + - name: "Breadcrumb" + value: 0 + response: + values: + - name: "ErrorCode" + value: 0 + - name: "DebugText" + value: "" + + - label: "Read back location third time" + command: "readAttribute" + cluster: "Basic Information" + attribute: "Location" + response: + value: "US" + + - label: "Restore initial values" + command: "SetRegulatoryConfig" + arguments: + values: + - name: "NewRegulatoryConfig" + value: originalRegulatoryConfig + - name: "CountryCode" + value: originalLocation + - name: "Breadcrumb" + value: 0 diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index ab052ad7899257..8a8c4ebcd364bf 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -84601,7 +84601,7 @@ class TestGeneralCommissioningSuite : public TestCommand { public: TestGeneralCommissioningSuite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestGeneralCommissioning", 31, credsIssuerConfig) + TestCommand("TestGeneralCommissioning", 40, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -84611,7 +84611,14 @@ class TestGeneralCommissioningSuite : public TestCommand AddArgument("timeout", 0, UINT16_MAX, &mTimeout); } - ~TestGeneralCommissioningSuite() {} + ~TestGeneralCommissioningSuite() + { + if (originalLocationBuffer != nullptr) + { + chip::Platform::MemoryFree(originalLocationBuffer); + originalLocationBuffer = nullptr; + } + } chip::System::Clock::Timeout GetWaitDuration() const override { @@ -84626,6 +84633,10 @@ class TestGeneralCommissioningSuite : public TestCommand chip::Optional mPayload; chip::Optional mTimeout; + chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum originalRegulatoryConfig; + char * originalLocationBuffer = nullptr; + chip::CharSpan originalLocation; + chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } // @@ -84841,6 +84852,75 @@ class TestGeneralCommissioningSuite : public TestCommand VerifyOrReturn(CheckConstraintType("value", "boolean", "boolean")); } break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + originalRegulatoryConfig = value; + } + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::CharSpan value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueAsString("location", value, chip::CharSpan("XX", 2))); + if (originalLocationBuffer != nullptr) + { + chip::Platform::MemoryFree(originalLocationBuffer); + } + originalLocationBuffer = static_cast(chip::Platform::MemoryAlloc(value.size())); + memcpy(originalLocationBuffer, value.data(), value.size()); + originalLocation = chip::CharSpan(originalLocationBuffer, value.size()); + } + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::CharSpan value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueAsString("location", value, originalLocation)); + } + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::CharSpan value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueAsString("location", value, originalLocation)); + } + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("errorCode", value.errorCode, 0U)); + VerifyOrReturn(CheckValueAsString("debugText", value.debugText, chip::CharSpan("", 0))); + } + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::CharSpan value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueAsString("location", value, chip::CharSpan("US", 2))); + } + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + } + break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); } @@ -85081,6 +85161,79 @@ class TestGeneralCommissioningSuite : public TestCommand return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GeneralCommissioning::Id, GeneralCommissioning::Attributes::SupportsConcurrentConnection::Id, true, chip::NullOptional); } + case 31: { + LogStep(31, "Read original regulatory location"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GeneralCommissioning::Id, + GeneralCommissioning::Attributes::RegulatoryConfig::Id, true, chip::NullOptional); + } + case 32: { + LogStep(32, "Read original location"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), BasicInformation::Id, BasicInformation::Attributes::Location::Id, + true, chip::NullOptional); + } + case 33: { + LogStep(33, "Try to SetRegulatoryConfig with 0-length country code"); + ListFreer listFreer; + chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfig::Type value; + value.newRegulatoryConfig = static_cast(0); + value.countryCode = chip::Span("garbage: not in length on purpose", 0); + value.breadcrumb = 0ULL; + return SendCommand(kIdentityAlpha, GetEndpoint(0), GeneralCommissioning::Id, + GeneralCommissioning::Commands::SetRegulatoryConfig::Id, value, chip::NullOptional + + ); + } + case 34: { + LogStep(34, "Read back location"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), BasicInformation::Id, BasicInformation::Attributes::Location::Id, + true, chip::NullOptional); + } + case 35: { + LogStep(35, "Try to SetRegulatoryConfig with length-1 country code"); + ListFreer listFreer; + chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfig::Type value; + value.newRegulatoryConfig = static_cast(0); + value.countryCode = chip::Span("Ugarbage: not in length on purpose", 1); + value.breadcrumb = 0ULL; + return SendCommand(kIdentityAlpha, GetEndpoint(0), GeneralCommissioning::Id, + GeneralCommissioning::Commands::SetRegulatoryConfig::Id, value, chip::NullOptional + + ); + } + case 36: { + LogStep(36, "Read back location second time"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), BasicInformation::Id, BasicInformation::Attributes::Location::Id, + true, chip::NullOptional); + } + case 37: { + LogStep(37, "Try to SetRegulatoryConfig with length-2 country code"); + ListFreer listFreer; + chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfig::Type value; + value.newRegulatoryConfig = static_cast(0); + value.countryCode = chip::Span("USgarbage: not in length on purpose", 2); + value.breadcrumb = 0ULL; + return SendCommand(kIdentityAlpha, GetEndpoint(0), GeneralCommissioning::Id, + GeneralCommissioning::Commands::SetRegulatoryConfig::Id, value, chip::NullOptional + + ); + } + case 38: { + LogStep(38, "Read back location third time"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), BasicInformation::Id, BasicInformation::Attributes::Location::Id, + true, chip::NullOptional); + } + case 39: { + LogStep(39, "Restore initial values"); + ListFreer listFreer; + chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfig::Type value; + value.newRegulatoryConfig = originalRegulatoryConfig; + value.countryCode = originalLocation; + value.breadcrumb = 0ULL; + return SendCommand(kIdentityAlpha, GetEndpoint(0), GeneralCommissioning::Id, + GeneralCommissioning::Commands::SetRegulatoryConfig::Id, value, chip::NullOptional + + ); + } } return CHIP_NO_ERROR; } diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index ce2f23e21bf64d..cfb01e1f3e79fd 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -112990,6 +112990,42 @@ class TestGeneralCommissioning : public TestCommandBridge { ChipLogProgress(chipTool, " ***** Test Step 30 : Validate presence of SupportsConcurrentConnection\n"); err = TestValidatePresenceOfSupportsConcurrentConnection_30(); break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Read original regulatory location\n"); + err = TestReadOriginalRegulatoryLocation_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Read original location\n"); + err = TestReadOriginalLocation_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Try to SetRegulatoryConfig with 0-length country code\n"); + err = TestTryToSetRegulatoryConfigWith0LengthCountryCode_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Read back location\n"); + err = TestReadBackLocation_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Try to SetRegulatoryConfig with length-1 country code\n"); + err = TestTryToSetRegulatoryConfigWithLength1CountryCode_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Read back location second time\n"); + err = TestReadBackLocationSecondTime_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Try to SetRegulatoryConfig with length-2 country code\n"); + err = TestTryToSetRegulatoryConfigWithLength2CountryCode_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Read back location third time\n"); + err = TestReadBackLocationThirdTime_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Restore initial values\n"); + err = TestRestoreInitialValues_39(); + break; } if (CHIP_NO_ERROR != err) { @@ -113094,6 +113130,33 @@ class TestGeneralCommissioning : public TestCommandBridge { case 30: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; } // Go on to the next test. @@ -113107,7 +113170,7 @@ class TestGeneralCommissioning : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; + const uint16_t mTestCount = 40; chip::Optional mNodeId; chip::Optional mCluster; @@ -113817,6 +113880,249 @@ class TestGeneralCommissioning : public TestCommandBridge { NextTest(); }]; + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull originalRegulatoryConfig; + + CHIP_ERROR TestReadOriginalRegulatoryLocation_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRegulatoryConfigWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read original regulatory location Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + originalRegulatoryConfig = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSString * _Nonnull originalLocation; + + CHIP_ERROR TestReadOriginalLocation_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read original location Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("Location", actualValue, @"XX")); + } + { + originalLocation = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToSetRegulatoryConfigWith0LengthCountryCode_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; + params.newRegulatoryConfig = [NSNumber numberWithUnsignedChar:0U]; + params.countryCode = @""; + params.breadcrumb = [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster + setRegulatoryConfigWithParams:params + completion:^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Try to SetRegulatoryConfig with 0-length country code Error: %@", err); + + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackLocation_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read back location Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToSetRegulatoryConfigWithLength1CountryCode_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; + params.newRegulatoryConfig = [NSNumber numberWithUnsignedChar:0U]; + params.countryCode = @"U"; + params.breadcrumb = [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster + setRegulatoryConfigWithParams:params + completion:^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Try to SetRegulatoryConfig with length-1 country code Error: %@", err); + + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackLocationSecondTime_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read back location second time Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToSetRegulatoryConfigWithLength2CountryCode_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; + params.newRegulatoryConfig = [NSNumber numberWithUnsignedChar:0U]; + params.countryCode = @"US"; + params.breadcrumb = [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster setRegulatoryConfigWithParams:params + completion:^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Try to SetRegulatoryConfig with length-2 country code Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); + } + + { + id actualValue = values.debugText; + VerifyOrReturn(CheckValueAsString("DebugText", actualValue, @"")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackLocationThirdTime_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read back location third time Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("Location", actualValue, @"US")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRestoreInitialValues_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; + params.newRegulatoryConfig = [originalRegulatoryConfig copy]; + params.countryCode = [originalLocation copy]; + params.breadcrumb = [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster setRegulatoryConfigWithParams:params + completion:^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Restore initial values Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + return CHIP_NO_ERROR; } };