From 1264793dece1f0e883c7986d6585d83c3cf1acac Mon Sep 17 00:00:00 2001 From: raju-apple <84206864+raju-apple@users.noreply.github.com> Date: Mon, 9 Aug 2021 09:45:39 -0700 Subject: [PATCH] Tests add test tc flw 1 1 occ 1 1 tm 1 1 yaml (#8823) * Adding Test_TC_FLW_1_1.yaml,Test_TC_OCC_1_1.yaml,Test_TC_TM_1_1.yaml to the tree and update the appropriate templates * Update generated tests --- examples/chip-tool/commands/tests/Commands.h | 389 ++++++++++++++++++ .../chip-tool/templates/tests-commands.zapt | 2 +- .../suites/certification/Test_TC_FLW_1_1.yaml | 45 ++ .../suites/certification/Test_TC_OCC_1_1.yaml | 43 ++ .../suites/certification/Test_TC_TM_1_1.yaml | 43 ++ .../CHIP/templates/clusters-tests.zapt | 2 +- .../Framework/CHIPTests/CHIPClustersTests.m | 74 ++++ 7 files changed, 596 insertions(+), 2 deletions(-) create mode 100644 src/app/tests/suites/certification/Test_TC_FLW_1_1.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_OCC_1_1.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_TM_1_1.yaml diff --git a/examples/chip-tool/commands/tests/Commands.h b/examples/chip-tool/commands/tests/Commands.h index 652a75084aa918..9da11f5a976598 100644 --- a/examples/chip-tool/commands/tests/Commands.h +++ b/examples/chip-tool/commands/tests/Commands.h @@ -17829,6 +17829,392 @@ class Test_TC_BI_1_1 : public TestCommand } }; +class Test_TC_FLW_1_1 : public TestCommand +{ +public: + Test_TC_FLW_1_1() : TestCommand("Test_TC_FLW_1_1"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "Test_TC_FLW_1_1: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "Test_TC_FLW_1_1: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 0; + + // + // Tests methods + // +}; + +class Test_TC_TM_1_1 : public TestCommand +{ +public: + Test_TC_TM_1_1() : TestCommand("Test_TC_TM_1_1"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "Test_TC_TM_1_1: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterTemperatureMeasurementCommandReadAttribute_0(); + break; + case 1: + err = TestSendClusterTemperatureMeasurementCommandReadAttribute_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "Test_TC_TM_1_1: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + // + // Tests methods + // + + // Test read the global attribute: ClusterRevision + using SuccessCallback_0 = void (*)(void * context, uint16_t clusterRevision); + chip::Callback::Callback mOnSuccessCallback_0{ + OnTestSendClusterTemperatureMeasurementCommandReadAttribute_0_SuccessResponse, this + }; + chip::Callback::Callback mOnFailureCallback_0{ + OnTestSendClusterTemperatureMeasurementCommandReadAttribute_0_FailureResponse, this + }; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterTemperatureMeasurementCommandReadAttribute_0() + { + ChipLogProgress(chipTool, "Temperature Measurement - read the global attribute: ClusterRevision: Sending command..."); + + chip::Controller::TemperatureMeasurementCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeClusterRevision(mOnSuccessCallback_0.Cancel(), mOnFailureCallback_0.Cancel()); + + return err; + } + + static void OnTestSendClusterTemperatureMeasurementCommandReadAttribute_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Temperature Measurement - read the global attribute: ClusterRevision: Failure Response"); + + Test_TC_TM_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterTemperatureMeasurementCommandReadAttribute_0_SuccessResponse(void * context, + uint16_t clusterRevision) + { + ChipLogProgress(chipTool, "Temperature Measurement - read the global attribute: ClusterRevision: Success Response"); + + Test_TC_TM_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (clusterRevision != 3U) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "3"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test reads back global attribute: ClusterRevision + using SuccessCallback_1 = void (*)(void * context, uint16_t clusterRevision); + chip::Callback::Callback mOnSuccessCallback_1{ + OnTestSendClusterTemperatureMeasurementCommandReadAttribute_1_SuccessResponse, this + }; + chip::Callback::Callback mOnFailureCallback_1{ + OnTestSendClusterTemperatureMeasurementCommandReadAttribute_1_FailureResponse, this + }; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterTemperatureMeasurementCommandReadAttribute_1() + { + ChipLogProgress(chipTool, "Temperature Measurement - reads back global attribute: ClusterRevision: Sending command..."); + + chip::Controller::TemperatureMeasurementCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeClusterRevision(mOnSuccessCallback_1.Cancel(), mOnFailureCallback_1.Cancel()); + + return err; + } + + static void OnTestSendClusterTemperatureMeasurementCommandReadAttribute_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Temperature Measurement - reads back global attribute: ClusterRevision: Failure Response"); + + Test_TC_TM_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterTemperatureMeasurementCommandReadAttribute_1_SuccessResponse(void * context, + uint16_t clusterRevision) + { + ChipLogProgress(chipTool, "Temperature Measurement - reads back global attribute: ClusterRevision: Success Response"); + + Test_TC_TM_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (clusterRevision != 3U) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "3"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class Test_TC_OCC_1_1 : public TestCommand +{ +public: + Test_TC_OCC_1_1() : TestCommand("Test_TC_OCC_1_1"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "Test_TC_OCC_1_1: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterOccupancySensingCommandReadAttribute_0(); + break; + case 1: + err = TestSendClusterOccupancySensingCommandReadAttribute_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "Test_TC_OCC_1_1: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + // + // Tests methods + // + + // Test read the global attribute: ClusterRevision + using SuccessCallback_0 = void (*)(void * context, uint16_t clusterRevision); + chip::Callback::Callback mOnSuccessCallback_0{ + OnTestSendClusterOccupancySensingCommandReadAttribute_0_SuccessResponse, this + }; + chip::Callback::Callback mOnFailureCallback_0{ + OnTestSendClusterOccupancySensingCommandReadAttribute_0_FailureResponse, this + }; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterOccupancySensingCommandReadAttribute_0() + { + ChipLogProgress(chipTool, "Occupancy Sensing - read the global attribute: ClusterRevision: Sending command..."); + + chip::Controller::OccupancySensingCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeClusterRevision(mOnSuccessCallback_0.Cancel(), mOnFailureCallback_0.Cancel()); + + return err; + } + + static void OnTestSendClusterOccupancySensingCommandReadAttribute_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Occupancy Sensing - read the global attribute: ClusterRevision: Failure Response"); + + Test_TC_OCC_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterOccupancySensingCommandReadAttribute_0_SuccessResponse(void * context, uint16_t clusterRevision) + { + ChipLogProgress(chipTool, "Occupancy Sensing - read the global attribute: ClusterRevision: Success Response"); + + Test_TC_OCC_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (clusterRevision != 2U) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "2"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test reads back global attribute: ClusterRevision + using SuccessCallback_1 = void (*)(void * context, uint16_t clusterRevision); + chip::Callback::Callback mOnSuccessCallback_1{ + OnTestSendClusterOccupancySensingCommandReadAttribute_1_SuccessResponse, this + }; + chip::Callback::Callback mOnFailureCallback_1{ + OnTestSendClusterOccupancySensingCommandReadAttribute_1_FailureResponse, this + }; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterOccupancySensingCommandReadAttribute_1() + { + ChipLogProgress(chipTool, "Occupancy Sensing - reads back global attribute: ClusterRevision: Sending command..."); + + chip::Controller::OccupancySensingCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeClusterRevision(mOnSuccessCallback_1.Cancel(), mOnFailureCallback_1.Cancel()); + + return err; + } + + static void OnTestSendClusterOccupancySensingCommandReadAttribute_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Occupancy Sensing - reads back global attribute: ClusterRevision: Failure Response"); + + Test_TC_OCC_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterOccupancySensingCommandReadAttribute_1_SuccessResponse(void * context, uint16_t clusterRevision) + { + ChipLogProgress(chipTool, "Occupancy Sensing - reads back global attribute: ClusterRevision: Success Response"); + + Test_TC_OCC_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (clusterRevision != 2U) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "2"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + void registerCommandsTests(Commands & commands) { const char * clusterName = "Tests"; @@ -17857,6 +18243,9 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), + make_unique(), + make_unique(), }; commands.Register(clusterName, clusterCommands); diff --git a/examples/chip-tool/templates/tests-commands.zapt b/examples/chip-tool/templates/tests-commands.zapt index 957c8b4fc8fdd8..c8ffe6bff32113 100644 --- a/examples/chip-tool/templates/tests-commands.zapt +++ b/examples/chip-tool/templates/tests-commands.zapt @@ -4,4 +4,4 @@ #include "TestCommand.h" -{{>test_cluster tests="TV_TargetNavigatorCluster, TV_AudioOutputCluster, TV_ApplicationLauncherCluster, TV_KeypadInputCluster, TV_AccountLoginCluster, TV_ApplicationBasicCluster, TV_MediaPlaybackCluster, TV_TvChannelCluster, TV_LowPowerCluster, TV_MediaInputCluster, TestCluster, Test_TC_OO_1_1, Test_TC_OO_2_1, Test_TC_OO_2_2, Test_TC_DM_1_1, Test_TC_DM_3_1, Test_TC_CC_3_4, Test_TC_CC_5, Test_TC_CC_6, Test_TC_CC_7, Test_TC_WNCV_1_1, Test_TC_WNCV_2_1, Test_TC_BI_1_1"}} +{{>test_cluster tests="TV_TargetNavigatorCluster, TV_AudioOutputCluster, TV_ApplicationLauncherCluster, TV_KeypadInputCluster, TV_AccountLoginCluster, TV_ApplicationBasicCluster, TV_MediaPlaybackCluster, TV_TvChannelCluster, TV_LowPowerCluster, TV_MediaInputCluster, TestCluster, Test_TC_OO_1_1, Test_TC_OO_2_1, Test_TC_OO_2_2, Test_TC_DM_1_1, Test_TC_DM_3_1, Test_TC_CC_3_4, Test_TC_CC_5, Test_TC_CC_6, Test_TC_CC_7, Test_TC_WNCV_1_1, Test_TC_WNCV_2_1, Test_TC_BI_1_1, Test_TC_FLW_1_1, Test_TC_TM_1_1, Test_TC_OCC_1_1"}} diff --git a/src/app/tests/suites/certification/Test_TC_FLW_1_1.yaml b/src/app/tests/suites/certification/Test_TC_FLW_1_1.yaml new file mode 100644 index 00000000000000..49ff90ade72779 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_FLW_1_1.yaml @@ -0,0 +1,45 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 27.1.1. [TC-FLW-1.1] Global attributes with server as DUT + +config: + cluster: "Flow Measurement" + endpoint: 1 + +tests: + - label: "read the global attribute: ClusterRevision" + command: "readAttribute" + disabled: true + attribute: "ClusterRevision" + response: + value: 2 + + - label: + "write the default values to mandatory global attribute: + ClusterRevision" + disabled: true + command: "writeAttribute" + attribute: "ClusterRevision" + arguments: + value: 2 + response: + error: 1 + + - label: "reads back global attribute: ClusterRevision" + command: "readAttribute" + disabled: true + attribute: "ClusterRevision" + response: + value: 2 diff --git a/src/app/tests/suites/certification/Test_TC_OCC_1_1.yaml b/src/app/tests/suites/certification/Test_TC_OCC_1_1.yaml new file mode 100644 index 00000000000000..661d9dfbe91ad1 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_OCC_1_1.yaml @@ -0,0 +1,43 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 24.1.1. [TC-OCC-1.1] Global attributes with server as DUT + +config: + cluster: "Occupancy Sensing" + endpoint: 1 + +tests: + - label: "read the global attribute: ClusterRevision" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 2 + + - label: + "write the default values to mandatory global attribute: + ClusterRevision" + disabled: true + command: "writeAttribute" + attribute: "ClusterRevision" + arguments: + value: 2 + response: + error: 1 + + - label: "reads back global attribute: ClusterRevision" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 2 diff --git a/src/app/tests/suites/certification/Test_TC_TM_1_1.yaml b/src/app/tests/suites/certification/Test_TC_TM_1_1.yaml new file mode 100644 index 00000000000000..03524a3a719d4a --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_TM_1_1.yaml @@ -0,0 +1,43 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 6.1.1. [TC-TM-1.1] Global attributes with server as DUT + +config: + cluster: "Temperature Measurement" + endpoint: 1 + +tests: + - label: "read the global attribute: ClusterRevision" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 3 + + - label: + "write the default values to mandatory global attribute: + ClusterRevision" + disabled: true + command: "writeAttribute" + attribute: "ClusterRevision" + arguments: + value: 3 + response: + error: 1 + + - label: "reads back global attribute: ClusterRevision" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 3 diff --git a/src/darwin/Framework/CHIP/templates/clusters-tests.zapt b/src/darwin/Framework/CHIP/templates/clusters-tests.zapt index 0da33c0e375b40..1d6a9ef55ced17 100644 --- a/src/darwin/Framework/CHIP/templates/clusters-tests.zapt +++ b/src/darwin/Framework/CHIP/templates/clusters-tests.zapt @@ -134,7 +134,7 @@ CHIPDevice * GetPairedDevice(uint64_t deviceId) [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -{{>test_cluster tests="TestCluster, Test_TC_OO_1_1, Test_TC_OO_2_1, Test_TC_OO_2_2, Test_TC_DM_1_1, Test_TC_DM_3_1, Test_TC_CC_3_4, Test_TC_CC_5, Test_TC_CC_6, Test_TC_CC_7, Test_TC_WNCV_1_1, Test_TC_WNCV_2_1, Test_TC_BI_1_1"}} +{{>test_cluster tests="TestCluster, Test_TC_OO_1_1, Test_TC_OO_2_1, Test_TC_OO_2_2, Test_TC_DM_1_1, Test_TC_DM_3_1, Test_TC_CC_3_4, Test_TC_CC_5, Test_TC_CC_6, Test_TC_CC_7, Test_TC_WNCV_1_1, Test_TC_WNCV_2_1, Test_TC_BI_1_1, Test_TC_FLW_1_1, Test_TC_TM_1_1, Test_TC_OCC_1_1"}} {{#chip_client_clusters}} {{#unless (isStrEqual "Test Cluster" name)}} diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 0b68aee83a823a..859939bd62ed29 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -4633,6 +4633,80 @@ - (void)testSendClusterTest_TC_BI_1_1_000001_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterTest_TC_TM_1_1_000000_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"read the global attribute: ClusterRevision"]; + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTemperatureMeasurement * cluster = [[CHIPTemperatureMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeClusterRevisionWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"read the global attribute: ClusterRevision Error: %@", err); + + XCTAssertEqual(err.code, 0); + XCTAssertEqual([values[@"value"] unsignedShortValue], 3); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_TM_1_1_000001_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"reads back global attribute: ClusterRevision"]; + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTemperatureMeasurement * cluster = [[CHIPTemperatureMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeClusterRevisionWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"reads back global attribute: ClusterRevision Error: %@", err); + + XCTAssertEqual(err.code, 0); + XCTAssertEqual([values[@"value"] unsignedShortValue], 3); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterTest_TC_OCC_1_1_000000_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"read the global attribute: ClusterRevision"]; + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPOccupancySensing * cluster = [[CHIPOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeClusterRevisionWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"read the global attribute: ClusterRevision Error: %@", err); + + XCTAssertEqual(err.code, 0); + XCTAssertEqual([values[@"value"] unsignedShortValue], 2); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_OCC_1_1_000001_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"reads back global attribute: ClusterRevision"]; + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPOccupancySensing * cluster = [[CHIPOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeClusterRevisionWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"reads back global attribute: ClusterRevision Error: %@", err); + + XCTAssertEqual(err.code, 0); + XCTAssertEqual([values[@"value"] unsignedShortValue], 2); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterAccountLoginReadAttributeClusterRevisionWithResponseHandler { XCTestExpectation * expectation =