From 115102808250cb26d01971161402c769a01c1fb3 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 16 Feb 2023 04:42:26 +0100 Subject: [PATCH] [TestConstraints] Add some tests for the hasValue constraints (#25087) * [TestConstraints] Add some tests for the hasValue constraints * Update generated tests content --- src/app/tests/suites/TestConstraints.yaml | 78 ++++ .../chip-tool/zap-generated/test/Commands.h | 149 +++++++- .../zap-generated/test/Commands.h | 346 +++++++++++++++++- 3 files changed, 571 insertions(+), 2 deletions(-) diff --git a/src/app/tests/suites/TestConstraints.yaml b/src/app/tests/suites/TestConstraints.yaml index 92e74944420980..4ef38820de4464 100644 --- a/src/app/tests/suites/TestConstraints.yaml +++ b/src/app/tests/suites/TestConstraints.yaml @@ -265,3 +265,81 @@ tests: attribute: "char_string" arguments: value: "" + + # Tests for hasValue attribute + + - label: "Read attribute NULLABLE_INT8U Default Value" + command: "readAttribute" + attribute: "nullable_int8u" + response: + value: 0 + + - label: "Write attribute NULLABLE_INT8U with a value" + command: "writeAttribute" + attribute: "nullable_int8u" + arguments: + value: 0 + + - label: "Read attribute NULLABLE_INT8U with a value" + command: "readAttribute" + attribute: "nullable_int8u" + response: + constraints: + hasValue: true + + - label: "Write attribute NULLABLE_INT8U without a value" + command: "writeAttribute" + attribute: "nullable_int8u" + arguments: + value: null + + - label: "Read attribute NULLABLE_INT8U with a value" + command: "readAttribute" + attribute: "nullable_int8u" + response: + constraints: + hasValue: false + + - label: "Write attribute NULLABLE_INT8U back to Default Value" + command: "writeAttribute" + attribute: "nullable_int8u" + arguments: + value: 0 + + - label: "Read attribute NULLABLE_OCTET_STRING Default Value" + command: "readAttribute" + attribute: "nullable_octet_string" + response: + value: "" + + - label: "Write attribute NULLABLE_OCTET_STRING" + command: "writeAttribute" + attribute: "nullable_octet_string" + arguments: + value: "TestValue" + + - label: "Read attribute NULLABLE_OCTET_STRING" + command: "readAttribute" + attribute: "nullable_octet_string" + response: + constraints: + hasValue: true + + - label: "Write attribute NULLABLE_OCTET_STRING" + command: "writeAttribute" + attribute: "nullable_octet_string" + arguments: + value: null + + - label: "Read attribute NULLABLE_OCTET_STRING" + command: "readAttribute" + attribute: "nullable_octet_string" + response: + constraints: + hasValue: false + + - label: "Write attribute NULLABLE_OCTET_STRING back to Default Value" + command: "writeAttribute" + attribute: "nullable_octet_string" + arguments: + value: "" diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 5ab74d47019bee..d87d2612f627e9 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -64705,7 +64705,7 @@ class TestClusterComplexTypesSuite : public TestCommand class TestConstraintsSuite : public TestCommand { public: - TestConstraintsSuite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("TestConstraints", 33, credsIssuerConfig) + TestConstraintsSuite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("TestConstraints", 45, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -64944,6 +64944,71 @@ class TestConstraintsSuite : public TestCommand case 32: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::Nullable value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueNonNull("nullableInt8u", value)); + VerifyOrReturn(CheckValue("nullableInt8u.Value()", value.Value(), 0U)); + } + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::Nullable value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + } + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::Nullable value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + } + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::Nullable value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueNonNull("nullableOctetString", value)); + VerifyOrReturn(CheckValueAsString("nullableOctetString.Value()", value.Value(), + chip::ByteSpan(chip::Uint8::from_const_char(""), 0))); + } + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::Nullable value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + } + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::Nullable value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + } + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); } @@ -65175,6 +65240,88 @@ class TestConstraintsSuite : public TestCommand return WriteAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::CharString::Id, value, chip::NullOptional, chip::NullOptional); } + case 33: { + LogStep(33, "Read attribute NULLABLE_INT8U Default Value"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableInt8u::Id, true, + chip::NullOptional); + } + case 34: { + LogStep(34, "Write attribute NULLABLE_INT8U with a value"); + ListFreer listFreer; + chip::app::DataModel::Nullable value; + value.SetNonNull(); + value.Value() = 0U; + return WriteAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableInt8u::Id, + value, chip::NullOptional, chip::NullOptional); + } + case 35: { + LogStep(35, "Read attribute NULLABLE_INT8U with a value"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableInt8u::Id, true, + chip::NullOptional); + } + case 36: { + LogStep(36, "Write attribute NULLABLE_INT8U without a value"); + ListFreer listFreer; + chip::app::DataModel::Nullable value; + value.SetNull(); + return WriteAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableInt8u::Id, + value, chip::NullOptional, chip::NullOptional); + } + case 37: { + LogStep(37, "Read attribute NULLABLE_INT8U with a value"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableInt8u::Id, true, + chip::NullOptional); + } + case 38: { + LogStep(38, "Write attribute NULLABLE_INT8U back to Default Value"); + ListFreer listFreer; + chip::app::DataModel::Nullable value; + value.SetNonNull(); + value.Value() = 0U; + return WriteAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableInt8u::Id, + value, chip::NullOptional, chip::NullOptional); + } + case 39: { + LogStep(39, "Read attribute NULLABLE_OCTET_STRING Default Value"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableOctetString::Id, + true, chip::NullOptional); + } + case 40: { + LogStep(40, "Write attribute NULLABLE_OCTET_STRING"); + ListFreer listFreer; + chip::app::DataModel::Nullable value; + value.SetNonNull(); + value.Value() = chip::ByteSpan(chip::Uint8::from_const_char("TestValuegarbage: not in length on purpose"), 9); + return WriteAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableOctetString::Id, + value, chip::NullOptional, chip::NullOptional); + } + case 41: { + LogStep(41, "Read attribute NULLABLE_OCTET_STRING"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableOctetString::Id, + true, chip::NullOptional); + } + case 42: { + LogStep(42, "Write attribute NULLABLE_OCTET_STRING"); + ListFreer listFreer; + chip::app::DataModel::Nullable value; + value.SetNull(); + return WriteAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableOctetString::Id, + value, chip::NullOptional, chip::NullOptional); + } + case 43: { + LogStep(43, "Read attribute NULLABLE_OCTET_STRING"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableOctetString::Id, + true, chip::NullOptional); + } + case 44: { + LogStep(44, "Write attribute NULLABLE_OCTET_STRING back to Default Value"); + ListFreer listFreer; + chip::app::DataModel::Nullable value; + value.SetNonNull(); + value.Value() = chip::ByteSpan(chip::Uint8::from_const_char("garbage: not in length on purpose"), 0); + return WriteAttribute(kIdentityAlpha, GetEndpoint(1), UnitTesting::Id, UnitTesting::Attributes::NullableOctetString::Id, + value, chip::NullOptional, 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 9cb0ad902e8039..afaa82182b7039 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -93852,6 +93852,54 @@ class TestConstraints : public TestCommandBridge { ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute CHAR_STRING Value Back to Default Value\n"); err = TestWriteAttributeCharStringValueBackToDefaultValue_32(); break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute NULLABLE_INT8U Default Value\n"); + err = TestReadAttributeNullableInt8uDefaultValue_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Write attribute NULLABLE_INT8U with a value\n"); + err = TestWriteAttributeNullableInt8uWithAValue_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Read attribute NULLABLE_INT8U with a value\n"); + err = TestReadAttributeNullableInt8uWithAValue_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Write attribute NULLABLE_INT8U without a value\n"); + err = TestWriteAttributeNullableInt8uWithoutAValue_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Read attribute NULLABLE_INT8U with a value\n"); + err = TestReadAttributeNullableInt8uWithAValue_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Write attribute NULLABLE_INT8U back to Default Value\n"); + err = TestWriteAttributeNullableInt8uBackToDefaultValue_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Read attribute NULLABLE_OCTET_STRING Default Value\n"); + err = TestReadAttributeNullableOctetStringDefaultValue_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Write attribute NULLABLE_OCTET_STRING\n"); + err = TestWriteAttributeNullableOctetString_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute NULLABLE_OCTET_STRING\n"); + err = TestReadAttributeNullableOctetString_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute NULLABLE_OCTET_STRING\n"); + err = TestWriteAttributeNullableOctetString_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute NULLABLE_OCTET_STRING\n"); + err = TestReadAttributeNullableOctetString_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Write attribute NULLABLE_OCTET_STRING back to Default Value\n"); + err = TestWriteAttributeNullableOctetStringBackToDefaultValue_44(); + break; } if (CHIP_NO_ERROR != err) { @@ -93962,6 +94010,42 @@ class TestConstraints : public TestCommandBridge { case 32: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + 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; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; } // Go on to the next test. @@ -93975,7 +94059,7 @@ class TestConstraints : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 33; + const uint16_t mTestCount = 45; chip::Optional mNodeId; chip::Optional mCluster; @@ -94664,6 +94748,266 @@ class TestConstraints : public TestCommandBridge { return CHIP_NO_ERROR; } + + CHIP_ERROR TestReadAttributeNullableInt8uDefaultValue_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read attribute NULLABLE_INT8U Default Value Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uWithAValue_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Write attribute NULLABLE_INT8U with a value Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read attribute NULLABLE_INT8U with a value Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uWithoutAValue_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = nil; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Write attribute NULLABLE_INT8U without a value Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read attribute NULLABLE_INT8U with a value Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uBackToDefaultValue_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Write attribute NULLABLE_INT8U back to Default Value Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetStringDefaultValue_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); + VerifyOrReturn( + CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableOctetString_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableOctetStringArgument; + nullableOctetStringArgument = [[NSData alloc] initWithBytes:"TestValue" length:9]; + [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Write attribute NULLABLE_OCTET_STRING Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetString_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableOctetString_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableOctetStringArgument; + nullableOctetStringArgument = nil; + [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Write attribute NULLABLE_OCTET_STRING Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetString_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableOctetStringBackToDefaultValue_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableOctetStringArgument; + nullableOctetStringArgument = [[NSData alloc] initWithBytes:"" length:0]; + [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Write attribute NULLABLE_OCTET_STRING back to Default Value Error: %@", + err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } }; class TestDelayCommands : public TestCommandBridge {