From bf9c86ad0adaa92d72d7052249a8c24cd490c9ce Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Mon, 12 Feb 2024 17:01:03 +0100 Subject: [PATCH] [placeholder] Remove tests generated with zap (#32038) * [placeholder] Remove examples/placeholder tests codegen * Remove src/app/tests/suites/pics * Remove src/app/tests/suites/include * Remove src/app/tests/suites/templates * Remove src/app/tests/suites/commands/[delay|discovery|log|system] * Remove examples/darwin-framework-tool/commands/tests/TestCommandBridge.h --- docs/guides/simulated_device_linux.md | 33 +- .../commands/tests/TestCommandBridge.h | 678 ------- examples/placeholder/linux/BUILD.gn | 4 - .../placeholder/linux/apps/app1/ciTests.json | 20 - .../linux/apps/app1/templates/templates.json | 72 - .../linux/apps/app2/templates/templates.json | 72 - .../linux/include/MatterCallbacks.h | 54 - .../placeholder/linux/include/TestCommand.h | 194 -- examples/placeholder/linux/main.cpp | 11 - .../placeholder/templates/tests-commands.zapt | 33 - scripts/examples/gn_build_test_example.sh | 3 - scripts/tools/zap_regen_all.py | 32 - src/app/common/BUILD.gn | 8 - src/app/tests/suites/commands/delay/BUILD.gn | 34 - .../suites/commands/delay/DelayCommands.cpp | 77 - .../suites/commands/delay/DelayCommands.h | 58 - .../commands/delay/scripts/WaitForMessage.py | 33 - .../tests/suites/commands/discovery/BUILD.gn | 36 - .../commands/discovery/DiscoveryCommands.cpp | 216 --- .../commands/discovery/DiscoveryCommands.h | 70 - src/app/tests/suites/commands/log/BUILD.gn | 32 - .../tests/suites/commands/log/LogCommands.cpp | 44 - .../tests/suites/commands/log/LogCommands.h | 35 - src/app/tests/suites/commands/system/BUILD.gn | 32 - .../suites/commands/system/SystemCommands.cpp | 187 -- .../suites/commands/system/SystemCommands.h | 46 - .../commands/system/scripts/CompareFiles.py | 31 - .../commands/system/scripts/CreateOtaImage.py | 33 - .../commands/system/scripts/FactoryReset.py | 28 - .../suites/commands/system/scripts/Reboot.py | 28 - .../suites/commands/system/scripts/Start.py | 29 - .../suites/commands/system/scripts/Stop.py | 28 - .../tests/suites/include/ConstraintsChecker.h | 678 ------- src/app/tests/suites/include/PICSChecker.h | 49 - src/app/tests/suites/include/TestRunner.h | 100 - src/app/tests/suites/include/ValueChecker.h | 221 --- src/app/tests/suites/pics/BUILD.gn | 33 - .../pics/PICSBooleanExpressionParser.cpp | 165 -- .../suites/pics/PICSBooleanExpressionParser.h | 49 - .../tests/suites/pics/PICSBooleanReader.cpp | 68 - src/app/tests/suites/pics/PICSBooleanReader.h | 31 - src/app/tests/suites/pics/PICSNormalizer.cpp | 30 - src/app/tests/suites/pics/PICSNormalizer.h | 28 - .../templates/simulated-cluster-objects.zapt | 132 -- src/app/tests/suites/templates/templates.json | 29 - .../Matter.xcodeproj/project.pbxproj | 64 - .../tests/simulated-cluster-objects.h | 1551 --------------- .../app1/zap-generated/test/Commands.h | 1719 ----------------- .../app2/zap-generated/test/Commands.h | 1719 ----------------- 49 files changed, 2 insertions(+), 8955 deletions(-) delete mode 100644 examples/darwin-framework-tool/commands/tests/TestCommandBridge.h delete mode 100644 examples/placeholder/linux/apps/app1/ciTests.json delete mode 100644 examples/placeholder/linux/apps/app1/templates/templates.json delete mode 100644 examples/placeholder/linux/apps/app2/templates/templates.json delete mode 100644 examples/placeholder/linux/include/TestCommand.h delete mode 100644 examples/placeholder/templates/tests-commands.zapt delete mode 100644 src/app/tests/suites/commands/delay/BUILD.gn delete mode 100644 src/app/tests/suites/commands/delay/DelayCommands.cpp delete mode 100644 src/app/tests/suites/commands/delay/DelayCommands.h delete mode 100755 src/app/tests/suites/commands/delay/scripts/WaitForMessage.py delete mode 100644 src/app/tests/suites/commands/discovery/BUILD.gn delete mode 100644 src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp delete mode 100644 src/app/tests/suites/commands/discovery/DiscoveryCommands.h delete mode 100644 src/app/tests/suites/commands/log/BUILD.gn delete mode 100644 src/app/tests/suites/commands/log/LogCommands.cpp delete mode 100644 src/app/tests/suites/commands/log/LogCommands.h delete mode 100644 src/app/tests/suites/commands/system/BUILD.gn delete mode 100644 src/app/tests/suites/commands/system/SystemCommands.cpp delete mode 100644 src/app/tests/suites/commands/system/SystemCommands.h delete mode 100755 src/app/tests/suites/commands/system/scripts/CompareFiles.py delete mode 100755 src/app/tests/suites/commands/system/scripts/CreateOtaImage.py delete mode 100755 src/app/tests/suites/commands/system/scripts/FactoryReset.py delete mode 100755 src/app/tests/suites/commands/system/scripts/Reboot.py delete mode 100755 src/app/tests/suites/commands/system/scripts/Start.py delete mode 100755 src/app/tests/suites/commands/system/scripts/Stop.py delete mode 100644 src/app/tests/suites/include/ConstraintsChecker.h delete mode 100644 src/app/tests/suites/include/PICSChecker.h delete mode 100644 src/app/tests/suites/include/TestRunner.h delete mode 100644 src/app/tests/suites/include/ValueChecker.h delete mode 100644 src/app/tests/suites/pics/BUILD.gn delete mode 100644 src/app/tests/suites/pics/PICSBooleanExpressionParser.cpp delete mode 100644 src/app/tests/suites/pics/PICSBooleanExpressionParser.h delete mode 100644 src/app/tests/suites/pics/PICSBooleanReader.cpp delete mode 100644 src/app/tests/suites/pics/PICSBooleanReader.h delete mode 100644 src/app/tests/suites/pics/PICSNormalizer.cpp delete mode 100644 src/app/tests/suites/pics/PICSNormalizer.h delete mode 100644 src/app/tests/suites/templates/simulated-cluster-objects.zapt delete mode 100644 src/app/tests/suites/templates/templates.json delete mode 100644 zzz_generated/app-common/app-common/zap-generated/tests/simulated-cluster-objects.h delete mode 100644 zzz_generated/placeholder/app1/zap-generated/test/Commands.h delete mode 100644 zzz_generated/placeholder/app2/zap-generated/test/Commands.h diff --git a/docs/guides/simulated_device_linux.md b/docs/guides/simulated_device_linux.md index 686a5387eb6eb9..81d36c90347115 100644 --- a/docs/guides/simulated_device_linux.md +++ b/docs/guides/simulated_device_linux.md @@ -11,11 +11,6 @@ If some parameters need to be overridden, a `CHIPProjectConfig.h` file can be placed under an ‘include’ folder into the app folder. For example `examples/placeholder/linux/apps/app1/include/CHIPProjectConfig.h` -In order to generate specific tests for a given accessory, a -[examples/placeholder/linux/apps/app1/tests.js](../../examples/placeholder/linux/apps/app1/tests.js) -file can be added into the application directory. The tests listed there are the -one that will be executed once the application has been commissioned. - Simulated Device: simulation of an application in which tests can be added. It is defined by a ZAP config file and tests can be added with a [YAML file](../../src/app/tests/suites/certification/Test_TC_DM_1_3_Simulated.yaml). @@ -66,7 +61,7 @@ Now that the building is completed there is a `chip-app1` binary created. This binary can be executed on a linux os with test commands. ``` -./out/debug/simulated/chip-app1 --command [TEST NAME] +./scripts/tests/yaml/runner.py [TEST NAME] app1 ``` ## Interacting with the simulated app @@ -99,8 +94,7 @@ interact with it using chip-tool ## Adding simulated Tests via YAML In order to validate commissioner/controller behavior, tests need to be added to -the simulated device test framework. To achieve this, YAML files are created and -new code is generated. +the simulated device test framework. To achieve this, YAML files are created. 1. YAML test file are located in [YAML folder](../../src/app/tests/suites/certification/) @@ -124,26 +118,3 @@ new code is generated. 5. [Test_TC_DM_1_3_Simulated](../../src/app/tests/suites/certification/Test_TC_DM_1_3_Simulated.yaml) is an example of a written test that runs on the simulated device. - -6. Next, it will need to be added to - [examples/placeholder/linux/apps/app1/tests.js](../../examples/placeholder/linux/apps/app1/tests.js) - in the following array: - - ```javascript - const tests = ["Test_TC_DM_1_3_Simulated"]; - ``` - -7. Then, the code will be generated using ZAP. - - ``` - ./scripts/tools/zap/generate.py examples/placeholder/linux/apps/app1/config.zap -t examples/placeholder/templates/templates.json -o zzz_generated/placeholder/app1/zap-generated - ``` - - The following command can be used to generate and compile: - - ``` - ./scripts/examples/gn_build_test_example.sh app1 - ``` - -8) When submitting code for review, create 2 commits. One for YAML changes and - second for generated code. diff --git a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h deleted file mode 100644 index 0c87c96cfe65d1..00000000000000 --- a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h +++ /dev/null @@ -1,678 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#pragma once - -#include "../common/CHIPCommandBridge.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#import - -#import "MTRDevice_Externs.h" -#import "MTRError_Utils.h" - -class TestCommandBridge; - -NS_ASSUME_NONNULL_BEGIN -namespace { -const char basePath[] = "./src/app/tests/suites/commands/delay/scripts/"; -const char * getScriptsFolder() { return basePath; } -} // namespace - -inline constexpr char kDefaultKey[] = "default"; - -@interface TestDeviceControllerDelegate : NSObject -@property TestCommandBridge * commandBridge; -@property chip::NodeId deviceId; -@property BOOL active; // Whether to pass on notifications to the commandBridge - -- (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommissioningStatus)status; -- (void)controller:(MTRDeviceController *)controller commissioningSessionEstablishmentDone:(NSError * _Nullable)error; -- (void)controller:(MTRDeviceController *)controller commissioningComplete:(NSError * _Nullable)error; - -- (instancetype)init NS_UNAVAILABLE; -- (instancetype)initWithTestCommandBridge:(TestCommandBridge *)commandBridge; -@end - -NS_ASSUME_NONNULL_END - -inline constexpr uint16_t kTimeoutInSeconds = 90; - -class TestCommandBridge : public CHIPCommandBridge, - public ValueChecker, - public ConstraintsChecker, - public PICSChecker, - public LogCommands, - public SystemCommands { -public: - TestCommandBridge(const char * _Nonnull commandName) - : CHIPCommandBridge(commandName) - , mDeviceControllerDelegate([[TestDeviceControllerDelegate alloc] initWithTestCommandBridge:this]) - { - AddArgument("delayInMs", 0, UINT64_MAX, &mDelayInMs); - AddArgument("PICS", &mPICSFilePath); - } - - ~TestCommandBridge() {}; - - /////////// CHIPCommand Interface ///////// - CHIP_ERROR RunCommand() override - { - if (mPICSFilePath.HasValue()) { - PICS.SetValue(PICSBooleanReader::Read(mPICSFilePath.Value())); - } - - mCallbackQueue = dispatch_queue_create("com.chip-tool.command", DISPATCH_QUEUE_SERIAL); - - NextTest(); - return CHIP_NO_ERROR; - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(kTimeoutInSeconds); } - - virtual void NextTest() = 0; - - // Support for tests that asynchronously come up with a status of some - // sort. Subclasses are expected to compare the provided status to the - // expected status for the test. - virtual void OnStatusUpdate(const chip::app::StatusIB & status) = 0; - - void Exit(std::string message, CHIP_ERROR err = CHIP_ERROR_INTERNAL) override - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", message.c_str()); - SetCommandExitStatus(err); - } - - /////////// DelayCommands ///////// - // This function is a modified version of the one in DelayCommands.cpp and is needed here in order to - // skip compilation of DelayCommands, which needs to link against SDK internals. - CHIP_ERROR WaitForMs( - const char * _Nullable identity, const chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type & value) - { - dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t) (value.ms * NSEC_PER_MSEC)); - dispatch_after(delayTime, mCallbackQueue, ^(void) { - NextTest(); - }); - return CHIP_NO_ERROR; - } - - // This function is identical to DelayCommands.cpp and is needed here in order to - // skip compilation of DelayCommands, which needs to link against SDK internals. - CHIP_ERROR WaitForMessage( - const char * _Nullable identity, const chip::app::Clusters::DelayCommands::Commands::WaitForMessage::Type & value) - { - VerifyOrReturnError(!value.message.empty(), CHIP_ERROR_INVALID_ARGUMENT); - - const char * scriptDir = getScriptsFolder(); - constexpr const char * scriptName = "WaitForMessage.py"; - const char * registerKeyValue = value.registerKey.HasValue() ? value.registerKey.Value().data() : kDefaultKey; - const size_t registerKeyLen = value.registerKey.HasValue() ? value.registerKey.Value().size() : strlen(kDefaultKey); - - char command[128]; - VerifyOrReturnError( - snprintf(command, sizeof(command), "%s%s %.*s %.*s", scriptDir, scriptName, static_cast(registerKeyLen), - registerKeyValue, static_cast(value.message.size()), value.message.data()) - >= 0, - CHIP_ERROR_INTERNAL); - return RunInternal(command); - } - - // This function is identical to DelayCommands.cpp and is needed here in order to - // skip compilation of DelayCommands, which needs to link against SDK internals. - CHIP_ERROR RunInternal(const char * _Nonnull command) - { - VerifyOrReturnError(system(command) == 0, CHIP_ERROR_INTERNAL); - return ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - CHIP_ERROR WaitForCommissionee( - const char * _Nullable identity, const chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type & value) - { - MTRDeviceController * controller = GetCommissioner(identity); - VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE); - - SetIdentity(identity); - - // Invalidate our existing CASE session; otherwise trying to work with - // our device will just reuse it without establishing a new CASE - // session when a reboot is done on the server, and then our next - // interaction will time out. - if (value.expireExistingSession.ValueOr(true)) { - if (GetDevice(identity) != nil) { - [GetDevice(identity) invalidateCASESession]; - mConnectedDevices[identity] = nil; - } - } - - mConnectedDevices[identity] = [MTRBaseDevice deviceWithNodeID:@(value.nodeId) controller:controller]; - dispatch_async(mCallbackQueue, ^{ - NextTest(); - }); - return CHIP_NO_ERROR; - } - - /////////// CommissionerCommands-like Interface ///////// - CHIP_ERROR PairWithCode( - const char * _Nullable identity, const chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type & value) - { - MTRDeviceController * controller = GetCommissioner(identity); - VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE); - - SetIdentity(identity); - [controller setDeviceControllerDelegate:mDeviceControllerDelegate queue:mCallbackQueue]; - [mDeviceControllerDelegate setDeviceId:value.nodeId]; - [mDeviceControllerDelegate setActive:YES]; - - NSString * payloadStr = [[NSString alloc] initWithBytes:value.payload.data() - length:value.payload.size() - encoding:NSUTF8StringEncoding]; - NSError * err; - auto * payload = [MTRSetupPayload setupPayloadWithOnboardingPayload:payloadStr error:&err]; - if (err != nil) { - return MTRErrorToCHIPErrorCode(err); - } - BOOL ok = [controller setupCommissioningSessionWithPayload:payload newNodeID:@(value.nodeId) error:&err]; - if (ok == YES) { - return CHIP_NO_ERROR; - } - - return MTRErrorToCHIPErrorCode(err); - } - - CHIP_ERROR GetCommissionerNodeId(const char * _Nullable identity, - const chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type & value, - void (^_Nonnull OnResponse)(const chip::GetCommissionerNodeIdResponse &)) - { - auto * controller = GetCommissioner(identity); - VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE); - - auto id = [controller.controllerNodeId unsignedLongLongValue]; - ChipLogProgress(chipTool, "Commissioner Node Id: %llu", id); - - chip::GetCommissionerNodeIdResponse outValue; - outValue.nodeId = id; - - dispatch_async(mCallbackQueue, ^{ - OnResponse(outValue); - }); - - return CHIP_NO_ERROR; - } - - /////////// SystemCommands Interface ///////// - CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) override - { - if (CHIP_NO_ERROR == err) { - dispatch_async(mCallbackQueue, ^{ - NextTest(); - }); - } else { - Exit(chip::ErrorStr(err), err); - } - return CHIP_NO_ERROR; - } - - MTRBaseDevice * _Nullable GetDevice(const char * _Nullable identity) - { - SetIdentity(identity); - return mConnectedDevices[identity]; - } - - // PairingDeleted and PairingComplete need to be public so our pairing - // delegate can call them. - void PairingDeleted() - { - // This should not happen! - Exit("Unexpected deletion of pairing"); - } - - void PairingComplete(chip::NodeId nodeId) - { - MTRDeviceController * commissioner = CurrentCommissioner(); - VerifyOrReturn(commissioner != nil, Exit("No current commissioner")); - - NSError * commissionError = nil; - [commissioner commissionNodeWithID:@(nodeId) - commissioningParams:[[MTRCommissioningParameters alloc] init] - error:&commissionError]; - CHIP_ERROR err = MTRErrorToCHIPErrorCode(commissionError); - if (err != CHIP_NO_ERROR) { - Exit("Failed to kick off commissioning", err); - return; - } - } - -protected: - dispatch_queue_t _Nullable mCallbackQueue; - - void Wait() - { - if (mDelayInMs.HasValue()) { - chip::test_utils::SleepMillis(mDelayInMs.Value()); - } - }; - - chip::Optional mDelayInMs; - chip::Optional mPICSFilePath; - chip::Optional mEndpointId; - chip::Optional mTimeout; - - bool CheckConstraintStartsWith( - const char * _Nonnull itemName, const NSString * _Nonnull current, const char * _Nonnull expected) - { - const chip::CharSpan value([current UTF8String], [current lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - return ConstraintsChecker::CheckConstraintStartsWith(itemName, value, expected); - } - - bool CheckConstraintEndsWith(const char * _Nonnull itemName, const NSString * _Nonnull current, const char * _Nonnull expected) - { - const chip::CharSpan value([current UTF8String], [current lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - return ConstraintsChecker::CheckConstraintEndsWith(itemName, value, expected); - } - - bool CheckConstraintIsUpperCase(const char * _Nonnull itemName, const NSString * _Nonnull current, bool expectUpperCase) - { - const chip::CharSpan value([current UTF8String], [current lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - return ConstraintsChecker::CheckConstraintIsUpperCase(itemName, value, expectUpperCase); - } - - bool CheckConstraintIsLowerCase(const char * _Nonnull itemName, const NSString * _Nonnull current, bool expectLowerCase) - { - const chip::CharSpan value([current UTF8String], [current lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - return ConstraintsChecker::CheckConstraintIsLowerCase(itemName, value, expectLowerCase); - } - - bool CheckConstraintIsHexString(const char * _Nonnull itemName, const NSString * _Nonnull current, bool expectHexString) - { - const chip::CharSpan value([current UTF8String], [current lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - return ConstraintsChecker::CheckConstraintIsHexString(itemName, value, expectHexString); - } - - template - bool CheckConstraintContains(const char * _Nonnull itemName, const NSArray * _Nonnull current, T expected) - { - for (id currentElement in current) { - if ([currentElement isEqualToNumber:@(expected)]) { - return true; - } - } - - Exit(std::string(itemName) + " expect the value " + std::to_string(expected) + " but the list does not contains it."); - return false; - } - - template - bool CheckConstraintExcludes(const char * _Nonnull itemName, const NSArray * _Nonnull current, T expected) - { - for (id currentElement in current) { - if ([currentElement isEqualToNumber:@(expected)]) { - Exit(std::string(itemName) + " does not expect the value " + std::to_string(expected) - + " but the list contains it."); - return false; - } - } - - return true; - } - - bool CheckConstraintNotValue( - const char * _Nonnull itemName, const NSString * _Nullable current, const NSString * _Nullable expected) - { - if (current == nil && expected == nil) { - Exit(std::string(itemName) + " got unexpected value. Both values are nil."); - return false; - } - if ((current == nil) != (expected == nil)) { - return true; - } - const chip::CharSpan currentValue([current UTF8String], [current lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - const chip::CharSpan expectedValue([expected UTF8String], [expected lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - return ConstraintsChecker::CheckConstraintNotValue(itemName, currentValue, expectedValue); - } - - bool CheckConstraintNotValue( - const char * _Nonnull itemName, const NSData * _Nullable current, const NSData * _Nullable expected) - { - if (current == nil && expected == nil) { - Exit(std::string(itemName) + " got unexpected value. Both values are nil."); - return false; - } - if ((current == nil) != (expected == nil)) { - return true; - } - const chip::ByteSpan currentValue(static_cast([current bytes]), [current length]); - const chip::ByteSpan expectedValue(static_cast([expected bytes]), [expected length]); - return ConstraintsChecker::CheckConstraintNotValue(itemName, currentValue, expectedValue); - } - - bool CheckConstraintNotValue(const char * _Nonnull itemName, const NSNumber * _Nullable current, NSNumber * _Nullable expected) - { - if (current == nil && expected == nil) { - Exit(std::string(itemName) + " got unexpected value. Both values are nil."); - return false; - } - if ((current == nil) != (expected == nil)) { - return true; - } - if ([current isEqualToNumber:expected]) { - Exit(std::string(itemName) + " got unexpected value: " + std::string([[current stringValue] UTF8String])); - return false; - } - - return true; - } - - template - bool CheckConstraintNotValue(const char * _Nonnull itemName, const NSNumber * _Nullable current, T expected) - { - return CheckConstraintNotValue(itemName, current, @(expected)); - } - - template - bool CheckConstraintNotValue(const char * _Nonnull itemName, NSError * _Nullable current, T expected) - { - NSNumber * currentValue = @(MTRErrorToCHIPErrorCode(current).AsInteger()); - return CheckConstraintNotValue(itemName, currentValue, @(expected)); - } - - using ConstraintsChecker::CheckConstraintMinLength; - - bool CheckConstraintMinLength(const char * _Nonnull itemName, NSString * _Nullable current, uint64_t expected) - { - if (current == nil) { - return true; - } - return CheckConstraintMinLength(itemName, [current length], expected); - } - - bool CheckConstraintMinLength(const char * _Nonnull itemName, NSArray * _Nullable current, uint64_t expected) - { - if (current == nil) { - return true; - } - return CheckConstraintMinLength(itemName, [current count], expected); - } - - using ConstraintsChecker::CheckConstraintMaxLength; - - bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSString * _Nullable current, uint64_t expected) - { - if (current == nil) { - return true; - } - return CheckConstraintMaxLength(itemName, [current length], expected); - } - - bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSArray * _Nullable current, uint64_t expected) - { - if (current == nil) { - return true; - } - return CheckConstraintMaxLength(itemName, [current count], expected); - } - - using ConstraintsChecker::CheckConstraintMinValue; - - // Used when the minValue is a saved variable, since ConstraintsChecker does - // not expect Core Foundation types. - template ::value && std::is_signed::value, int> = 0> - bool CheckConstraintMinValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) - { - if (expected == nil) { - return true; - } - return ConstraintsChecker::CheckConstraintMinValue(itemName, current, [expected longLongValue]); - } - - template ::value && !std::is_signed::value, int> = 0> - bool CheckConstraintMinValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) - { - if (expected == nil) { - return true; - } - return ConstraintsChecker::CheckConstraintMinValue(itemName, current, [expected unsignedLongLongValue]); - } - - template ::value, int> = 0> - bool CheckConstraintMinValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) - { - if (expected == nil) { - return true; - } - return ConstraintsChecker::CheckConstraintMinValue(itemName, current, [expected doubleValue]); - } - - using ConstraintsChecker::CheckConstraintMaxValue; - - // Used when the maxValue is a saved variable, since ConstraintsChecker does - // not expect Core Foundation types. - template ::value && std::is_signed::value, int> = 0> - bool CheckConstraintMaxValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) - { - if (expected == nil) { - return true; - } - return ConstraintsChecker::CheckConstraintMaxValue(itemName, current, [expected longLongValue]); - } - - template ::value && !std::is_signed::value, int> = 0> - bool CheckConstraintMaxValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) - { - if (expected == nil) { - return true; - } - return ConstraintsChecker::CheckConstraintMaxValue(itemName, current, [expected unsignedLongLongValue]); - } - - template ::value, int> = 0> - bool CheckConstraintMaxValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) - { - if (expected == nil) { - return true; - } - return ConstraintsChecker::CheckConstraintMaxValue(itemName, current, [expected doubleValue]); - } - - bool CheckConstraintHasValue(const char * _Nonnull itemName, id _Nullable current, bool shouldHaveValue) - { - if (shouldHaveValue && (current == nil)) { - Exit(std::string(itemName) + " expected to have a value but doesn't"); - return false; - } - - if (!shouldHaveValue && (current != nil)) { - Exit(std::string(itemName) + " not expected to have a value but does"); - return false; - } - - return true; - } - - bool CheckValueAsString(const char * _Nonnull itemName, const id _Nonnull current, const NSString * _Nonnull expected) - { - NSString * data = current; - const chip::CharSpan currentValue([data UTF8String], [data lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - const chip::CharSpan expectedValue([expected UTF8String], [expected lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - return ValueChecker::CheckValueAsString(itemName, currentValue, expectedValue); - } - - bool CheckValueAsString(const char * _Nonnull itemName, const id _Nonnull current, const NSData * _Nonnull expected) - { - NSData * data = current; - const chip::ByteSpan currentValue(static_cast([data bytes]), [data length]); - const chip::ByteSpan expectedValue(static_cast([expected bytes]), [expected length]); - return ValueChecker::CheckValueAsString(itemName, currentValue, expectedValue); - } - - bool CheckValue(const char * _Nonnull itemName, NSNumber * _Nonnull current, NSNumber * _Nonnull expected) - { - if (![current isEqualToNumber:expected]) { - Exit(std::string(itemName) + " value mismatch: expected " + std::string([[expected stringValue] UTF8String]) - + " but got " + std::string([[current stringValue] UTF8String])); - return false; - } - - return true; - } - - bool CheckValue(const char * _Nonnull itemName, id _Nonnull current, NSNumber * _Nonnull expected) - { - NSNumber * currentValue = current; - return CheckValue(itemName, currentValue, expected); - } - - template - bool CheckValue(const char * _Nonnull itemName, NSNumber * _Nonnull current, T expected) - { - return CheckValue(itemName, current, @(expected)); - } - - template - bool CheckValue(const char * _Nonnull itemName, id _Nonnull current, T expected) - { - NSNumber * currentValue = current; - return CheckValue(itemName, currentValue, @(expected)); - } - - template - bool CheckValue(const char * _Nonnull itemName, NSError * _Nullable current, T expected) - { - - NSNumber * currentValue = @(current.code); - return CheckValue(itemName, currentValue, @(expected)); - } - - template - bool CheckValue(const char * _Nonnull itemName, T current, U expected) - { - - return ValueChecker::CheckValue(itemName, current, expected); - } - - bool CheckValueNonNull(const char * _Nonnull itemName, id _Nullable current) - { - if (current != nil) { - return true; - } - - Exit(std::string(itemName) + " expected to not be null but is"); - return false; - } - - bool CheckValueNull(const char * _Nonnull itemName, id _Nullable current) - { - if (current == nil) { - return true; - } - - Exit(std::string(itemName) + " expected to be null but isn't"); - return false; - } - -private: - TestDeviceControllerDelegate * _Nonnull mDeviceControllerDelegate; - - // Set of our connected devices, keyed by identity. - std::map mConnectedDevices; -}; - -NS_ASSUME_NONNULL_BEGIN - -@implementation TestDeviceControllerDelegate -- (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommissioningStatus)status -{ - if (_active) { - if (status == MTRCommissioningStatusSuccess) { - NSLog(@"Secure pairing success"); - } else if (status == MTRCommissioningStatusFailed) { - _active = NO; - NSLog(@"Secure pairing failed"); - _commandBridge->OnStatusUpdate(chip::app::StatusIB(chip::Protocols::InteractionModel::Status::Failure)); - } - } -} - -- (void)controller:(MTRDeviceController *)controller commissioningSessionEstablishmentDone:(NSError * _Nullable)error -{ - if (_active) { - if (error != nil) { - _active = NO; - NSLog(@"Pairing complete with error"); - CHIP_ERROR err = MTRErrorToCHIPErrorCode(error); - _commandBridge->OnStatusUpdate([self convertToStatusIB:err]); - } else { - _commandBridge->PairingComplete(_deviceId); - } - } -} - -- (void)controller:(MTRDeviceController *)controller commissioningComplete:(NSError * _Nullable)error -{ - if (_active) { - _active = NO; - CHIP_ERROR err = MTRErrorToCHIPErrorCode(error); - _commandBridge->OnStatusUpdate([self convertToStatusIB:err]); - } -} - -- (chip::app::StatusIB)convertToStatusIB:(CHIP_ERROR)err -{ - using chip::app::StatusIB; - using namespace chip; - using namespace chip::Protocols::InteractionModel; - using namespace chip::app::Clusters::OperationalCredentials; - - if (CHIP_ERROR_INVALID_PUBLIC_KEY == err) { - return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kInvalidPublicKey)); - } - if (CHIP_ERROR_WRONG_NODE_ID == err) { - return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kInvalidNodeOpId)); - } - if (CHIP_ERROR_UNSUPPORTED_CERT_FORMAT == err) { - return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kInvalidNOC)); - } - if (CHIP_ERROR_FABRIC_EXISTS == err) { - return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kFabricConflict)); - } - if (CHIP_ERROR_INVALID_FABRIC_INDEX == err) { - return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kInvalidFabricIndex)); - } - - return StatusIB(err); -} - -- (instancetype)initWithTestCommandBridge:(TestCommandBridge *)commandBridge -{ - if (!(self = [super init])) { - return nil; - } - - _commandBridge = commandBridge; - _active = NO; - return self; -} -@end - -NS_ASSUME_NONNULL_END diff --git a/examples/placeholder/linux/BUILD.gn b/examples/placeholder/linux/BUILD.gn index 0752f7ee0fb4fe..089d223c0cd52d 100644 --- a/examples/placeholder/linux/BUILD.gn +++ b/examples/placeholder/linux/BUILD.gn @@ -38,11 +38,7 @@ executable("chip-${chip_tests_zap_config}") { "${chip_root}/examples/common/websocket-server", "${chip_root}/examples/placeholder/linux/apps/${chip_tests_zap_config}:${chip_tests_zap_config}", "${chip_root}/examples/platform/linux:app-main", - "${chip_root}/src/app/tests/suites/commands/delay", - "${chip_root}/src/app/tests/suites/commands/discovery", - "${chip_root}/src/app/tests/suites/commands/log", "${chip_root}/src/app/tests/suites/credentials:dac_provider", - "${chip_root}/src/app/tests/suites/pics", "${chip_root}/src/lib", "${chip_root}/src/lib/support:test_utils", "${chip_root}/src/platform/logging:headers", diff --git a/examples/placeholder/linux/apps/app1/ciTests.json b/examples/placeholder/linux/apps/app1/ciTests.json deleted file mode 100644 index 63ba1ad875563c..00000000000000 --- a/examples/placeholder/linux/apps/app1/ciTests.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "Test": [ - "Test_TC_WNCV_5_1_Simulated", - "Test_TC_OCC_2_4_Simulated", - "Test_TC_DGSW_3_2_Simulated", - "Test_TC_DGETH_3_2_Simulated", - "Test_TC_DGWIFI_3_2_Simulated", - "Test_TC_WNCV_6_1_Simulated", - "Test_TC_WNCV_7_1_Simulated", - "Test_TC_CC_3_4_Simulated", - "Test_TC_CC_4_5_Simulated", - "Test_TC_CC_5_4_Simulated", - "Test_TC_CC_6_4_Simulated", - "Test_TC_CC_7_5_Simulated", - "Test_TC_CC_9_4_Simulated", - "Test_TC_DGTHREAD_3_4_Simulated", - "Test_TC_OO_3_2_Simulated" - ], - "collection": ["Test"] -} diff --git a/examples/placeholder/linux/apps/app1/templates/templates.json b/examples/placeholder/linux/apps/app1/templates/templates.json deleted file mode 100644 index 07ab95ea1c7d99..00000000000000 --- a/examples/placeholder/linux/apps/app1/templates/templates.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "Placeholder templates", - "version": "chip-v1", - "helpers": [ - "partials/helper.js", - "common/StringHelper.js", - "templates/app/helper.js", - "templates/chip/helper.js", - "common/ClusterTestGeneration.js", - "chip-tool/templates/helper.js", - "chip-tool/templates/tests/helper.js" - ], - "resources": { - "pics-metafile": "../../../../../../src/app/tests/suites/certification/PICS.yaml", - "certification-metadir": "../../../../../../src/app/tests/suites/certification", - "test-metadir": "../../../../../../src/app/tests/suites" - }, - "override": "../../../../../../src/app/zap-templates/common/override.js", - "partials": [ - { - "name": "header", - "path": "../../../../../../src/app/zap-templates/partials/header.zapt" - }, - { - "name": "test_cluster", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/test_cluster.zapt" - }, - { - "name": "test_step", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/test_step.zapt" - }, - { - "name": "test_step_response", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/test_step_response.zapt" - }, - { - "name": "maybeCheckExpectedValue", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt" - }, - { - "name": "maybeCheckExpectedConstraints", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedConstraints.zapt" - }, - { - "name": "maybeSaveAs", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/saveAs/maybeSaveAs.zapt" - }, - { - "name": "setupSaveAs", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/saveAs/setupSaveAs.zapt" - }, - { - "name": "teardownSaveAs", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/saveAs/teardownSaveAs.zapt" - }, - { - "name": "commandValue", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/command_value.zapt" - }, - { - "name": "valueEquals", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/value_equals.zapt" - } - ], - "templates": [ - { - "path": "../../../../templates/tests-commands.zapt", - "name": "Tests Commands header", - "output": "test/Commands.h" - } - ] -} diff --git a/examples/placeholder/linux/apps/app2/templates/templates.json b/examples/placeholder/linux/apps/app2/templates/templates.json deleted file mode 100644 index 07ab95ea1c7d99..00000000000000 --- a/examples/placeholder/linux/apps/app2/templates/templates.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "Placeholder templates", - "version": "chip-v1", - "helpers": [ - "partials/helper.js", - "common/StringHelper.js", - "templates/app/helper.js", - "templates/chip/helper.js", - "common/ClusterTestGeneration.js", - "chip-tool/templates/helper.js", - "chip-tool/templates/tests/helper.js" - ], - "resources": { - "pics-metafile": "../../../../../../src/app/tests/suites/certification/PICS.yaml", - "certification-metadir": "../../../../../../src/app/tests/suites/certification", - "test-metadir": "../../../../../../src/app/tests/suites" - }, - "override": "../../../../../../src/app/zap-templates/common/override.js", - "partials": [ - { - "name": "header", - "path": "../../../../../../src/app/zap-templates/partials/header.zapt" - }, - { - "name": "test_cluster", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/test_cluster.zapt" - }, - { - "name": "test_step", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/test_step.zapt" - }, - { - "name": "test_step_response", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/test_step_response.zapt" - }, - { - "name": "maybeCheckExpectedValue", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt" - }, - { - "name": "maybeCheckExpectedConstraints", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedConstraints.zapt" - }, - { - "name": "maybeSaveAs", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/saveAs/maybeSaveAs.zapt" - }, - { - "name": "setupSaveAs", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/saveAs/setupSaveAs.zapt" - }, - { - "name": "teardownSaveAs", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/saveAs/teardownSaveAs.zapt" - }, - { - "name": "commandValue", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/command_value.zapt" - }, - { - "name": "valueEquals", - "path": "../../../../../../examples/chip-tool/templates/tests/partials/value_equals.zapt" - } - ], - "templates": [ - { - "path": "../../../../templates/tests-commands.zapt", - "name": "Tests Commands header", - "output": "test/Commands.h" - } - ] -} diff --git a/examples/placeholder/linux/include/MatterCallbacks.h b/examples/placeholder/linux/include/MatterCallbacks.h index 0ddddb8f7d2ae9..d7ba67e2b38200 100644 --- a/examples/placeholder/linux/include/MatterCallbacks.h +++ b/examples/placeholder/linux/include/MatterCallbacks.h @@ -19,76 +19,22 @@ #pragma once #include "InteractiveServer.h" -#include "Options.h" #include #include -#include -#include - -#include - -TestCommand * GetTargetTest() -{ - const char * command = LinuxDeviceOptions::GetInstance().command; - if (command == nullptr) - { - return nullptr; - } - - static auto test = GetTestCommand(command); - if (test.get() == nullptr) - { - ChipLogError(chipTool, "Specified test command does not exist: %s", command); - PrintTestCommands(); - return nullptr; - } - - const char * PICSFilePath = LinuxDeviceOptions::GetInstance().PICS; - if (PICSFilePath != nullptr) - { - test->PICS.SetValue(PICSBooleanReader::Read(PICSFilePath)); - } - - return test.get(); -} void MatterPostCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath, const chip::Access::SubjectDescriptor & subjectDescriptor) { VerifyOrReturn(!InteractiveServer::GetInstance().Command(commandPath)); - - auto test = GetTargetTest(); - VerifyOrReturn(test != nullptr && test->isRunning); - - ChipLogError(Zcl, "Receive command: Endpoint: %u, Cluster: " ChipLogFormatMEI ", Command: " ChipLogFormatMEI, - commandPath.mEndpointId, ChipLogValueMEI(commandPath.mClusterId), ChipLogValueMEI(commandPath.mCommandId)); - - test->CheckCommandPath(commandPath); } void MatterPostAttributeReadCallback(const chip::app::ConcreteAttributePath & attributePath) { VerifyOrReturn(!InteractiveServer::GetInstance().ReadAttribute(attributePath)); - - auto test = GetTargetTest(); - VerifyOrReturn(test != nullptr && test->isRunning); - - ChipLogError(Zcl, "Receive READ attribute command: Endpoint: %u, Cluster: " ChipLogFormatMEI ", Attribute: " ChipLogFormatMEI, - attributePath.mEndpointId, ChipLogValueMEI(attributePath.mClusterId), ChipLogValueMEI(attributePath.mAttributeId)); - - test->CheckAttributePath(attributePath); } void MatterPostAttributeWriteCallback(const chip::app::ConcreteAttributePath & attributePath) { VerifyOrReturn(!InteractiveServer::GetInstance().WriteAttribute(attributePath)); - - auto test = GetTargetTest(); - VerifyOrReturn(test != nullptr && test->isRunning); - - ChipLogError(Zcl, "Receive WRITE attribute command: Endpoint: %u, Cluster: " ChipLogFormatMEI ", Attribute: " ChipLogFormatMEI, - attributePath.mEndpointId, ChipLogValueMEI(attributePath.mClusterId), ChipLogValueMEI(attributePath.mAttributeId)); - - test->CheckAttributePath(attributePath); } diff --git a/examples/placeholder/linux/include/TestCommand.h b/examples/placeholder/linux/include/TestCommand.h deleted file mode 100644 index 5b0d733d4736dc..00000000000000 --- a/examples/placeholder/linux/include/TestCommand.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * 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. - */ - -#pragma once - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -inline constexpr char kIdentityAlpha[] = ""; -inline constexpr char kIdentityBeta[] = ""; -inline constexpr char kIdentityGamma[] = ""; - -class TestCommand : public TestRunner, - public PICSChecker, - public LogCommands, - public DiscoveryCommands, - public DelayCommands, - public ValueChecker, - public ConstraintsChecker -{ -public: - TestCommand(const char * commandName, uint16_t testsCount) : - TestRunner(commandName, testsCount), mCommandPath(0, 0, 0), mAttributePath(0, 0, 0) - {} - virtual ~TestCommand() {} - - void SetCommandExitStatus(CHIP_ERROR status) - { - chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); - mExitCode = (CHIP_NO_ERROR == status ? EXIT_SUCCESS : EXIT_FAILURE); - } - - int GetCommandExitCode() { return mExitCode; } - - template - size_t AddArgument(const char * name, chip::Optional * value) - { - return 0; - } - - template - size_t AddArgument(const char * name, int64_t min, uint64_t max, chip::Optional * value) - { - return 0; - } - - CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) override - { - if (CHIP_NO_ERROR == err) - { - NextTest(); - } - else - { - Exit(chip::ErrorStr(err), err); - } - return CHIP_NO_ERROR; - } - - void Exit(std::string message, CHIP_ERROR err) override - { - LogEnd(message, err); - - if (CHIP_NO_ERROR == err) - { - chip::DeviceLayer::PlatformMgr().ScheduleWork(AsyncExit, reinterpret_cast(this)); - } - else - { - SetCommandExitStatus(err); - } - } - - static void AsyncExit(intptr_t context) - { - TestCommand * command = reinterpret_cast(context); - command->SetCommandExitStatus(CHIP_NO_ERROR); - } - - static void ScheduleNextTest(intptr_t context) - { - TestCommand * command = reinterpret_cast(context); - command->isRunning = true; - command->NextTest(); - } - - static void OnPlatformEvent(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg) - { - switch (event->Type) - { - case chip::DeviceLayer::DeviceEventType::kCommissioningComplete: - ChipLogProgress(chipTool, "Commissioning complete"); - chip::DeviceLayer::PlatformMgr().ScheduleWork(ScheduleNextTest, arg); - chip::DeviceLayer::PlatformMgr().RemoveEventHandler(OnPlatformEvent, arg); - break; - } - } - - void CheckCommandPath(const chip::app::ConcreteCommandPath & commandPath) - { - if (commandPath == mCommandPath) - { - chip::DeviceLayer::PlatformMgr().ScheduleWork(ScheduleNextTest, reinterpret_cast(this)); - return; - } - - ChipLogError(chipTool, "CommandPath does not match"); - SetCommandExitStatus(CHIP_ERROR_INTERNAL); - } - - void CheckAttributePath(const chip::app::ConcreteAttributePath & attributePath) - { - if (attributePath == mAttributePath) - { - chip::DeviceLayer::PlatformMgr().ScheduleWork(ScheduleNextTest, reinterpret_cast(this)); - return; - } - - ChipLogError(chipTool, "AttributePath does not match"); - return SetCommandExitStatus(CHIP_ERROR_INTERNAL); - } - - void ClearAttributeAndCommandPaths() - { - mCommandPath = chip::app::ConcreteCommandPath(0, 0, 0); - mAttributePath = chip::app::ConcreteAttributePath(0, 0, 0); - } - - std::atomic_bool isRunning{ true }; - - CHIP_ERROR WaitAttribute(chip::EndpointId endpointId, chip::ClusterId clusterId, chip::AttributeId attributeId) - { - ClearAttributeAndCommandPaths(); - ChipLogError(chipTool, "[Endpoint: 0x%08x Cluster: %d, Attribute: %d]", endpointId, clusterId, attributeId); - mAttributePath = chip::app::ConcreteAttributePath(endpointId, clusterId, attributeId); - return CHIP_NO_ERROR; - } - - CHIP_ERROR WaitCommand(chip::EndpointId endpointId, chip::ClusterId clusterId, chip::CommandId commandId) - { - ClearAttributeAndCommandPaths(); - ChipLogError(chipTool, "[Endpoint: 0x%08x Cluster: %d, Command: %d]", endpointId, clusterId, commandId); - mCommandPath = chip::app::ConcreteCommandPath(endpointId, clusterId, commandId); - return CHIP_NO_ERROR; - } - -protected: - chip::app::ConcreteCommandPath mCommandPath; - chip::app::ConcreteAttributePath mAttributePath; - chip::Optional mCommissionerNodeId; - chip::Optional mEndpointId; - int mExitCode = EXIT_SUCCESS; - - void SetIdentity(const char * name){}; - - /////////// DelayCommands Interface ///////// - void OnWaitForMs() override { NextTest(); } - - CHIP_ERROR WaitForCommissioning(const char * identity, - const chip::app::Clusters::DelayCommands::Commands::WaitForCommissioning::Type & value) override - { - isRunning = false; - return chip::DeviceLayer::PlatformMgr().AddEventHandler(OnPlatformEvent, reinterpret_cast(this)); - } -}; diff --git a/examples/placeholder/linux/main.cpp b/examples/placeholder/linux/main.cpp index 11f7529e07aa03..ab5fa266dd6392 100644 --- a/examples/placeholder/linux/main.cpp +++ b/examples/placeholder/linux/main.cpp @@ -28,12 +28,6 @@ int main(int argc, char * argv[]) { VerifyOrDie(ChipLinuxAppInit(argc, argv, AppOptions::GetOptions()) == 0); - auto test = GetTargetTest(); - if (test != nullptr) - { - test->NextTest(); - } - LinuxDeviceOptions::GetInstance().dacProvider = AppOptions::GetDACProvider(); auto & server = InteractiveServer::GetInstance(); @@ -44,10 +38,5 @@ int main(int argc, char * argv[]) ChipLinuxAppMainLoop(); - if (test != nullptr) - { - return test->GetCommandExitCode(); - } - return 0; } diff --git a/examples/placeholder/templates/tests-commands.zapt b/examples/placeholder/templates/tests-commands.zapt deleted file mode 100644 index be0474f4632605..00000000000000 --- a/examples/placeholder/templates/tests-commands.zapt +++ /dev/null @@ -1,33 +0,0 @@ -{{> header}} - -#pragma once - -#include "TestCommand.h" - -#include - -{{>test_cluster tests="../linux/apps/app1/ciTests.json" credsIssuerConfigArg=false needsWaitDuration=false}} - -std::unique_ptrGetTestCommand(std::string testName) -{ - {{#chip_tests "../linux/apps/app1/ciTests.json" includeAllClusters=true}} - if (testName == "{{filename}}") - { - return std::unique_ptr<{{filename}}Suite>(new {{filename}}Suite()); - } - {{/chip_tests}} - - return nullptr; -} - -void PrintTestCommands() -{ - {{#chip_tests "../linux/apps/app1/ciTests.json" includeAllClusters=true}} - {{#first}} - ChipLogError(chipTool, "Supported commands:"); - {{/first}} - ChipLogError(chipTool, "\t* {{filename}}"); - {{else}} - ChipLogError("\t No available commands."); - {{/chip_tests}} -} diff --git a/scripts/examples/gn_build_test_example.sh b/scripts/examples/gn_build_test_example.sh index 766868016bbf08..7ca97892270e8b 100755 --- a/scripts/examples/gn_build_test_example.sh +++ b/scripts/examples/gn_build_test_example.sh @@ -38,9 +38,6 @@ function runZAP() { # Generates the generic files for the given zap configuration "$CHIP_ROOT"/scripts/tools/zap/generate.py "$ZAP_INPUT_FILE" -o "$ZAP_OUTPUT_DIR" - - # Generates the specific files for the given zap configuration - TARGET_APP=$APP_DIR "$CHIP_ROOT"/scripts/tools/zap/generate.py "$ZAP_INPUT_FILE" -t "$INPUT_DIR"/apps/"$APP_DIR"/templates/templates.json -o "$ZAP_OUTPUT_DIR" } function runGN() { diff --git a/scripts/tools/zap_regen_all.py b/scripts/tools/zap_regen_all.py index ef950eb96fe94f..0e0b2b6dda93ec 100755 --- a/scripts/tools/zap_regen_all.py +++ b/scripts/tools/zap_regen_all.py @@ -368,26 +368,6 @@ def getGlobalTemplatesTargets(): example_name = example_name[example_name.index('examples/') + 9:] example_name = example_name[:example_name.index('/')] - # Place holder has apps within each build - if example_name == "placeholder": - example_name = filepath.as_posix() - example_name = example_name[example_name.index( - 'apps/') + len('apps/'):] - example_name = example_name[:example_name.index('/')] - logging.info("Found example %s (via %s)" % - (example_name, str(filepath))) - - # The name zap-generated is to make includes clear by using - # a name like - output_dir = os.path.join( - 'zzz_generated', 'placeholder', example_name, 'zap-generated') - template = os.path.join( - 'examples', 'placeholder', 'linux', 'apps', example_name, 'templates', 'templates.json') - - targets.append(ZAPGenerateTarget.MatterIdlTarget(ZapInput.FromZap(filepath))) - targets.append(ZAPGenerateTarget(ZapInput.FromZap(filepath), output_dir=output_dir, template=template)) - continue - if example_name == "chef": if os.path.join("chef", "devices") not in str(filepath): continue @@ -400,17 +380,6 @@ def getGlobalTemplatesTargets(): logging.info("Found example %s (via %s)" % (example_name, str(filepath))) - generate_subdir = example_name - - # Special casing lighting app because separate folders - if example_name == "lighting-app" or example_name == "lock-app": - if 'nxp' in str(filepath): - generate_subdir = f"{example_name}/nxp" - - # The name zap-generated is to make includes clear by using - # a name like - output_dir = os.path.join( - 'zzz_generated', generate_subdir, 'zap-generated') targets.append(ZAPGenerateTarget.MatterIdlTarget(ZapInput.FromZap(filepath))) targets.append(ZAPGenerateTarget.MatterIdlTarget(ZapInput.FromPropertiesJson('src/app/zap-templates/zcl/zcl.json'), @@ -450,7 +419,6 @@ def getSpecificTemplatesTargets(): # Mapping of required template and output directory templates = { 'src/app/common/templates/templates.json': 'zzz_generated/app-common/app-common/zap-generated', - 'src/app/tests/suites/templates/templates.json': 'zzz_generated/app-common/app-common/zap-generated', 'examples/chip-tool/templates/templates.json': 'zzz_generated/chip-tool/zap-generated', 'examples/darwin-framework-tool/templates/templates.json': 'zzz_generated/darwin-framework-tool/zap-generated', 'src/controller/python/templates/templates.json': None, diff --git a/src/app/common/BUILD.gn b/src/app/common/BUILD.gn index f2eb7b479f42a2..193d4c362e537e 100644 --- a/src/app/common/BUILD.gn +++ b/src/app/common/BUILD.gn @@ -44,11 +44,3 @@ source_set("enums") { public_configs = [ ":includes" ] } - -source_set("simulated") { - sources = [ "${chip_root}/zzz_generated/app-common/app-common/zap-generated/tests/simulated-cluster-objects.h" ] - - public_deps = [ ":enums" ] - - public_configs = [ ":includes" ] -} diff --git a/src/app/tests/suites/commands/delay/BUILD.gn b/src/app/tests/suites/commands/delay/BUILD.gn deleted file mode 100644 index de0babc859026f..00000000000000 --- a/src/app/tests/suites/commands/delay/BUILD.gn +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2022 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. - -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -static_library("delay") { - output_name = "libDelayCommands" - - sources = [ - "DelayCommands.cpp", - "DelayCommands.h", - ] - - cflags = [ "-Wconversion" ] - - public_deps = [ - "${chip_root}/src/app/common:simulated", - "${chip_root}/src/lib/support", - "${chip_root}/src/platform", - "${chip_root}/src/system", - ] -} diff --git a/src/app/tests/suites/commands/delay/DelayCommands.cpp b/src/app/tests/suites/commands/delay/DelayCommands.cpp deleted file mode 100644 index abf66ea9fa1192..00000000000000 --- a/src/app/tests/suites/commands/delay/DelayCommands.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#include "DelayCommands.h" - -namespace { -const char basePath[] = "./src/app/tests/suites/commands/delay/scripts/"; -const char * getScriptsFolder() -{ - return basePath; -} -} // namespace - -constexpr char kDefaultKey[] = "default"; - -CHIP_ERROR DelayCommands::WaitForMs(const char * identity, - const chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type & value) -{ - const auto duration = chip::System::Clock::Milliseconds32(value.ms); - return chip::DeviceLayer::SystemLayer().StartTimer(duration, OnWaitForMsFn, this); -} - -void DelayCommands::OnWaitForMsFn(chip::System::Layer * systemLayer, void * context) -{ - auto * command = static_cast(context); - command->OnWaitForMs(); -} - -CHIP_ERROR DelayCommands::WaitForMessage(const char * identity, - const chip::app::Clusters::DelayCommands::Commands::WaitForMessage::Type & value) -{ - VerifyOrReturnError(!value.message.empty(), CHIP_ERROR_INVALID_ARGUMENT); - - const char * scriptDir = getScriptsFolder(); - constexpr const char * scriptName = "WaitForMessage.py"; - const char * registerKeyValue = value.registerKey.HasValue() ? value.registerKey.Value().data() : kDefaultKey; - const size_t registerKeyLen = value.registerKey.HasValue() ? value.registerKey.Value().size() : strlen(kDefaultKey); - - char command[128]; - VerifyOrReturnError(snprintf(command, sizeof(command), "%s%s %.*s %.*s", scriptDir, scriptName, - static_cast(registerKeyLen), registerKeyValue, static_cast(value.message.size()), - value.message.data()) >= 0, - CHIP_ERROR_INTERNAL); - return RunInternal(command); -} - -CHIP_ERROR DelayCommands::RunInternal(const char * command) -{ - VerifyOrReturnError(system(command) == 0, CHIP_ERROR_INTERNAL); - return ContinueOnChipMainThread(CHIP_NO_ERROR); -} - -CHIP_ERROR DelayCommands::BusyWaitFor(chip::System::Clock::Milliseconds32 durationInMs) -{ - auto & clock = chip::System::SystemClock(); - auto start = clock.GetMonotonicTimestamp(); - while (clock.GetMonotonicTimestamp() - start < durationInMs) - { - // nothing to do. - }; - return CHIP_NO_ERROR; -} diff --git a/src/app/tests/suites/commands/delay/DelayCommands.h b/src/app/tests/suites/commands/delay/DelayCommands.h deleted file mode 100644 index c9e8681860d7f4..00000000000000 --- a/src/app/tests/suites/commands/delay/DelayCommands.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#pragma once - -#include -#include -#include - -#include - -class DelayCommands -{ -public: - DelayCommands(){}; - virtual ~DelayCommands(){}; - - virtual CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) = 0; - virtual void OnWaitForMs() = 0; - - virtual CHIP_ERROR WaitForCommissionee(const char * identity, - const chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type & value) - { - return CHIP_ERROR_NOT_IMPLEMENTED; - }; - virtual CHIP_ERROR WaitForCommissioning(const char * identity, - const chip::app::Clusters::DelayCommands::Commands::WaitForCommissioning::Type & value) - { - return CHIP_ERROR_NOT_IMPLEMENTED; - }; - CHIP_ERROR WaitForMs(const char * identity, const chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type & value); - // Wait for any message specified by value.message for the application specified by value.registerKey - // If the message is never seen, a timeout would occur - CHIP_ERROR WaitForMessage(const char * identity, - const chip::app::Clusters::DelayCommands::Commands::WaitForMessage::Type & value); - - // Busy-wait for a given duration in milliseconds - CHIP_ERROR BusyWaitFor(chip::System::Clock::Milliseconds32 durationInMs); - -private: - static void OnWaitForMsFn(chip::System::Layer * systemLayer, void * context); - CHIP_ERROR RunInternal(const char * command); -}; diff --git a/src/app/tests/suites/commands/delay/scripts/WaitForMessage.py b/src/app/tests/suites/commands/delay/scripts/WaitForMessage.py deleted file mode 100755 index 345d6b37cf1bc9..00000000000000 --- a/src/app/tests/suites/commands/delay/scripts/WaitForMessage.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env -S python3 -B - -# Copyright (c) 2022 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. - -import sys -import xmlrpc.client - -IP = '127.0.0.1' -PORT = 9000 - -if sys.platform == 'linux': - IP = '10.10.10.5' - - -def main(): - with xmlrpc.client.ServerProxy('http://' + IP + ':' + str(PORT) + '/', allow_none=True) as proxy: - proxy.waitForMessage(sys.argv[1], sys.argv[2:]) - - -if __name__ == "__main__": - main() diff --git a/src/app/tests/suites/commands/discovery/BUILD.gn b/src/app/tests/suites/commands/discovery/BUILD.gn deleted file mode 100644 index 169e9a91609183..00000000000000 --- a/src/app/tests/suites/commands/discovery/BUILD.gn +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) 2022 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. - -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -static_library("discovery") { - output_name = "libDiscoveryCommands" - - include_dirs = [ "${chip_root}/zzz_generated/app-common" ] - - sources = [ - "DiscoveryCommands.cpp", - "DiscoveryCommands.h", - ] - - cflags = [ "-Wconversion" ] - - public_deps = [ - "${chip_root}/src/app", - "${chip_root}/src/app/common:simulated", - "${chip_root}/src/lib/address_resolve", - "${chip_root}/src/lib/support", - ] -} diff --git a/src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp b/src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp deleted file mode 100644 index 2313480351d803..00000000000000 --- a/src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#include "DiscoveryCommands.h" - -#include -#include - -CHIP_ERROR -DiscoveryCommands::FindCommissionable(const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionable::Type & value) -{ - ReturnErrorOnFailure(SetupDiscoveryCommands()); - - chip::Dnssd::DiscoveryFilter filter(chip::Dnssd::DiscoveryFilterType::kNone, (uint64_t) 0); - return mDNSResolver.DiscoverCommissionableNodes(filter); -} - -CHIP_ERROR DiscoveryCommands::FindCommissionableByShortDiscriminator( - const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByShortDiscriminator::Type & value) -{ - ReturnErrorOnFailure(SetupDiscoveryCommands()); - - chip::Dnssd::DiscoveryFilter filter(chip::Dnssd::DiscoveryFilterType::kShortDiscriminator, value.value); - return mDNSResolver.DiscoverCommissionableNodes(filter); -} - -CHIP_ERROR DiscoveryCommands::FindCommissionableByLongDiscriminator( - const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByLongDiscriminator::Type & value) -{ - ReturnErrorOnFailure(SetupDiscoveryCommands()); - - chip::Dnssd::DiscoveryFilter filter(chip::Dnssd::DiscoveryFilterType::kLongDiscriminator, value.value); - return mDNSResolver.DiscoverCommissionableNodes(filter); -} - -CHIP_ERROR DiscoveryCommands::FindCommissionableByCommissioningMode( - const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByCommissioningMode::Type & value) -{ - ReturnErrorOnFailure(SetupDiscoveryCommands()); - - chip::Dnssd::DiscoveryFilter filter(chip::Dnssd::DiscoveryFilterType::kCommissioningMode); - return mDNSResolver.DiscoverCommissionableNodes(filter); -} - -CHIP_ERROR DiscoveryCommands::FindCommissionableByVendorId( - const char * identity, const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByVendorId::Type & value) -{ - ReturnErrorOnFailure(SetupDiscoveryCommands()); - - chip::Dnssd::DiscoveryFilter filter(chip::Dnssd::DiscoveryFilterType::kVendorId, value.value); - return mDNSResolver.DiscoverCommissionableNodes(filter); -} - -CHIP_ERROR DiscoveryCommands::FindCommissionableByDeviceType( - const char * identity, const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByDeviceType::Type & value) -{ - ReturnErrorOnFailure(SetupDiscoveryCommands()); - - chip::Dnssd::DiscoveryFilter filter(chip::Dnssd::DiscoveryFilterType::kDeviceType, value.value); - return mDNSResolver.DiscoverCommissionableNodes(filter); -} - -CHIP_ERROR -DiscoveryCommands::FindCommissioner(const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissioner::Type & value) -{ - ReturnErrorOnFailure(SetupDiscoveryCommands()); - - chip::Dnssd::DiscoveryFilter filter(chip::Dnssd::DiscoveryFilterType::kCommissioner, 1); - return mDNSResolver.DiscoverCommissioners(filter); -} - -CHIP_ERROR -DiscoveryCommands::FindCommissionerByVendorId( - const char * identity, const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionerByVendorId::Type & value) -{ - ReturnErrorOnFailure(SetupDiscoveryCommands()); - - chip::Dnssd::DiscoveryFilter filter(chip::Dnssd::DiscoveryFilterType::kVendorId, value.value); - return mDNSResolver.DiscoverCommissioners(filter); -} - -CHIP_ERROR DiscoveryCommands::FindCommissionerByDeviceType( - const char * identity, const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionerByDeviceType::Type & value) -{ - ReturnErrorOnFailure(SetupDiscoveryCommands()); - - chip::Dnssd::DiscoveryFilter filter(chip::Dnssd::DiscoveryFilterType::kDeviceType, value.value); - return mDNSResolver.DiscoverCommissioners(filter); -} - -CHIP_ERROR DiscoveryCommands::SetupDiscoveryCommands() -{ - ReturnErrorOnFailure(TearDownDiscoveryCommands()); - - if (!mReady) - { - ReturnErrorOnFailure(mDNSResolver.Init(chip::DeviceLayer::UDPEndPointManager())); - mReady = true; - } - mDNSResolver.SetCommissioningDelegate(this); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DiscoveryCommands::TearDownDiscoveryCommands() -{ - mDNSResolver.StopDiscovery(); - mDNSResolver.SetCommissioningDelegate(nullptr); - return CHIP_NO_ERROR; -} - -void DiscoveryCommands::OnNodeDiscovered(const chip::Dnssd::DiscoveredNodeData & nodeData) -{ - // TODO: If multiple results are found for the same filter, then the test result depends - // on which result comes first. At the moment, the code assume that there is only - // a single match on the network, but if that's not enough, there may be a need - // to implement some sort of list that is built for a given duration before returning - ReturnOnFailure(TearDownDiscoveryCommands()); - - nodeData.LogDetail(); - - chip::DiscoveryCommandResponse data; - data.hostName = chip::CharSpan(nodeData.resolutionData.hostName, strlen(nodeData.resolutionData.hostName)); - data.instanceName = chip::CharSpan(nodeData.commissionData.instanceName, strlen(nodeData.commissionData.instanceName)); - data.longDiscriminator = nodeData.commissionData.longDiscriminator; - data.shortDiscriminator = ((nodeData.commissionData.longDiscriminator >> 8) & 0x0F); - data.vendorId = nodeData.commissionData.vendorId; - data.productId = nodeData.commissionData.productId; - data.commissioningMode = nodeData.commissionData.commissioningMode; - data.deviceType = nodeData.commissionData.deviceType; - data.deviceName = chip::CharSpan(nodeData.commissionData.deviceName, strlen(nodeData.commissionData.deviceName)); - data.rotatingId = chip::ByteSpan(nodeData.commissionData.rotatingId, nodeData.commissionData.rotatingIdLen); - data.rotatingIdLen = nodeData.commissionData.rotatingIdLen; - data.pairingHint = nodeData.commissionData.pairingHint; - data.pairingInstruction = - chip::CharSpan(nodeData.commissionData.pairingInstruction, strlen(nodeData.commissionData.pairingInstruction)); - data.supportsTcp = nodeData.resolutionData.supportsTcp; - data.port = nodeData.resolutionData.port; - - if (!chip::CanCastTo(nodeData.resolutionData.numIPs)) - { - ChipLogError(chipTool, "Too many ips."); - return; - } - data.numIPs = static_cast(nodeData.resolutionData.numIPs); - - if (nodeData.resolutionData.mrpRetryIntervalIdle.HasValue()) - { - data.mrpRetryIntervalIdle.SetValue(nodeData.resolutionData.mrpRetryIntervalIdle.Value().count()); - } - - if (nodeData.resolutionData.mrpRetryIntervalActive.HasValue()) - { - data.mrpRetryIntervalActive.SetValue(nodeData.resolutionData.mrpRetryIntervalActive.Value().count()); - } - - if (nodeData.resolutionData.mrpRetryActiveThreshold.HasValue()) - { - data.mrpRetryActiveThreshold.SetValue(nodeData.resolutionData.mrpRetryActiveThreshold.Value().count()); - } - - if (nodeData.resolutionData.isICDOperatingAsLIT.HasValue()) - { - data.isICDOperatingAsLIT.SetValue(nodeData.resolutionData.isICDOperatingAsLIT.Value()); - } - - chip::app::StatusIB status; - status.mStatus = chip::Protocols::InteractionModel::Status::Success; - - constexpr uint32_t kMaxDataLen = 4096; - uint8_t * buffer = static_cast(chip::Platform::MemoryCalloc(sizeof(uint8_t), kMaxDataLen)); - if (buffer == nullptr) - { - ChipLogError(chipTool, "Can not dispatch mdns data: %s", chip::ErrorStr(CHIP_ERROR_NO_MEMORY)); - return; - } - - chip::TLV::TLVWriter writer; - writer.Init(buffer, kMaxDataLen); - CHIP_ERROR err = data.Encode(writer, chip::TLV::AnonymousTag()); - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, "Can not encode mdns data: %s", chip::ErrorStr(err)); - return; - } - - uint32_t dataLen = writer.GetLengthWritten(); - writer.Finalize(); - - chip::TLV::TLVReader reader; - reader.Init(buffer, dataLen); - reader.Next(); - - OnResponse(status, &reader); - - chip::Platform::MemoryFree(buffer); -} diff --git a/src/app/tests/suites/commands/discovery/DiscoveryCommands.h b/src/app/tests/suites/commands/discovery/DiscoveryCommands.h deleted file mode 100644 index 8425ef4ff1be81..00000000000000 --- a/src/app/tests/suites/commands/discovery/DiscoveryCommands.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#pragma once - -#include -#include -#include - -#include - -class DiscoveryCommands : public chip::Dnssd::CommissioningResolveDelegate -{ -public: - DiscoveryCommands(){}; - ~DiscoveryCommands() override{}; - - virtual void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) = 0; - virtual CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) = 0; - - CHIP_ERROR FindCommissionable(const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionable::Type & value); - CHIP_ERROR FindCommissionableByShortDiscriminator( - const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByShortDiscriminator::Type & value); - CHIP_ERROR FindCommissionableByLongDiscriminator( - const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByLongDiscriminator::Type & value); - CHIP_ERROR FindCommissionableByCommissioningMode( - const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByCommissioningMode::Type & value); - CHIP_ERROR FindCommissionableByVendorId( - const char * identity, const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByVendorId::Type & value); - CHIP_ERROR FindCommissionableByDeviceType( - const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionableByDeviceType::Type & value); - - CHIP_ERROR FindCommissioner(const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissioner::Type & value); - CHIP_ERROR - FindCommissionerByVendorId(const char * identity, - const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionerByVendorId::Type & value); - CHIP_ERROR FindCommissionerByDeviceType( - const char * identity, const chip::app::Clusters::DiscoveryCommands::Commands::FindCommissionerByDeviceType::Type & value); - - CHIP_ERROR SetupDiscoveryCommands(); - CHIP_ERROR TearDownDiscoveryCommands(); - - /////////// CommissioningDelegate Interface ///////// - void OnNodeDiscovered(const chip::Dnssd::DiscoveredNodeData & nodeData) override; - -private: - bool mReady = false; - chip::Dnssd::ResolverProxy mDNSResolver; -}; diff --git a/src/app/tests/suites/commands/log/BUILD.gn b/src/app/tests/suites/commands/log/BUILD.gn deleted file mode 100644 index b873bf1c38d96d..00000000000000 --- a/src/app/tests/suites/commands/log/BUILD.gn +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) 2022 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. - -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -static_library("log") { - output_name = "libLogCommands" - - sources = [ - "LogCommands.cpp", - "LogCommands.h", - ] - - cflags = [ "-Wconversion" ] - - public_deps = [ - "${chip_root}/src/app/common:simulated", - "${chip_root}/src/lib/support", - ] -} diff --git a/src/app/tests/suites/commands/log/LogCommands.cpp b/src/app/tests/suites/commands/log/LogCommands.cpp deleted file mode 100644 index 690eeea432d881..00000000000000 --- a/src/app/tests/suites/commands/log/LogCommands.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#include "LogCommands.h" -#include - -CHIP_ERROR LogCommands::Log(const char * identity, const chip::app::Clusters::LogCommands::Commands::Log::Type & value) -{ - ChipLogDetail(chipTool, "%.*s", static_cast(value.message.size()), value.message.data()); - return ContinueOnChipMainThread(CHIP_NO_ERROR); -} - -CHIP_ERROR LogCommands::UserPrompt(const char * identity, - const chip::app::Clusters::LogCommands::Commands::UserPrompt::Type & value) -{ - ChipLogDetail(chipTool, "USER_PROMPT: %.*s", static_cast(value.message.size()), value.message.data()); - - if (value.expectedValue.HasValue()) - { - std::string line; - std::getline(std::cin, line); - if (line != std::string(value.expectedValue.Value().data(), value.expectedValue.Value().size())) - { - return ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT); - } - } - - return ContinueOnChipMainThread(CHIP_NO_ERROR); -} diff --git a/src/app/tests/suites/commands/log/LogCommands.h b/src/app/tests/suites/commands/log/LogCommands.h deleted file mode 100644 index 43585dff8acf2e..00000000000000 --- a/src/app/tests/suites/commands/log/LogCommands.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#pragma once - -#include - -#include - -class LogCommands -{ -public: - LogCommands(){}; - virtual ~LogCommands(){}; - - virtual CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) = 0; - - CHIP_ERROR Log(const char * identity, const chip::app::Clusters::LogCommands::Commands::Log::Type & value); - CHIP_ERROR UserPrompt(const char * identity, const chip::app::Clusters::LogCommands::Commands::UserPrompt::Type & value); -}; diff --git a/src/app/tests/suites/commands/system/BUILD.gn b/src/app/tests/suites/commands/system/BUILD.gn deleted file mode 100644 index df9972388b1f33..00000000000000 --- a/src/app/tests/suites/commands/system/BUILD.gn +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) 2022 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. - -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -static_library("system") { - output_name = "libSystemCommands" - - sources = [ - "SystemCommands.cpp", - "SystemCommands.h", - ] - - cflags = [ "-Wconversion" ] - - public_deps = [ - "${chip_root}/src/app/common:simulated", - "${chip_root}/src/lib/support", - ] -} diff --git a/src/app/tests/suites/commands/system/SystemCommands.cpp b/src/app/tests/suites/commands/system/SystemCommands.cpp deleted file mode 100644 index c4e8559ffdf0a1..00000000000000 --- a/src/app/tests/suites/commands/system/SystemCommands.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#include "SystemCommands.h" - -#include - -namespace { -const char basePath[] = "./src/app/tests/suites/commands/system/scripts/"; -const char * getScriptsFolder() -{ - return basePath; -} -} // namespace - -constexpr size_t kCommandMaxLen = 256; -constexpr size_t kArgumentMaxLen = 128; -constexpr char kDefaultKey[] = "default"; - -CHIP_ERROR SystemCommands::Start(const char * identity, const chip::app::Clusters::SystemCommands::Commands::Start::Type & value) -{ - const char * scriptDir = getScriptsFolder(); - constexpr const char * scriptName = "Start.py"; - - char command[kCommandMaxLen]; - chip::StringBuilderBase builder(command, sizeof(command)); - builder.Add(scriptDir); - builder.Add(scriptName); - builder.Add(" "); - - if (value.registerKey.HasValue()) - { - VerifyOrReturnError(value.registerKey.Value().size() < 128, CHIP_ERROR_INVALID_ARGUMENT); - char registerKey[128]; - chip::Platform::CopyString(registerKey, value.registerKey.Value()); - builder.Add(registerKey); - } - else - { - builder.Add(kDefaultKey); - } - - // Add any applicable optional command line options - if (value.discriminator.HasValue()) - { - builder.Add(" --discriminator "); - builder.Add(value.discriminator.Value()); - } - - if (value.port.HasValue()) - { - builder.Add(" --secured-device-port "); - builder.Add(value.port.Value()); - } - - if (value.kvs.HasValue()) - { - AddSystemCommandArgument(builder, "--KVS", value.kvs.Value()); - } - - if (value.minCommissioningTimeout.HasValue()) - { - builder.Add(" --min_commissioning_timeout "); - builder.Add(value.minCommissioningTimeout.Value()); - } - - // OTA provider specific arguments - if (value.filepath.HasValue()) - { - AddSystemCommandArgument(builder, "--filepath", value.filepath.Value()); - } - - // OTA requstor specific arguments - if (value.otaDownloadPath.HasValue()) - { - AddSystemCommandArgument(builder, "--otaDownloadPath", value.otaDownloadPath.Value()); - } - - VerifyOrReturnError(builder.Fit(), CHIP_ERROR_BUFFER_TOO_SMALL); - - return RunInternal(command); -} - -CHIP_ERROR SystemCommands::Stop(const char * identity, const chip::app::Clusters::SystemCommands::Commands::Stop::Type & value) -{ - constexpr const char * scriptName = "Stop.py"; - return RunInternal(scriptName, value.registerKey); -} - -CHIP_ERROR SystemCommands::Reboot(const char * identity, const chip::app::Clusters::SystemCommands::Commands::Reboot::Type & value) -{ - constexpr const char * scriptName = "Reboot.py"; - return RunInternal(scriptName, value.registerKey); -} - -CHIP_ERROR SystemCommands::FactoryReset(const char * identity, - const chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type & value) -{ - constexpr const char * scriptName = "FactoryReset.py"; - return RunInternal(scriptName, value.registerKey); -} - -CHIP_ERROR SystemCommands::CreateOtaImage(const char * identity, - const chip::app::Clusters::SystemCommands::Commands::CreateOtaImage::Type & value) -{ - VerifyOrReturnError(!value.rawImageContent.empty(), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(!value.rawImageFilePath.empty(), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(!value.otaImageFilePath.empty(), CHIP_ERROR_INVALID_ARGUMENT); - - const char * scriptDir = getScriptsFolder(); - constexpr const char * scriptName = "CreateOtaImage.py"; - - char command[128]; - VerifyOrReturnError(snprintf(command, sizeof(command), "%s%s %.*s %.*s %.*s", scriptDir, scriptName, - static_cast(value.otaImageFilePath.size()), value.otaImageFilePath.data(), - static_cast(value.rawImageFilePath.size()), value.rawImageFilePath.data(), - static_cast(value.rawImageContent.size()), value.rawImageContent.data()) >= 0, - CHIP_ERROR_INTERNAL); - return RunInternal(command); -} - -CHIP_ERROR SystemCommands::CompareFiles(const char * identity, - const chip::app::Clusters::SystemCommands::Commands::CompareFiles::Type & value) -{ - VerifyOrReturnError(!value.file1.empty(), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(!value.file2.empty(), CHIP_ERROR_INVALID_ARGUMENT); - - const char * scriptDir = getScriptsFolder(); - constexpr const char * scriptName = "CompareFiles.py"; - - char command[128]; - VerifyOrReturnError(snprintf(command, sizeof(command), "%s%s %.*s %.*s", scriptDir, scriptName, - static_cast(value.file1.size()), value.file1.data(), static_cast(value.file2.size()), - value.file2.data()) >= 0, - CHIP_ERROR_INTERNAL); - return RunInternal(command); -} - -CHIP_ERROR SystemCommands::RunInternal(const char * scriptName, const chip::Optional registerKey) -{ - const char * scriptDir = getScriptsFolder(); - const char * registerKeyValue = registerKey.HasValue() ? registerKey.Value().data() : kDefaultKey; - const size_t registerKeyLen = registerKey.HasValue() ? registerKey.Value().size() : strlen(kDefaultKey); - - char command[kCommandMaxLen]; - VerifyOrReturnError(snprintf(command, sizeof(command), "%s%s %.*s", scriptDir, scriptName, static_cast(registerKeyLen), - registerKeyValue) >= 0, - CHIP_ERROR_INTERNAL); - return RunInternal(command); -} - -CHIP_ERROR SystemCommands::RunInternal(const char * command) -{ - VerifyOrReturnError(system(command) == 0, CHIP_ERROR_INTERNAL); - return ContinueOnChipMainThread(CHIP_NO_ERROR); -} - -CHIP_ERROR SystemCommands::AddSystemCommandArgument(chip::StringBuilderBase & builder, const char * argName, - const chip::CharSpan & argValue) -{ - VerifyOrReturnError(argValue.size() < kArgumentMaxLen, CHIP_ERROR_INVALID_ARGUMENT); - - builder.Add(" "); - builder.Add(argName); - builder.Add(" "); - - char arg[kArgumentMaxLen]; - chip::Platform::CopyString(arg, argValue); - builder.Add(arg); - - return CHIP_NO_ERROR; -} diff --git a/src/app/tests/suites/commands/system/SystemCommands.h b/src/app/tests/suites/commands/system/SystemCommands.h deleted file mode 100644 index 7e14fc89c5bcfe..00000000000000 --- a/src/app/tests/suites/commands/system/SystemCommands.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#pragma once - -#include -#include - -#include - -class SystemCommands -{ -public: - SystemCommands(){}; - virtual ~SystemCommands(){}; - - virtual CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) = 0; - - CHIP_ERROR Start(const char * identity, const chip::app::Clusters::SystemCommands::Commands::Start::Type & value); - CHIP_ERROR Stop(const char * identity, const chip::app::Clusters::SystemCommands::Commands::Stop::Type & value); - CHIP_ERROR Reboot(const char * identity, const chip::app::Clusters::SystemCommands::Commands::Reboot::Type & value); - CHIP_ERROR FactoryReset(const char * identity, const chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type & value); - CHIP_ERROR CreateOtaImage(const char * identity, - const chip::app::Clusters::SystemCommands::Commands::CreateOtaImage::Type & value); - CHIP_ERROR CompareFiles(const char * identity, const chip::app::Clusters::SystemCommands::Commands::CompareFiles::Type & value); - -private: - CHIP_ERROR RunInternal(const char * scriptName, const chip::Optional registerKey); - CHIP_ERROR RunInternal(const char * command); - CHIP_ERROR AddSystemCommandArgument(chip::StringBuilderBase & builder, const char * argName, const chip::CharSpan & argValue); -}; diff --git a/src/app/tests/suites/commands/system/scripts/CompareFiles.py b/src/app/tests/suites/commands/system/scripts/CompareFiles.py deleted file mode 100755 index fcb1c1506a2e4d..00000000000000 --- a/src/app/tests/suites/commands/system/scripts/CompareFiles.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env -S python3 -B - -# Copyright (c) 2022 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. - -import sys -import xmlrpc.client - -IP = '127.0.0.1' -PORT = 9000 - -if sys.platform == 'linux': - IP = '10.10.10.5' - -# Passing in sys.argv[2:] gets rid of the script name and key to the apps register. The remaining -# values in the list are key-value pairs, e.g. [option1, value1, option2, value2, ...] -with xmlrpc.client.ServerProxy('http://' + IP + ':' + str(PORT) + '/', allow_none=True) as proxy: - file1 = sys.argv[1] - file2 = sys.argv[2] - proxy.compareFiles(file1, file2) diff --git a/src/app/tests/suites/commands/system/scripts/CreateOtaImage.py b/src/app/tests/suites/commands/system/scripts/CreateOtaImage.py deleted file mode 100755 index c0a343c8adf4f7..00000000000000 --- a/src/app/tests/suites/commands/system/scripts/CreateOtaImage.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env -S python3 -B - -# Copyright (c) 2022 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. - -import sys -import xmlrpc.client - -IP = '127.0.0.1' -PORT = 9000 - -if sys.platform == 'linux': - IP = '10.10.10.5' - -# Passing in sys.argv[2:] gets rid of the script name and key to the apps register. The remaining -# values in the list are key-value pairs, e.g. [option1, value1, option2, value2, ...] -with xmlrpc.client.ServerProxy('http://' + IP + ':' + str(PORT) + '/', allow_none=True) as proxy: - otaImageFilePath = sys.argv[1] - rawImageFilePath = sys.argv[2] - rawImageContent = ' '.join(sys.argv[3:]) - - proxy.createOtaImage(otaImageFilePath, rawImageFilePath, rawImageContent) diff --git a/src/app/tests/suites/commands/system/scripts/FactoryReset.py b/src/app/tests/suites/commands/system/scripts/FactoryReset.py deleted file mode 100755 index c78651a229f758..00000000000000 --- a/src/app/tests/suites/commands/system/scripts/FactoryReset.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env -S python3 -B - -# Copyright (c) 2022 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. - -import sys -import xmlrpc.client - -IP = '127.0.0.1' -PORT = 9000 - -if sys.platform == 'linux': - IP = '10.10.10.5' - -# sys.argv[1] contains the key to the apps register -with xmlrpc.client.ServerProxy('http://' + IP + ':' + str(PORT) + '/', allow_none=True) as proxy: - proxy.factoryReset(sys.argv[1]) diff --git a/src/app/tests/suites/commands/system/scripts/Reboot.py b/src/app/tests/suites/commands/system/scripts/Reboot.py deleted file mode 100755 index 8d6b430041bfea..00000000000000 --- a/src/app/tests/suites/commands/system/scripts/Reboot.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env -S python3 -B - -# Copyright (c) 2022 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. - -import sys -import xmlrpc.client - -IP = '127.0.0.1' -PORT = 9000 - -if sys.platform == 'linux': - IP = '10.10.10.5' - -# sys.argv[1] contains the key to the apps register -with xmlrpc.client.ServerProxy('http://' + IP + ':' + str(PORT) + '/', allow_none=True) as proxy: - proxy.reboot(sys.argv[1]) diff --git a/src/app/tests/suites/commands/system/scripts/Start.py b/src/app/tests/suites/commands/system/scripts/Start.py deleted file mode 100755 index 1a3c70013ce942..00000000000000 --- a/src/app/tests/suites/commands/system/scripts/Start.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env -S python3 -B - -# Copyright (c) 2022 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. - -import sys -import xmlrpc.client - -IP = '127.0.0.1' -PORT = 9000 - -if sys.platform == 'linux': - IP = '10.10.10.5' - -# Passing in sys.argv[2:] gets rid of the script name and key to the apps register. The remaining -# values in the list are key-value pairs, e.g. [option1, value1, option2, value2, ...] -with xmlrpc.client.ServerProxy('http://' + IP + ':' + str(PORT) + '/', allow_none=True) as proxy: - proxy.start(sys.argv[1], sys.argv[2:]) diff --git a/src/app/tests/suites/commands/system/scripts/Stop.py b/src/app/tests/suites/commands/system/scripts/Stop.py deleted file mode 100755 index 75f843e85e3835..00000000000000 --- a/src/app/tests/suites/commands/system/scripts/Stop.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env -S python3 -B - -# Copyright (c) 2022 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. - -import sys -import xmlrpc.client - -IP = '127.0.0.1' -PORT = 9000 - -if sys.platform == 'linux': - IP = '10.10.10.5' - -# sys.argv[1] contains the key to the apps register -with xmlrpc.client.ServerProxy('http://' + IP + ':' + str(PORT) + '/', allow_none=True) as proxy: - proxy.stop(sys.argv[1]) diff --git a/src/app/tests/suites/include/ConstraintsChecker.h b/src/app/tests/suites/include/ConstraintsChecker.h deleted file mode 100644 index 0811ca85923f83..00000000000000 --- a/src/app/tests/suites/include/ConstraintsChecker.h +++ /dev/null @@ -1,678 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#pragma once - -#include - -#include -#include - -class ConstraintsChecker -{ -public: - ConstraintsChecker(){}; - virtual ~ConstraintsChecker(){}; - -protected: - virtual void Exit(std::string message, CHIP_ERROR err = CHIP_ERROR_INTERNAL) = 0; - - bool CheckConstraintType(const char * itemName, const char * current, const char * expected) - { - if (strcmp(current, expected) != 0) - { - Exit(std::string(itemName) + " type (" + std::string(current) + ") is different than the expected type (" + - std::string(expected) + ")."); - return false; - } - - return true; - } - - bool CheckConstraintFormat(const char * itemName, const char * current, const char * expected) - { - ChipLogError(chipTool, "Warning: %s format checking is not implemented yet. Expected format: '%s'", - StringOrNullMarker(itemName), StringOrNullMarker(expected)); - return true; - } - - bool CheckConstraintMinLength(const char * itemName, uint64_t current, uint64_t expected) - { - if (current < expected) - { - Exit(std::string(itemName) + " length < minLength: " + std::to_string(current) + " < " + std::to_string(expected)); - return false; - } - - return true; - } - - bool CheckConstraintMaxLength(const char * itemName, uint64_t current, uint64_t expected) - { - if (current > expected) - { - Exit(std::string(itemName) + " length > maxLength: " + std::to_string(current) + " > " + std::to_string(expected)); - return false; - } - - return true; - } - - template - bool CheckConstraintMinLength(const char * itemName, const chip::Span & current, uint64_t expected) - { - return CheckConstraintMinLength(itemName, current.size(), expected); - } - - template - bool CheckConstraintMinLength(const char * itemName, const chip::app::DataModel::Nullable> & current, - uint64_t expected) - { - if (current.IsNull()) - { - return true; - } - - return CheckConstraintMinLength(itemName, current.Value(), expected); - } - - template - bool CheckConstraintMaxLength(const char * itemName, const chip::Span & current, uint64_t expected) - { - return CheckConstraintMaxLength(itemName, current.size(), expected); - } - - template - bool CheckConstraintMaxLength(const char * itemName, const chip::app::DataModel::Nullable> & current, - uint64_t expected) - { - if (current.IsNull()) - { - return true; - } - - return CheckConstraintMaxLength(itemName, current.Value(), expected); - } - - template - bool CheckConstraintMinLength(const char * itemName, const chip::app::DataModel::DecodableList & current, uint64_t expected) - { - size_t size; - CHIP_ERROR err = current.ComputeSize(&size); - if (err != CHIP_NO_ERROR) - { - Exit(std::string(itemName) + " length cannot be extracted: " + err.AsString()); - return false; - } - return CheckConstraintMinLength(itemName, size, expected); - } - - template - bool CheckConstraintMaxLength(const char * itemName, const chip::app::DataModel::DecodableList & current, uint64_t expected) - { - size_t size; - CHIP_ERROR err = current.ComputeSize(&size); - if (err != CHIP_NO_ERROR) - { - Exit(std::string(itemName) + " length cannot be extracted: " + err.AsString()); - return false; - } - return CheckConstraintMaxLength(itemName, size, expected); - } - - bool CheckConstraintStartsWith(const char * itemName, const chip::CharSpan current, const char * expected) - { - std::string value(current.data(), current.size()); - if (value.rfind(expected, 0) != 0) - { - Exit(std::string(itemName) + " (\"" + value + "\") does not starts with: \"" + std::string(expected) + "\""); - return false; - } - - return true; - } - - bool CheckConstraintEndsWith(const char * itemName, const chip::CharSpan current, const char * expected) - { - std::string value(current.data(), current.size()); - if (value.find(expected, value.size() - strlen(expected)) == std::string::npos) - { - Exit(std::string(itemName) + " (\"" + value + "\") does not ends with: \"" + std::string(expected) + "\""); - return false; - } - - return true; - } - - bool CheckConstraintIsUpperCase(const char * itemName, const chip::CharSpan current, bool expectUpperCase) - { - std::string value(current.data(), current.size()); - return CheckConstraintIsUpperCase(itemName, value.c_str(), expectUpperCase); - } - - bool CheckConstraintIsUpperCase(const char * itemName, const char * current, bool expectUpperCase) - { - bool isUpperCase = true; - for (size_t i = 0; i < strlen(current); i++) - { - if (islower(current[i])) - { - isUpperCase = false; - break; - } - } - - if (expectUpperCase && !isUpperCase) - { - Exit(std::string(itemName) + " (\"" + std::string(current) + "\") is not an upppercase string"); - return false; - } - - if (!expectUpperCase && isUpperCase) - { - Exit(std::string(itemName) + " (\"" + std::string(current) + "\") is an upppercase string"); - return false; - } - - return true; - } - - bool CheckConstraintIsLowerCase(const char * itemName, const chip::CharSpan current, bool expectLowerCase) - { - std::string value(current.data(), current.size()); - return CheckConstraintIsLowerCase(itemName, value.c_str(), expectLowerCase); - } - - bool CheckConstraintIsLowerCase(const char * itemName, const char * current, bool expectLowerCase) - { - bool isLowerCase = true; - for (size_t i = 0; i < strlen(current); i++) - { - if (isupper(current[i])) - { - isLowerCase = false; - break; - } - } - - if (expectLowerCase && !isLowerCase) - { - Exit(std::string(itemName) + " (\"" + std::string(current) + "\") is not a lowercase string"); - return false; - } - - if (!expectLowerCase && isLowerCase) - { - Exit(std::string(itemName) + " (\"" + std::string(current) + "\") is a lowercase string"); - return false; - } - - return true; - } - - bool CheckConstraintIsHexString(const char * itemName, const chip::CharSpan current, bool expectHexString) - { - std::string value(current.data(), current.size()); - return CheckConstraintIsHexString(itemName, value.c_str(), expectHexString); - } - - bool CheckConstraintIsHexString(const char * itemName, const char * current, bool expectHexString) - { - bool isHexString = true; - for (size_t i = 0; i < strlen(current); i++) - { - if (!isxdigit(current[i])) - { - isHexString = false; - break; - } - } - - if (expectHexString && !isHexString) - { - Exit(std::string(itemName) + " (\"" + std::string(current) + "\") is not a hexadecimal string"); - return false; - } - - if (!expectHexString && isHexString) - { - Exit(std::string(itemName) + " (\"" + std::string(current) + "\") is a hexadecimal string"); - return false; - } - - return true; - } - - template ::value && !std::is_pointer::value, int> = 0> - bool CheckConstraintMinValue(const char * itemName, T current, U expected) - { - if (current < expected) - { - Exit(std::string(itemName) + " value < minValue: " + std::to_string(current) + " < " + std::to_string(expected)); - return false; - } - - return true; - } - - template ::value && !std::is_enum::value && !std::is_pointer::value, int> = 0> - bool CheckConstraintMinValue(const char * itemName, T current, U expected) - { - return CheckConstraintMinValue(itemName, chip::to_underlying(current), expected); - } - - template ::value && std::is_enum::value, int> = 0> - bool CheckConstraintMinValue(const char * itemName, T current, U expected) - { - return CheckConstraintMinValue(itemName, chip::to_underlying(current), chip::to_underlying(expected)); - } - - template ::value && std::is_enum::value, int> = 0> - bool CheckConstraintMinValue(const char * itemName, T current, U expected) - { - return CheckConstraintMinValue(itemName, current, chip::to_underlying(expected)); - } - - template ::value, int> = 0> - bool CheckConstraintMinValue(const char * itemName, chip::BitFlags current, U expected) - { - if (current.Raw() < expected) - { - Exit(std::string(itemName) + " value < minValue: " + std::to_string(current.Raw()) + " < " + std::to_string(expected)); - return false; - } - - return true; - } - - template ::value, int> = 0> - bool CheckConstraintMinValue(const char * itemName, chip::BitMask current, U expected) - { - if (current.Raw() < expected) - { - Exit(std::string(itemName) + " value < minValue: " + std::to_string(current.Raw()) + " < " + std::to_string(expected)); - return false; - } - - return true; - } - - template ::value, int> = 0> - bool CheckConstraintMinValue(const char * itemName, const chip::app::DataModel::Nullable & current, U expected) - { - if (current.IsNull()) - { - return true; - } - return CheckConstraintMinValue(itemName, current.Value(), static_cast(expected)); - } - - template - bool CheckConstraintMinValue(const char * itemName, const chip::app::DataModel::Nullable & current, - const chip::app::DataModel::Nullable & expected) - { - if (expected.IsNull()) - { - return true; - } - return CheckConstraintMinValue(itemName, current, expected.Value()); - } - - template - bool CheckConstraintMinValue(const char * itemName, const T & current, const chip::Optional & expected) - { - if (!expected.HasValue()) - { - Exit(std::string(itemName) + ": expected min value does not have a value"); - return false; - } - return CheckConstraintMinValue(itemName, current, expected.Value()); - } - - template ::value && !std::is_pointer::value, int> = 0> - bool CheckConstraintMaxValue(const char * itemName, T current, U expected) - { - if (current > expected) - { - Exit(std::string(itemName) + " value > maxValue: " + std::to_string(current) + " > " + std::to_string(expected)); - return false; - } - - return true; - } - - template ::value && !std::is_enum::value && !std::is_pointer::value, int> = 0> - bool CheckConstraintMaxValue(const char * itemName, T current, U expected) - { - return CheckConstraintMaxValue(itemName, chip::to_underlying(current), expected); - } - - template ::value && std::is_enum::value, int> = 0> - bool CheckConstraintMaxValue(const char * itemName, T current, U expected) - { - return CheckConstraintMaxValue(itemName, chip::to_underlying(current), chip::to_underlying(expected)); - } - - template ::value && std::is_enum::value, int> = 0> - bool CheckConstraintMaxValue(const char * itemName, T current, U expected) - { - return CheckConstraintMaxValue(itemName, current, chip::to_underlying(expected)); - } - - template ::value, int> = 0> - bool CheckConstraintMaxValue(const char * itemName, chip::BitFlags current, U expected) - { - if (current.Raw() > expected) - { - Exit(std::string(itemName) + " value > maxValue: " + std::to_string(current.Raw()) + " > " + std::to_string(expected)); - return false; - } - - return true; - } - - template ::value, int> = 0> - bool CheckConstraintMaxValue(const char * itemName, chip::BitMask current, U expected) - { - if (current.Raw() > expected) - { - Exit(std::string(itemName) + " value > maxValue: " + std::to_string(current.Raw()) + " > " + std::to_string(expected)); - return false; - } - - return true; - } - - template ::value, int> = 0> - bool CheckConstraintMaxValue(const char * itemName, const chip::app::DataModel::Nullable & current, U expected) - { - if (current.IsNull()) - { - return true; - } - return CheckConstraintMaxValue(itemName, current.Value(), static_cast(expected)); - } - - template - bool CheckConstraintMaxValue(const char * itemName, const chip::app::DataModel::Nullable & current, - const chip::app::DataModel::Nullable & expected) - { - if (expected.IsNull()) - { - return true; - } - return CheckConstraintMaxValue(itemName, current, expected.Value()); - } - - template - bool CheckConstraintMaxValue(const char * itemName, const T & current, const chip::Optional & expected) - { - if (!expected.HasValue()) - { - Exit(std::string(itemName) + ": expected max value does not have a value"); - return false; - } - return CheckConstraintMaxValue(itemName, current, expected.Value()); - } - - template - bool CheckConstraintNotValue(const char * itemName, const chip::app::DataModel::Nullable & current, - const chip::app::DataModel::Nullable & expected) - { - if (expected.IsNull() && current.IsNull()) - { - Exit(std::string(itemName) + " got null for both values, but expected not equal"); - return false; - } - - if (expected.IsNull() != current.IsNull()) - { - return true; - } - - return CheckConstraintNotValue(itemName, current.Value(), expected.Value()); - } - - template ::value, int> = 0> - bool CheckConstraintNotValue(const char * itemName, T current, U expected) - { - if (current == expected) - { - Exit(std::string(itemName) + " got unexpected value: " + std::to_string(current)); - return false; - } - - return true; - } - - template ::value, int> = 0> - bool CheckConstraintNotValue(const char * itemName, T current, U expected) - { - return CheckConstraintNotValue(itemName, chip::to_underlying(current), expected); - } - - template ::value, int> = 0> - bool CheckConstraintNotValue(const char * itemName, T current, T expected) - { - return CheckConstraintNotValue(itemName, chip::to_underlying(current), chip::to_underlying(expected)); - } - - template - bool CheckConstraintNotValue(const char * itemName, chip::BitFlags current, chip::BitFlags expected) - { - if (current == expected) - { - Exit(std::string(itemName) + " got unexpected value: " + std::to_string(current.Raw())); - return false; - } - - return true; - } - - template - bool CheckConstraintNotValue(const char * itemName, chip::BitMask current, chip::BitMask expected) - { - if (current == expected) - { - Exit(std::string(itemName) + " got unexpected value: " + std::to_string(current.Raw())); - return false; - } - - return true; - } - - template - bool CheckConstraintNotValue(const char * itemName, chip::BitFlags current, U expected) - { - if (current.Raw() == expected) - { - - Exit(std::string(itemName) + " got unexpected value: " + std::to_string(current.Raw())); - return false; - } - - return true; - } - - template - bool CheckConstraintNotValue(const char * itemName, chip::BitMask current, U expected) - { - if (current.Raw() == expected) - { - - Exit(std::string(itemName) + " got unexpected value: " + std::to_string(current.Raw())); - return false; - } - - return true; - } - - template - bool CheckConstraintNotValue(const char * itemName, const chip::app::DataModel::Nullable & current, U expected) - { - if (current.IsNull()) - { - return true; - } - return CheckConstraintNotValue(itemName, current.Value(), expected); - } - - bool CheckConstraintNotValue(const char * itemName, const chip::CharSpan current, const chip::CharSpan expected) - { - if (current.data_equal(expected)) - { - Exit(std::string(itemName) + " got unexpected value: " + std::string(current.data(), current.size())); - return false; - } - - return true; - } - - bool CheckConstraintNotValue(const char * itemName, const chip::ByteSpan current, const chip::ByteSpan expected) - { - if (current.data_equal(expected)) - { - Exit(std::string(itemName) + " got unexpected value of size: " + std::to_string(current.size())); - return false; - } - - return true; - } - - template - bool CheckConstraintNotValue(const char * itemName, const T & current, const chip::Optional & expected) - { - if (!expected.HasValue()) - { - Exit(std::string(itemName) + ": expected disallowed value does not have a value"); - return false; - } - return CheckConstraintNotValue(itemName, current, expected.Value()); - } - - template - bool CheckConstraintHasValue(const char * itemName, const chip::Optional & current, bool expected) - { - if (current.HasValue() == expected) - { - return true; - } - - if (current.HasValue()) - { - Exit(std::string(itemName) + " not expected to have a value but does"); - } - else - { - Exit(std::string(itemName) + " expected to have a value but doesn't"); - } - return false; - } - - template - bool CheckConstraintContains(const char * itemName, const chip::app::DataModel::DecodableList & current, const U & expected) - { - auto iterValue = current.begin(); - while (iterValue.Next()) - { - auto currentValue = iterValue.GetValue(); - if (currentValue == expected) - { - return true; - } - } - - Exit(std::string(itemName) + " expect the value " + std::to_string(expected) + " but the list does not contains it."); - return false; - } - - template - bool CheckConstraintExcludes(const char * itemName, const chip::app::DataModel::DecodableList & current, const U & expected) - { - auto iterValue = current.begin(); - while (iterValue.Next()) - { - auto currentValue = iterValue.GetValue(); - if (currentValue == expected) - { - Exit(std::string(itemName) + " does not expect the value " + std::to_string(expected) + - " but the list contains it."); - return false; - } - } - - CHIP_ERROR err = iterValue.GetStatus(); - if (CHIP_NO_ERROR != err) - { - Exit(std::string(chip::ErrorStr(err))); - return false; - } - - return true; - } - - template - bool CheckConstraintHasMasksSet(const char * itemName, const T & current, const U & expected) - { - if (current & expected) - { - return true; - } - - Exit(std::string(itemName) + " expects the field with value " + std::to_string(expected) + " to be set but it is not."); - return false; - } - - template - bool CheckConstraintHasMasksSet(const char * itemName, const chip::BitMask & current, const U & expected) - { - if (current.Has(static_cast(expected))) - { - return true; - } - - Exit(std::string(itemName) + " expects the field with value " + std::to_string(expected) + " to be set but it is not."); - return false; - } - - template - bool CheckConstraintHasMasksClear(const char * itemName, const T & current, const U & expected) - { - if ((current & expected) == 0) - { - return true; - } - - Exit(std::string(itemName) + " expects the field with value " + std::to_string(expected) + " to not be set but it is."); - return false; - } - - template - bool CheckConstraintHasMasksClear(const char * itemName, const chip::BitMask & current, const U & expected) - { - if (!current.Has(static_cast(expected))) - { - return true; - } - - Exit(std::string(itemName) + " expects the field with value " + std::to_string(expected) + " to not be set but it is."); - return false; - } -}; diff --git a/src/app/tests/suites/include/PICSChecker.h b/src/app/tests/suites/include/PICSChecker.h deleted file mode 100644 index 0423e583ebd522..00000000000000 --- a/src/app/tests/suites/include/PICSChecker.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - */ - -#pragma once - -#include - -#include -#include -#include -#include - -class PICSChecker -{ -public: - bool ShouldSkip(const char * expression) - { - // If there is no PICS configuration file, considers that nothing should be skipped. - if (!PICS.HasValue()) - { - return false; - } - - std::map pics(PICS.Value()); - bool shouldSkip = !PICSBooleanExpressionParser::Eval(expression, pics); - if (shouldSkip) - { - ChipLogProgress(chipTool, " **** Skipping: %s == false\n", StringOrNullMarker(expression)); - } - return shouldSkip; - } - - chip::Optional> PICS; -}; diff --git a/src/app/tests/suites/include/TestRunner.h b/src/app/tests/suites/include/TestRunner.h deleted file mode 100644 index 719f758c01e641..00000000000000 --- a/src/app/tests/suites/include/TestRunner.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#pragma once - -#include - -#include -#include -#include - -class TestRunner -{ -public: - TestRunner(const char * name, uint16_t testCount) : mTestName(name), mTestCount(testCount), mTestIndex(0) {} - virtual ~TestRunner(){}; - - void LogStart() { ChipLogProgress(chipTool, " ***** Test Start : %s\n", StringOrNullMarker(mTestName)); } - - void LogStep(uint32_t stepNumber, const char * stepName) - { - ChipLogProgress(chipTool, " ***** Test Step %u : %s\n", stepNumber, StringOrNullMarker(stepName)); - } - - void LogEnd(std::string message, CHIP_ERROR err) - { - if (CHIP_NO_ERROR == err) - { - ChipLogProgress(chipTool, " **** Test Complete: %s\n", message.c_str()); - } - else - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", message.c_str()); - } - } - - virtual CHIP_ERROR DoTestStep(uint16_t testIndex) = 0; - virtual void Exit(std::string message, CHIP_ERROR err = CHIP_ERROR_INTERNAL) = 0; - - void NextTest() - { - if (mTestSubStepIndex != mTestSubStepCount) - { - Exit(mTestName, CHIP_ERROR_INVALID_ARGUMENT); - return; - } - mTestSubStepIndex = 0; - mTestSubStepCount = 0; - - if (0 == mTestIndex) - { - LogStart(); - } - - if (mTestCount == mTestIndex) - { - Exit(mTestName, CHIP_NO_ERROR); - return; - } - - if (mDelayInMs.HasValue()) - { - chip::test_utils::SleepMillis(mDelayInMs.Value()); - } - - // 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. - auto err = DoTestStep(mTestIndex++); - if (CHIP_NO_ERROR != err) - { - Exit(chip::ErrorStr(err)); - } - } - -protected: - const char * mTestName; - const uint16_t mTestCount; - std::atomic_uint16_t mTestIndex; - chip::Optional mDelayInMs; - - uint16_t mTestSubStepIndex = 0; - uint16_t mTestSubStepCount = 0; -}; diff --git a/src/app/tests/suites/include/ValueChecker.h b/src/app/tests/suites/include/ValueChecker.h deleted file mode 100644 index 3fa032a4db638a..00000000000000 --- a/src/app/tests/suites/include/ValueChecker.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * 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. - * - */ - -#pragma once - -#include - -#include -#include - -class ValueChecker -{ -public: - ValueChecker(){}; - virtual ~ValueChecker(){}; - -protected: - virtual void Exit(std::string message, CHIP_ERROR err = CHIP_ERROR_INTERNAL) = 0; - - bool CheckDecodeValue(CHIP_ERROR error) - { - if (CHIP_NO_ERROR != error) - { - Exit(std::string("Can not decode data: ") + chip::ErrorStr(error)); - return false; - } - - return true; - } - - bool CheckValueAsString(const char * itemName, chip::ByteSpan current, chip::ByteSpan expected) - { - if (!current.data_equal(expected)) - { - Exit(std::string(itemName) + " value mismatch, expecting " + - std::string(chip::Uint8::to_const_char(expected.data()), expected.size())); - return false; - } - - return true; - } - - bool CheckValueAsString(const char * itemName, chip::CharSpan current, chip::CharSpan expected) - { - if (!current.data_equal(expected)) - { - Exit(std::string(itemName) + " value mismatch, expected '" + std::string(expected.data(), expected.size()) + - "' but got '" + std::string(current.data(), current.size()) + "'"); - return false; - } - - return true; - } - - // Allow a different expected type from the actual value type, because if T - // is short the literal we are using is not short-typed. - template ::value && !std::is_enum::value, int> = 0> - bool CheckValue(const char * itemName, T current, U expected) - { - if (current != expected) - { - Exit(std::string(itemName) + " value mismatch: expected " + std::to_string(expected) + " but got " + - std::to_string(current)); - return false; - } - - return true; - } - - template ::value && std::is_enum::value, int> = 0> - bool CheckValue(const char * itemName, T current, U expected) - { - return CheckValue(itemName, current, chip::to_underlying(expected)); - } - - template ::value, int> = 0> - bool CheckValue(const char * itemName, T current, U expected) - { - return CheckValue(itemName, chip::to_underlying(current), expected); - } - - template - bool CheckValue(const char * itemName, chip::BitFlags current, U expected) - { - return CheckValue(itemName, current.Raw(), expected); - } - - template - bool CheckValue(const char * itemName, chip::BitMask current, U expected) - { - return CheckValue(itemName, current.Raw(), expected); - } - - // Allow an expected value that is a nullable wrapped around the actual - // value (e.g. a SaveAs from reading a different attribute that has a value - // space that includes null). In that case we check that: - // 1) The nullable is not in fact null. - // - // 2) The value in the nullable matches our test value. - template - bool CheckValue(const char * itemName, T current, const chip::app::DataModel::Nullable & expected) - { - auto nullableName = std::string(itemName); - nullableName += " expected value"; - return CheckValueNonNull(nullableName.c_str(), expected) && CheckValue(itemName, current, expected.Value()); - } - - template - bool CheckValue(const char * itemName, chip::BitFlags current, chip::BitFlags expected) - { - return CheckValue(itemName, current.Raw(), expected.Raw()); - } - - template - bool CheckValue(const char * itemName, chip::BitMask current, chip::BitMask expected) - { - return CheckValue(itemName, current.Raw(), expected.Raw()); - } - - template - bool CheckValuePresent(const char * itemName, const chip::Optional & value) - { - if (value.HasValue()) - { - return true; - } - - Exit(std::string(itemName) + " expected to have value but doesn't"); - return false; - } - - template - bool CheckValueNull(const char * itemName, const chip::app::DataModel::Nullable & value) - { - if (value.IsNull()) - { - return true; - } - - Exit(std::string(itemName) + " expected to be null but isn't"); - return false; - } - - template - bool CheckValueNonNull(const char * itemName, const chip::app::DataModel::Nullable & value) - { - if (!value.IsNull()) - { - return true; - } - - Exit(std::string(itemName) + " expected to not be null but is"); - return false; - } - - /** - * Check that the next list item, which is at index "index", exists and - * decodes properly. - */ - template - bool CheckNextListItemDecodes(const char * listName, typename std::remove_reference_t::Iterator & iter, size_t index) - { - bool hasValue = iter.Next(); - if (iter.GetStatus() != CHIP_NO_ERROR) - { - Exit(std::string(listName) + " value mismatch: error '" + iter.GetStatus().AsString() + "'decoding item at index " + - std::to_string(index)); - return false; - } - - if (hasValue) - { - return true; - } - - Exit(std::string(listName) + " value mismatch: should have value at index " + std::to_string(index) + - " but doesn't (actual value too short)"); - return false; - } - - /** - * Check that there are no more list items now that we have seen - * "expectedCount" of them. - */ - template - bool CheckNoMoreListItems(const char * listName, typename std::remove_reference_t::Iterator & iter, - size_t expectedCount) - { - bool hasValue = iter.Next(); - if (iter.GetStatus() != CHIP_NO_ERROR) - { - Exit(std::string(listName) + " value mismatch: error '" + iter.GetStatus().AsString() + - "'decoding item after we have seen " + std::to_string(expectedCount) + " items"); - return false; - } - - if (!hasValue) - { - return true; - } - - Exit(std::string(listName) + " value mismatch: expected only " + std::to_string(expectedCount) + - " items, but have more than that (actual value too long)"); - return false; - } -}; diff --git a/src/app/tests/suites/pics/BUILD.gn b/src/app/tests/suites/pics/BUILD.gn deleted file mode 100644 index df8ae17dded523..00000000000000 --- a/src/app/tests/suites/pics/BUILD.gn +++ /dev/null @@ -1,33 +0,0 @@ -# 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. - -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -static_library("pics") { - output_name = "libPICS" - - sources = [ - "PICSBooleanExpressionParser.cpp", - "PICSBooleanExpressionParser.h", - "PICSBooleanReader.cpp", - "PICSBooleanReader.h", - "PICSNormalizer.cpp", - "PICSNormalizer.h", - ] - - cflags = [ "-Wconversion" ] - - public_deps = [ "${chip_root}/src/lib/support" ] -} diff --git a/src/app/tests/suites/pics/PICSBooleanExpressionParser.cpp b/src/app/tests/suites/pics/PICSBooleanExpressionParser.cpp deleted file mode 100644 index 7aac171f20b128..00000000000000 --- a/src/app/tests/suites/pics/PICSBooleanExpressionParser.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * 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. - */ - -#include "PICSBooleanExpressionParser.h" -#include "PICSNormalizer.h" - -#include - -bool PICSBooleanExpressionParser::Eval(std::string expression, std::map & PICS) -{ - std::vector tokens; - uint8_t index = 0; - - Tokenize(expression, tokens); - return EvaluateExpression(tokens, PICS, index); -} - -void PICSBooleanExpressionParser::Tokenize(std::string & expression, std::vector & tokens) -{ - if (expression.empty()) - { - return; - } - - std::string s; - - for (char c : expression) - { - switch (c) - { - case ' ': - case '\n': - case '\t': - if (s.empty()) - { - continue; - } - break; - - case '(': - case ')': - case '!': - if (!s.empty() > 0) - { - tokens.push_back(s); - s.clear(); - } - - tokens.push_back(std::string(1, c)); - break; - - case '&': - case '|': - if (!s.empty() && s.back() == c) - { - s.pop_back(); - if (s.size()) - { - tokens.push_back(s); - s.clear(); - } - - tokens.push_back(std::string(1, c) + std::string(1, c)); - break; - } - - s.push_back(c); - break; - - default: - s.push_back(c); - break; - } - } - - if (s.size()) - { - tokens.push_back(s); - } -} - -bool PICSBooleanExpressionParser::EvaluateExpression(std::vector & tokens, std::map & PICS, - uint8_t & index) -{ - bool leftExpr = EvaluateSubExpression(tokens, PICS, index); - if (index >= tokens.size()) - { - return leftExpr; - } - - if (tokens[index] == ")") - { - return leftExpr; - } - - std::string token = tokens[index]; - if (token == "&&") - { - index++; - bool rightExpr = EvaluateExpression(tokens, PICS, index); - return leftExpr && rightExpr; - } - if (token == "||") - { - index++; - bool rightExpr = EvaluateExpression(tokens, PICS, index); - return leftExpr || rightExpr; - } - - ChipLogError(chipTool, "Unknown token: '%s'", token.c_str()); - chipDie(); -} - -bool PICSBooleanExpressionParser::EvaluateSubExpression(std::vector & tokens, std::map & PICS, - uint8_t & index) -{ - std::string token = tokens[index]; - if (token == "(") - { - index++; - bool expr = EvaluateExpression(tokens, PICS, index); - if (tokens[index] != ")") - { - ChipLogError(chipTool, "Missing ')'"); - chipDie(); - } - - index++; - return expr; - } - if (token == "!") - { - index++; - bool expr = EvaluateSubExpression(tokens, PICS, index); - return !expr; - } - - token = PICSNormalizer::Normalize(token); - - index++; - - if (PICS.find(token) == PICS.end()) - { - // By default, let's consider that if a PICS item is not defined, it is |false|. - // It allows to create a file that only contains enabled features. - return false; - } - - return PICS[token]; -} diff --git a/src/app/tests/suites/pics/PICSBooleanExpressionParser.h b/src/app/tests/suites/pics/PICSBooleanExpressionParser.h deleted file mode 100644 index 162f55df1f1582..00000000000000 --- a/src/app/tests/suites/pics/PICSBooleanExpressionParser.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - * 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. - */ - -/** - * @file - * @brief Declaration of PICS Boolean Expression parser, a class that - * implements PICS condition parsing for YAML tests. - */ - -#include -#include -#include -#include - -class PICSBooleanExpressionParser -{ -public: - /** - * @brief - * This function returns a boolean which is the result of evaluating the - * boolean logic expressed into the PICS expression. - * - * @param [in] expression An expression containing PICS code such as - * "!DT_CTRL_CONCATENATED_QR_CODE_1 && DT_CTRL_CONCATENATED_QR_CODE_2" - * @param [in] PICS A map of enabled/disabled PICS code - * - * @returns A boolean as the result of evaluating the expression. - */ - static bool Eval(std::string expression, std::map & PICS); - -private: - static void Tokenize(std::string & expression, std::vector & tokens); - static bool EvaluateExpression(std::vector & tokens, std::map & PICS, uint8_t & index); - static bool EvaluateSubExpression(std::vector & tokens, std::map & PICS, uint8_t & index); -}; diff --git a/src/app/tests/suites/pics/PICSBooleanReader.cpp b/src/app/tests/suites/pics/PICSBooleanReader.cpp deleted file mode 100644 index 9e84763fbb8288..00000000000000 --- a/src/app/tests/suites/pics/PICSBooleanReader.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/** - * - * 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. - */ - -#include "PICSBooleanReader.h" -#include "PICSNormalizer.h" - -#include - -#include -#include - -std::map PICSBooleanReader::Read(std::string filepath) -{ - std::ifstream f(filepath); - VerifyOrDieWithMsg(f.is_open(), chipTool, "Error reading: %s", filepath.c_str()); - - std::map PICS; - std::string line; - std::string key; - std::string value; - uint16_t lineNumber = 0; - while (std::getline(f, line)) - { - if (line.empty()) - { - continue; - } - - std::stringstream ss(line); - - std::getline(ss, key, '='); - VerifyOrDieWithMsg(!key.empty(), chipTool, "Missing PICS key at line %u", lineNumber + 1); - key = PICSNormalizer::Normalize(key); - - std::getline(ss, value); - if (value == "0") - { - PICS[key] = false; - } - else if (value == "1") - { - PICS[key] = true; - } - else - { - ChipLogError(chipTool, "%s: PICS value should be either '0' or '1', got '%s'", key.c_str(), value.c_str()); - chipDie(); - } - - lineNumber++; - } - - return PICS; -} diff --git a/src/app/tests/suites/pics/PICSBooleanReader.h b/src/app/tests/suites/pics/PICSBooleanReader.h deleted file mode 100644 index 6f8e240c6678f1..00000000000000 --- a/src/app/tests/suites/pics/PICSBooleanReader.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * - * 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. - */ - -/** - * @file - * @brief Declaration of PICS Boolean Reader, a class that read and parse - * a file with PICS Code and their enabled/disabled state. - */ - -#include -#include - -class PICSBooleanReader -{ -public: - static std::map Read(std::string filepath); -}; diff --git a/src/app/tests/suites/pics/PICSNormalizer.cpp b/src/app/tests/suites/pics/PICSNormalizer.cpp deleted file mode 100644 index 0fe5eb5ca2db23..00000000000000 --- a/src/app/tests/suites/pics/PICSNormalizer.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2022 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. - */ - -#include "PICSNormalizer.h" - -#include -#include - -std::string PICSNormalizer::Normalize(std::string code) -{ - // Convert to all-lowercase so people who mess up cases don't have things - // break on them in subtle ways. - std::transform(code.begin(), code.end(), code.begin(), [](unsigned char c) { return std::tolower(c); }); - - // TODO strip off "(Additional Context)" bits from the end of the code. - return code; -} diff --git a/src/app/tests/suites/pics/PICSNormalizer.h b/src/app/tests/suites/pics/PICSNormalizer.h deleted file mode 100644 index 04f5b028973683..00000000000000 --- a/src/app/tests/suites/pics/PICSNormalizer.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2022 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. - */ - -/** - * @file - * @brief Declaration of a method that normalizes a PICS code. - */ - -#include - -class PICSNormalizer -{ -public: - static std::string Normalize(std::string code); -}; diff --git a/src/app/tests/suites/templates/simulated-cluster-objects.zapt b/src/app/tests/suites/templates/simulated-cluster-objects.zapt deleted file mode 100644 index 9c4dadca6385cd..00000000000000 --- a/src/app/tests/suites/templates/simulated-cluster-objects.zapt +++ /dev/null @@ -1,132 +0,0 @@ -{{>header}} - -#include -#include - -#pragma once - -namespace chip { - -{{#chip_tests_only_clusters includeAllClusters=true}} -{{#chip_tests_only_cluster_commands}} - -struct {{name}}Command -{ - {{#chip_tests_only_cluster_command_parameters}} - {{zapTypeToEncodableClusterObjectType type ns=cluster}} {{name}}; - {{/chip_tests_only_cluster_command_parameters}} - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - {{#chip_tests_only_cluster_command_parameters}} - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag({{index}}), {{name}})); - {{/chip_tests_only_cluster_command_parameters}} - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - {{#chip_tests_only_cluster_command_parameters}} - case {{index}}: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, {{name}})); - break; - {{/chip_tests_only_cluster_command_parameters}} - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; -{{/chip_tests_only_cluster_commands}} -{{#chip_tests_only_cluster_responses}} - -struct {{#if responseName}}{{responseName}}{{else}}{{name}}Response{{/if}} -{ - {{#chip_tests_only_cluster_response_parameters}} - {{zapTypeToEncodableClusterObjectType type}} {{name}}; - {{/chip_tests_only_cluster_response_parameters}} - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - {{#chip_tests_only_cluster_response_parameters}} - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag({{index}}), {{name}})); - {{/chip_tests_only_cluster_response_parameters}} - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - {{#chip_tests_only_cluster_response_parameters}} - case {{index}}: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, {{name}})); - break; - {{/chip_tests_only_cluster_response_parameters}} - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; -{{/chip_tests_only_cluster_responses}} -{{/chip_tests_only_clusters}} - -namespace app { -namespace Clusters { -{{#chip_tests_only_clusters}} - -namespace {{name}} { -namespace Commands { -{{#chip_tests_only_cluster_commands}} -namespace {{name}} { -using Type = struct {{name}}Command; -} -{{/chip_tests_only_cluster_commands}} -{{#chip_tests_only_cluster_responses}} -namespace {{#if responseName}}{{responseName}}{{else}}{{name}}Response{{/if}} { -using DecodableType = struct {{#if responseName}}{{responseName}}{{else}}{{name}}Response{{/if}}; -} -{{/chip_tests_only_cluster_responses}} -} // namespace Commands -} // namespace {{name}} - -{{/chip_tests_only_clusters}} -} // namespace Clusters -} // namespace app - -} // namespace chip diff --git a/src/app/tests/suites/templates/templates.json b/src/app/tests/suites/templates/templates.json deleted file mode 100644 index 2a174671c2763b..00000000000000 --- a/src/app/tests/suites/templates/templates.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "CHIP Tests templates", - "version": "chip-v1", - "helpers": [ - "common/StringHelper.js", - "templates/app/helper.js", - "templates/chip/helper.js", - "common/ClusterTestGeneration.js" - ], - "resources": { - "pics-metafile": "../../../tests/suites/certification/PICS.yaml", - "certification-metadir": "../../../tests/suites/certification", - "test-metadir": "../../../tests/suites" - }, - "override": "../../../zap-templates/common/override.js", - "partials": [ - { - "name": "header", - "path": "../../../zap-templates/partials/header.zapt" - } - ], - "templates": [ - { - "path": "simulated-cluster-objects.zapt", - "name": "Simulated Cluster Objects Commands header", - "output": "tests/simulated-cluster-objects.h" - } - ] -} diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index 2abac8376ed097..22c071844795d5 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -22,7 +22,6 @@ 037C3DB72991BD5000B7EEE2 /* ModelCommandBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 037C3D882991BD4F00B7EEE2 /* ModelCommandBridge.h */; }; 037C3DB82991BD5000B7EEE2 /* ClusterCommandBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 037C3D892991BD4F00B7EEE2 /* ClusterCommandBridge.h */; }; 037C3DB92991BD5000B7EEE2 /* ReportCommandBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 037C3D8A2991BD4F00B7EEE2 /* ReportCommandBridge.h */; }; - 037C3DBA2991BD5000B7EEE2 /* TestCommandBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 037C3D8C2991BD4F00B7EEE2 /* TestCommandBridge.h */; }; 037C3DBB2991BD5000B7EEE2 /* Commands.h in Headers */ = {isa = PBXBuildFile; fileRef = 037C3D8E2991BD4F00B7EEE2 /* Commands.h */; }; 037C3DBC2991BD5000B7EEE2 /* OTASoftwareUpdateInteractive.mm in Sources */ = {isa = PBXBuildFile; fileRef = 037C3D8F2991BD4F00B7EEE2 /* OTASoftwareUpdateInteractive.mm */; }; 037C3DBD2991BD5000B7EEE2 /* OTAProviderDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 037C3D902991BD4F00B7EEE2 /* OTAProviderDelegate.h */; }; @@ -68,9 +67,6 @@ 039546A02991DFC5006D42A8 /* json_tool.h in Headers */ = {isa = PBXBuildFile; fileRef = 0395469B2991DFC4006D42A8 /* json_tool.h */; }; 039546A12991DFC5006D42A8 /* json_value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0395469C2991DFC4006D42A8 /* json_value.cpp */; }; 039546A62991E151006D42A8 /* InteractionModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 039546A52991E132006D42A8 /* InteractionModel.cpp */; }; - 039546BC2991E1CB006D42A8 /* LogCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 039546AF2991E193006D42A8 /* LogCommands.cpp */; }; - 039546BD2991E1CB006D42A8 /* SystemCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 039546B32991E194006D42A8 /* SystemCommands.cpp */; }; - 039546BE2991E1CB006D42A8 /* DelayCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 039546AC2991E185006D42A8 /* DelayCommands.cpp */; }; 039547012992D461006D42A8 /* generic-callback-stubs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5143041F2914CED9004DC7FE /* generic-callback-stubs.cpp */; }; 0395470F2992DB37006D42A8 /* complete.c in Sources */ = {isa = PBXBuildFile; fileRef = 0395470C2992DB37006D42A8 /* complete.c */; }; 03F430A7299410C000166449 /* ExamplePersistentStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F430A6299410C000166449 /* ExamplePersistentStorage.cpp */; }; @@ -400,7 +396,6 @@ 037C3D882991BD4F00B7EEE2 /* ModelCommandBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelCommandBridge.h; sourceTree = ""; }; 037C3D892991BD4F00B7EEE2 /* ClusterCommandBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClusterCommandBridge.h; sourceTree = ""; }; 037C3D8A2991BD4F00B7EEE2 /* ReportCommandBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReportCommandBridge.h; sourceTree = ""; }; - 037C3D8C2991BD4F00B7EEE2 /* TestCommandBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCommandBridge.h; sourceTree = ""; }; 037C3D8E2991BD4F00B7EEE2 /* Commands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Commands.h; sourceTree = ""; }; 037C3D8F2991BD4F00B7EEE2 /* OTASoftwareUpdateInteractive.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OTASoftwareUpdateInteractive.mm; sourceTree = ""; }; 037C3D902991BD4F00B7EEE2 /* OTAProviderDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTAProviderDelegate.h; sourceTree = ""; }; @@ -445,15 +440,6 @@ 0395469C2991DFC4006D42A8 /* json_value.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = json_value.cpp; sourceTree = ""; }; 0395469D2991DFC4006D42A8 /* json_valueiterator.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_valueiterator.inl; sourceTree = ""; }; 039546A52991E132006D42A8 /* InteractionModel.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InteractionModel.cpp; sourceTree = ""; }; - 039546AC2991E185006D42A8 /* DelayCommands.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DelayCommands.cpp; sourceTree = ""; }; - 039546AF2991E193006D42A8 /* LogCommands.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LogCommands.cpp; sourceTree = ""; }; - 039546B32991E194006D42A8 /* SystemCommands.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SystemCommands.cpp; sourceTree = ""; }; - 039546B62991E194006D42A8 /* FactoryReset.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = FactoryReset.py; sourceTree = ""; }; - 039546B72991E194006D42A8 /* Stop.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = Stop.py; sourceTree = ""; }; - 039546B82991E194006D42A8 /* Start.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = Start.py; sourceTree = ""; }; - 039546B92991E194006D42A8 /* CreateOtaImage.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = CreateOtaImage.py; sourceTree = ""; }; - 039546BA2991E194006D42A8 /* CompareFiles.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = CompareFiles.py; sourceTree = ""; }; - 039546BB2991E194006D42A8 /* Reboot.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = Reboot.py; sourceTree = ""; }; 0395470B2992DB37006D42A8 /* editline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = editline.c; path = repo/src/editline.c; sourceTree = ""; }; 0395470C2992DB37006D42A8 /* complete.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = complete.c; path = repo/src/complete.c; sourceTree = ""; }; 03F430A6299410C000166449 /* ExamplePersistentStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExamplePersistentStorage.cpp; sourceTree = ""; }; @@ -868,14 +854,6 @@ path = clusters; sourceTree = ""; }; - 037C3D8B2991BD4F00B7EEE2 /* tests */ = { - isa = PBXGroup; - children = ( - 037C3D8C2991BD4F00B7EEE2 /* TestCommandBridge.h */, - ); - path = tests; - sourceTree = ""; - }; 037C3D8D2991BD4F00B7EEE2 /* provider */ = { isa = PBXGroup; children = ( @@ -980,47 +958,6 @@ path = ../../src/app/tests/suites/commands/interaction_model; sourceTree = ""; }; - 039546A72991E185006D42A8 /* delay */ = { - isa = PBXGroup; - children = ( - 039546AC2991E185006D42A8 /* DelayCommands.cpp */, - ); - name = delay; - path = ../../src/app/tests/suites/commands/delay; - sourceTree = ""; - }; - 039546AD2991E193006D42A8 /* log */ = { - isa = PBXGroup; - children = ( - 039546AF2991E193006D42A8 /* LogCommands.cpp */, - ); - name = log; - path = ../../src/app/tests/suites/commands/log; - sourceTree = ""; - }; - 039546B12991E194006D42A8 /* system */ = { - isa = PBXGroup; - children = ( - 039546B32991E194006D42A8 /* SystemCommands.cpp */, - 039546B52991E194006D42A8 /* scripts */, - ); - name = system; - path = ../../src/app/tests/suites/commands/system; - sourceTree = ""; - }; - 039546B52991E194006D42A8 /* scripts */ = { - isa = PBXGroup; - children = ( - 039546B62991E194006D42A8 /* FactoryReset.py */, - 039546B72991E194006D42A8 /* Stop.py */, - 039546B82991E194006D42A8 /* Start.py */, - 039546B92991E194006D42A8 /* CreateOtaImage.py */, - 039546BA2991E194006D42A8 /* CompareFiles.py */, - 039546BB2991E194006D42A8 /* Reboot.py */, - ); - path = scripts; - sourceTree = ""; - }; 039547092992DB02006D42A8 /* editline */ = { isa = PBXGroup; children = ( @@ -1527,7 +1464,6 @@ 037C3DB72991BD5000B7EEE2 /* ModelCommandBridge.h in Headers */, 037C3DC52991BD5100B7EEE2 /* StorageManagementCommand.h in Headers */, 037C3DCC2991BD5100B7EEE2 /* MTRError_Utils.h in Headers */, - 037C3DBA2991BD5000B7EEE2 /* TestCommandBridge.h in Headers */, 037C3DAD2991BD4F00B7EEE2 /* PairingCommandBridge.h in Headers */, 037C3DBB2991BD5000B7EEE2 /* Commands.h in Headers */, 03FB93DF2A46200A0048CB35 /* Commands.h in Headers */, diff --git a/zzz_generated/app-common/app-common/zap-generated/tests/simulated-cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/tests/simulated-cluster-objects.h deleted file mode 100644 index e75d11598b9b0b..00000000000000 --- a/zzz_generated/app-common/app-common/zap-generated/tests/simulated-cluster-objects.h +++ /dev/null @@ -1,1551 +0,0 @@ -/* - * - * Copyright (c) 2022 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. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include - -#pragma once - -namespace chip { - -struct PairWithCodeCommand -{ - chip::NodeId nodeId; - chip::CharSpan payload; - Optional discoverOnce; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), nodeId)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), payload)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(2), discoverOnce)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, nodeId)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, payload)); - break; - case 2: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, discoverOnce)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct UnpairCommand -{ - chip::NodeId nodeId; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), nodeId)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, nodeId)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct GetCommissionerNodeIdCommand -{ - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct GetCommissionerNodeIdResponse -{ - chip::NodeId nodeId; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), nodeId)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, nodeId)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct WaitForMsCommand -{ - uint32_t ms; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), ms)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, ms)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct WaitForCommissioningCommand -{ - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct WaitForCommissioneeCommand -{ - chip::NodeId nodeId; - Optional expireExistingSession; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), nodeId)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), expireExistingSession)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, nodeId)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, expireExistingSession)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct WaitForMessageCommand -{ - Optional registerKey; - chip::CharSpan message; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), registerKey)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), message)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, registerKey)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, message)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionableCommand -{ - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionableByShortDiscriminatorCommand -{ - uint64_t value; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), value)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, value)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionableByLongDiscriminatorCommand -{ - uint64_t value; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), value)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, value)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionableByCommissioningModeCommand -{ - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionableByVendorIdCommand -{ - uint64_t value; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), value)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, value)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionableByDeviceTypeCommand -{ - uint64_t value; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), value)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, value)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionableByNameCommand -{ - chip::CharSpan value; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), value)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, value)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionerCommand -{ - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionerByVendorIdCommand -{ - uint64_t value; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), value)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, value)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FindCommissionerByDeviceTypeCommand -{ - uint64_t value; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), value)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, value)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct DiscoveryCommandResponse -{ - chip::CharSpan hostName; - chip::CharSpan instanceName; - uint16_t longDiscriminator; - uint8_t shortDiscriminator; - uint16_t vendorId; - uint16_t productId; - uint8_t commissioningMode; - uint32_t deviceType; - chip::CharSpan deviceName; - chip::ByteSpan rotatingId; - uint64_t rotatingIdLen; - uint16_t pairingHint; - chip::CharSpan pairingInstruction; - bool supportsTcp; - uint8_t numIPs; - uint16_t port; - Optional mrpRetryIntervalIdle; - Optional mrpRetryIntervalActive; - Optional mrpRetryActiveThreshold; - Optional isICDOperatingAsLIT; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), hostName)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), instanceName)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(2), longDiscriminator)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(3), shortDiscriminator)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(4), vendorId)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(5), productId)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(6), commissioningMode)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(7), deviceType)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(8), deviceName)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(9), rotatingId)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(10), rotatingIdLen)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(11), pairingHint)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(12), pairingInstruction)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(13), supportsTcp)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(14), numIPs)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(15), port)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(16), mrpRetryIntervalIdle)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(17), mrpRetryIntervalActive)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(18), mrpRetryActiveThreshold)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(19), isICDOperatingAsLIT)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, hostName)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, instanceName)); - break; - case 2: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, longDiscriminator)); - break; - case 3: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, shortDiscriminator)); - break; - case 4: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, vendorId)); - break; - case 5: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, productId)); - break; - case 6: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, commissioningMode)); - break; - case 7: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, deviceType)); - break; - case 8: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, deviceName)); - break; - case 9: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, rotatingId)); - break; - case 10: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, rotatingIdLen)); - break; - case 11: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, pairingHint)); - break; - case 12: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, pairingInstruction)); - break; - case 13: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, supportsTcp)); - break; - case 14: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, numIPs)); - break; - case 15: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, port)); - break; - case 16: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, mrpRetryIntervalIdle)); - break; - case 17: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, mrpRetryIntervalActive)); - break; - case 18: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, mrpRetryActiveThreshold)); - break; - case 19: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, isICDOperatingAsLIT)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct BooleanEqualsCommand -{ - bool Value1; - bool Value2; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), Value1)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), Value2)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, Value1)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, Value2)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct SignedNumberEqualsCommand -{ - int64_t Value1; - int64_t Value2; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), Value1)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), Value2)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, Value1)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, Value2)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct UnsignedNumberEqualsCommand -{ - uint64_t Value1; - uint64_t Value2; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), Value1)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), Value2)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, Value1)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, Value2)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct EqualityResponse -{ - bool Equals; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), Equals)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, Equals)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct LogCommand -{ - chip::CharSpan message; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), message)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, message)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct UserPromptCommand -{ - chip::CharSpan message; - Optional expectedValue; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), message)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), expectedValue)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, message)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, expectedValue)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct StartCommand -{ - Optional registerKey; - Optional discriminator; - Optional port; - Optional kvs; - Optional minCommissioningTimeout; - Optional filepath; - Optional otaDownloadPath; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), registerKey)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), discriminator)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(2), port)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(3), kvs)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(4), minCommissioningTimeout)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(5), filepath)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(6), otaDownloadPath)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, registerKey)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, discriminator)); - break; - case 2: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, port)); - break; - case 3: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, kvs)); - break; - case 4: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, minCommissioningTimeout)); - break; - case 5: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, filepath)); - break; - case 6: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, otaDownloadPath)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct StopCommand -{ - Optional registerKey; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), registerKey)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, registerKey)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct RebootCommand -{ - Optional registerKey; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), registerKey)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, registerKey)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct FactoryResetCommand -{ - Optional registerKey; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), registerKey)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, registerKey)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct CreateOtaImageCommand -{ - chip::CharSpan otaImageFilePath; - chip::CharSpan rawImageFilePath; - chip::CharSpan rawImageContent; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), otaImageFilePath)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), rawImageFilePath)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(2), rawImageContent)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, otaImageFilePath)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, rawImageFilePath)); - break; - case 2: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, rawImageContent)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -struct CompareFilesCommand -{ - chip::CharSpan file1; - chip::CharSpan file2; - - CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const - { - chip::TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(0), file1)); - ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::ContextTag(1), file2)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; - } - - CHIP_ERROR Decode(chip::TLV::TLVReader & reader) - { - CHIP_ERROR err = CHIP_NO_ERROR; - chip::TLV::TLVType outer; - VerifyOrReturnError(chip::TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(chip::TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (chip::TLV::TagNumFromTag(reader.GetTag())) - { - case 0: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, file1)); - break; - case 1: - ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, file2)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - - return CHIP_NO_ERROR; - } -}; - -namespace app { -namespace Clusters { - -namespace CommissionerCommands { -namespace Commands { -namespace PairWithCode { -using Type = struct PairWithCodeCommand; -} -namespace Unpair { -using Type = struct UnpairCommand; -} -namespace GetCommissionerNodeId { -using Type = struct GetCommissionerNodeIdCommand; -} -namespace GetCommissionerNodeIdResponse { -using DecodableType = struct GetCommissionerNodeIdResponse; -} -} // namespace Commands -} // namespace CommissionerCommands - -namespace DelayCommands { -namespace Commands { -namespace WaitForMs { -using Type = struct WaitForMsCommand; -} -namespace WaitForCommissioning { -using Type = struct WaitForCommissioningCommand; -} -namespace WaitForCommissionee { -using Type = struct WaitForCommissioneeCommand; -} -namespace WaitForMessage { -using Type = struct WaitForMessageCommand; -} -} // namespace Commands -} // namespace DelayCommands - -namespace DiscoveryCommands { -namespace Commands { -namespace FindCommissionable { -using Type = struct FindCommissionableCommand; -} -namespace FindCommissionableByShortDiscriminator { -using Type = struct FindCommissionableByShortDiscriminatorCommand; -} -namespace FindCommissionableByLongDiscriminator { -using Type = struct FindCommissionableByLongDiscriminatorCommand; -} -namespace FindCommissionableByCommissioningMode { -using Type = struct FindCommissionableByCommissioningModeCommand; -} -namespace FindCommissionableByVendorId { -using Type = struct FindCommissionableByVendorIdCommand; -} -namespace FindCommissionableByDeviceType { -using Type = struct FindCommissionableByDeviceTypeCommand; -} -namespace FindCommissionableByName { -using Type = struct FindCommissionableByNameCommand; -} -namespace FindCommissioner { -using Type = struct FindCommissionerCommand; -} -namespace FindCommissionerByVendorId { -using Type = struct FindCommissionerByVendorIdCommand; -} -namespace FindCommissionerByDeviceType { -using Type = struct FindCommissionerByDeviceTypeCommand; -} -namespace DiscoveryCommandResponse { -using DecodableType = struct DiscoveryCommandResponse; -} -} // namespace Commands -} // namespace DiscoveryCommands - -namespace EqualityCommands { -namespace Commands { -namespace BooleanEquals { -using Type = struct BooleanEqualsCommand; -} -namespace SignedNumberEquals { -using Type = struct SignedNumberEqualsCommand; -} -namespace UnsignedNumberEquals { -using Type = struct UnsignedNumberEqualsCommand; -} -namespace EqualityResponse { -using DecodableType = struct EqualityResponse; -} -} // namespace Commands -} // namespace EqualityCommands - -namespace LogCommands { -namespace Commands { -namespace Log { -using Type = struct LogCommand; -} -namespace UserPrompt { -using Type = struct UserPromptCommand; -} -} // namespace Commands -} // namespace LogCommands - -namespace SystemCommands { -namespace Commands { -namespace Start { -using Type = struct StartCommand; -} -namespace Stop { -using Type = struct StopCommand; -} -namespace Reboot { -using Type = struct RebootCommand; -} -namespace FactoryReset { -using Type = struct FactoryResetCommand; -} -namespace CreateOtaImage { -using Type = struct CreateOtaImageCommand; -} -namespace CompareFiles { -using Type = struct CompareFilesCommand; -} -} // namespace Commands -} // namespace SystemCommands - -} // namespace Clusters -} // namespace app - -} // namespace chip diff --git a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h deleted file mode 100644 index fd7e5da8588d13..00000000000000 --- a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h +++ /dev/null @@ -1,1719 +0,0 @@ -/* - * - * Copyright (c) 2022 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. - */ - -// THIS FILE IS GENERATED BY ZAP - -#pragma once - -#include "TestCommand.h" - -#include - -class Test_TC_WNCV_5_1_SimulatedSuite : public TestCommand -{ -public: - Test_TC_WNCV_5_1_SimulatedSuite() : TestCommand("Test_TC_WNCV_5_1_Simulated", 5) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_WNCV_5_1_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Step 1a: DUT reads the FeatureMap attribute from TH"); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::FeatureMap::Id); - } - case 1: { - LogStep(1, "Step 2a: DUT reads the Type attribute from TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.A0000"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::Type::Id); - } - case 2: { - LogStep(2, "Step 2b: DUT reads the EndProductType attribute from TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.A000d"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::EndProductType::Id); - } - case 3: { - LogStep(3, "Step 3a: DUT reads the Mode attribute from TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.A0017"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::Mode::Id); - } - case 4: { - LogStep(4, "Step 3b: DUT reads the ConfigStatus attribute from TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.A0007"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::ConfigStatus::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OCC_2_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_OCC_2_4_SimulatedSuite() : TestCommand("Test_TC_OCC_2_4_Simulated", 2) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_OCC_2_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "TH reads OccupancySensorType attribute from DUT"); - VerifyOrDo(!ShouldSkip("OCC.C.A0001"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), OccupancySensing::Id, OccupancySensing::Attributes::OccupancySensorType::Id); - } - case 1: { - LogStep(1, "TH reads OccupancySensorTypeBitmap attribute from DUT"); - VerifyOrDo(!ShouldSkip("OCC.C.A0002"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), OccupancySensing::Id, OccupancySensing::Attributes::OccupancySensorTypeBitmap::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGSW_3_2_SimulatedSuite : public TestCommand -{ -public: - Test_TC_DGSW_3_2_SimulatedSuite() : TestCommand("Test_TC_DGSW_3_2_Simulated", 1) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DGSW_3_2_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT sends ResetWatermarks to TH"); - VerifyOrDo(!ShouldSkip("DGSW.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), SoftwareDiagnostics::Id, SoftwareDiagnostics::Commands::ResetWatermarks::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_3_2_SimulatedSuite : public TestCommand -{ -public: - Test_TC_DGETH_3_2_SimulatedSuite() : TestCommand("Test_TC_DGETH_3_2_Simulated", 1) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DGETH_3_2_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT sends ResetCounts to TH"); - VerifyOrDo(!ShouldSkip("DGETH.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), EthernetNetworkDiagnostics::Id, - EthernetNetworkDiagnostics::Commands::ResetCounts::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_3_2_SimulatedSuite : public TestCommand -{ -public: - Test_TC_DGWIFI_3_2_SimulatedSuite() : TestCommand("Test_TC_DGWIFI_3_2_Simulated", 1) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DGWIFI_3_2_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT sends ResetCounts command to TH"); - VerifyOrDo(!ShouldSkip("DGWIFI.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WiFiNetworkDiagnostics::Id, WiFiNetworkDiagnostics::Commands::ResetCounts::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_6_1_SimulatedSuite : public TestCommand -{ -public: - Test_TC_WNCV_6_1_SimulatedSuite() : TestCommand("Test_TC_WNCV_6_1_Simulated", 3) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_WNCV_6_1_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Step 1a: DUT sends UpOrOpen command to TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::UpOrOpen::Id); - } - case 1: { - LogStep(1, "Step 2a: DUT sends DownOrClose command to TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.C01.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::DownOrClose::Id); - } - case 2: { - LogStep(2, "Step 3a: DUT sends StopMotion command to TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.C02.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::StopMotion::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_7_1_SimulatedSuite : public TestCommand -{ -public: - Test_TC_WNCV_7_1_SimulatedSuite() : TestCommand("Test_TC_WNCV_7_1_Simulated", 2) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_WNCV_7_1_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Step 1a: If (PA_LF & LF) DUT sends GoToLiftPercentage command with 50% to DUT"); - VerifyOrDo(!ShouldSkip("WNCV.C.C05.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::GoToLiftPercentage::Id); - } - case 1: { - LogStep(1, "Step 2a: If (PA_TL & TL) DUT sends GoToTiltPercentage command with 50% to DUT"); - VerifyOrDo(!ShouldSkip("WNCV.C.C08.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::GoToTiltPercentage::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_3_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_3_4_SimulatedSuite() : TestCommand("Test_TC_CC_3_4_Simulated", 16) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_3_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends MoveToHue command to TH an Hue with _TransitionTime 300"); - VerifyOrDo(!ShouldSkip("CC.C.C00.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToHue::Id); - } - case 2: { - LogStep(2, "DUT reads CurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C00.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 3: { - LogStep(3, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 4: { - LogStep(4, "DUT reads CurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C00.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 5: { - LogStep(5, "DUT sends MoveHue command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C01.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveHue::Id); - } - case 6: { - LogStep(6, "DUT reads CurrentHue attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C01.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 7: { - LogStep(7, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 8: { - LogStep(8, "DUT reads CurrentHue attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C01.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 9: { - LogStep(9, "DUT sends StepHue command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C02.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StepHue::Id); - } - case 10: { - LogStep(10, "DUT reads CurrentHue attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C02.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 11: { - LogStep(11, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 12: { - LogStep(12, "DUT reads CurrentHue attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C02.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 13: { - LogStep(13, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 14: { - LogStep(14, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 15: { - LogStep(15, "Over TransitionTime, DUT reads CurrentHue attribute from TH"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_5_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_4_5_SimulatedSuite() : TestCommand("Test_TC_CC_4_5_Simulated", 22) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_4_5_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends MoveToSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToSaturation::Id); - } - case 2: { - LogStep(2, "DUT reads CurrentSaturation attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 3: { - LogStep(3, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 4: { - LogStep(4, "DUT reads CurrentSaturation attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 5: { - LogStep(5, "DUT sends MoveSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C04.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveSaturation::Id); - } - case 6: { - LogStep(6, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C04.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 7: { - LogStep(7, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 8: { - LogStep(8, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C04.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 9: { - LogStep(9, "DUT sends StepSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C05.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StepSaturation::Id); - } - case 10: { - LogStep(10, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C05.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 11: { - LogStep(11, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 12: { - LogStep(12, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C05.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 13: { - LogStep(13, "DUT sends MoveToHueAndSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToHueAndSaturation::Id); - } - case 14: { - LogStep(14, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 15: { - LogStep(15, "DUT reads CurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 16: { - LogStep(16, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 17: { - LogStep(17, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 18: { - LogStep(18, "DUT reads CurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 19: { - LogStep(19, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 20: { - LogStep(20, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 21: { - LogStep(21, "Over TransitionTime, DUT reads CurrentSaturation attribute from TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_5_4_SimulatedSuite() : TestCommand("Test_TC_CC_5_4_Simulated", 9) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_5_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mTimeout; - chip::Optional mEndpoint; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends MoveToColor command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C07.Tx && CC.C.F03"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToColor::Id); - } - case 2: { - LogStep(2, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 3: { - LogStep(3, "DUT sends MoveColor command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C08.Tx && CC.C.F03"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveColor::Id); - } - case 4: { - LogStep(4, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 5: { - LogStep(5, "DUT sends StepColor command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C09.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StepColor::Id); - } - case 6: { - LogStep(6, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 7: { - LogStep(7, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 8: { - LogStep(8, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_6_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_6_4_SimulatedSuite() : TestCommand("Test_TC_CC_6_4_Simulated", 18) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_6_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mTimeout; - chip::Optional mEndpoint; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, - "* TH provides a server implementation of Color Control with F04(CT)=true and reasonable values of " - "ColorTempPhysicalMinMireds (e.g. 153 (6500K), ColorTempPhysicalMaxMireds (e.g. 454 (2200K)) DUT read " - "attribute ColorTempPhysicalMinMireds from TH"); - VerifyOrDo(!ShouldSkip("CC.C.A400b && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTempPhysicalMinMireds::Id); - } - case 2: { - LogStep(2, - "* TH provides a server implementation of Color Control with F04(CT)=true and reasonable values of " - "ColorTempPhysicalMinMireds (e.g. 153 (6500K), ColorTempPhysicalMaxMireds (e.g. 454 (2200K)) DUT read " - "attribute ColorTempPhysicalMaxMireds from TH"); - VerifyOrDo(!ShouldSkip("CC.C.A400c && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTempPhysicalMaxMireds::Id); - } - case 3: { - LogStep(3, "DUT sends MoveToColorTemperature command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C0a.Tx && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToColorTemperature::Id); - } - case 4: { - LogStep(4, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C0a.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 5: { - LogStep(5, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 6: { - LogStep(6, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C0a.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 7: { - LogStep(7, "DUT sends MoveColorTemperatureMireds command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C4b.Tx && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveColorTemperature::Id); - } - case 8: { - LogStep(8, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C4b.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 9: { - LogStep(9, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 10: { - LogStep(10, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C4b.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 11: { - LogStep(11, "DUT sends StepColorTemperature command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C4c.Tx && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StepColorTemperature::Id); - } - case 12: { - LogStep(12, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C4c.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 13: { - LogStep(13, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 14: { - LogStep(14, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C4c.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 15: { - LogStep(15, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 16: { - LogStep(16, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 17: { - LogStep(17, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_7_5_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_7_5_SimulatedSuite() : TestCommand("Test_TC_CC_7_5_Simulated", 23) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_7_5_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mTimeout; - chip::Optional mEndpoint; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends MoveToEnhancedHue command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C40.Tx && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::EnhancedMoveToHue::Id); - } - case 2: { - LogStep(2, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C40.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 3: { - LogStep(3, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 4: { - LogStep(4, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C40.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 5: { - LogStep(5, "DUT sends MoveEnhanced Hue command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C41.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::EnhancedMoveHue::Id); - } - case 6: { - LogStep(6, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C41.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 7: { - LogStep(7, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 8: { - LogStep(8, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C41.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 9: { - LogStep(9, "DUT sends StepEnhanced command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C42.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::EnhancedStepHue::Id); - } - case 10: { - LogStep(10, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C42.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 11: { - LogStep(11, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 12: { - LogStep(12, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C42.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 13: { - LogStep(13, "DUT sends EnhancedMoveToHueAndSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::EnhancedMoveToHueAndSaturation::Id); - } - case 14: { - LogStep(14, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 15: { - LogStep(15, "DUT reads CurrentSaturation attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.A0001 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 16: { - LogStep(16, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 17: { - LogStep(17, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 18: { - LogStep(18, "DUT reads CurrentSaturation attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.A0001 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 19: { - LogStep(19, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 20: { - LogStep(20, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 21: { - LogStep(21, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 22: { - LogStep(22, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_9_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_9_4_SimulatedSuite() : TestCommand("Test_TC_CC_9_4_Simulated", 19) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - - ~Test_TC_CC_9_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mTimeout; - chip::Optional mCluster; - chip::Optional mEndpoint; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends ColorLoopSet command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C44.Tx && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::ColorLoopSet::Id); - } - case 2: { - LogStep(2, "DUT reads ColorLoopActive attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4002 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorLoopActive::Id); - } - case 3: { - LogStep(3, "DUT reads ColorLoopDirection attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4003 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorLoopDirection::Id); - } - case 4: { - LogStep(4, "DUT reads ColorLoopTime attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4004 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorLoopTime::Id); - } - case 5: { - LogStep(5, "DUT reads ColorLoopStartEnhancedHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4005 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorLoopStartEnhancedHue::Id); - } - case 6: { - LogStep(6, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 7: { - LogStep(7, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 8: { - LogStep(8, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 9: { - LogStep(9, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 10: { - LogStep(10, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 11: { - LogStep(11, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 12: { - LogStep(12, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 13: { - LogStep(13, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 14: { - LogStep(14, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 15: { - LogStep(15, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 16: { - LogStep(16, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 17: { - LogStep(17, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 18: { - LogStep(18, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGTHREAD_3_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_DGTHREAD_3_4_SimulatedSuite() : TestCommand("Test_TC_DGTHREAD_3_4_Simulated", 2) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DGTHREAD_3_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT sends ResetCounts command to TH"); - VerifyOrDo(!ShouldSkip("DGTHREAD.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), ThreadNetworkDiagnostics::Id, ThreadNetworkDiagnostics::Commands::ResetCounts::Id); - } - case 1: { - LogStep(1, "DUT reads OverrunCount attribute value from TH"); - VerifyOrDo(!ShouldSkip("DGTHREAD.C.A0006"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), ThreadNetworkDiagnostics::Id, - ThreadNetworkDiagnostics::Attributes::OverrunCount::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_3_2_SimulatedSuite : public TestCommand -{ -public: - Test_TC_OO_3_2_SimulatedSuite() : TestCommand("Test_TC_OO_3_2_Simulated", 6) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_OO_3_2_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT issues an Off command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::Off::Id); - } - case 1: { - LogStep(1, "DUT issues an On command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C01.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 2: { - LogStep(2, "DUT issues an Toggle command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C02.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::Toggle::Id); - } - case 3: { - LogStep(3, "DUT issues an OffWithEffect command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C40.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::OffWithEffect::Id); - } - case 4: { - LogStep(4, "DUT issues an OnWithRecallGlobalScene command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C41.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::OnWithRecallGlobalScene::Id); - } - case 5: { - LogStep(5, "DUT issues an OnWithTimedOff command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C42.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::OnWithTimedOff::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -std::unique_ptr GetTestCommand(std::string testName) -{ - if (testName == "Test_TC_WNCV_5_1_Simulated") - { - return std::unique_ptr(new Test_TC_WNCV_5_1_SimulatedSuite()); - } - if (testName == "Test_TC_OCC_2_4_Simulated") - { - return std::unique_ptr(new Test_TC_OCC_2_4_SimulatedSuite()); - } - if (testName == "Test_TC_DGSW_3_2_Simulated") - { - return std::unique_ptr(new Test_TC_DGSW_3_2_SimulatedSuite()); - } - if (testName == "Test_TC_DGETH_3_2_Simulated") - { - return std::unique_ptr(new Test_TC_DGETH_3_2_SimulatedSuite()); - } - if (testName == "Test_TC_DGWIFI_3_2_Simulated") - { - return std::unique_ptr(new Test_TC_DGWIFI_3_2_SimulatedSuite()); - } - if (testName == "Test_TC_WNCV_6_1_Simulated") - { - return std::unique_ptr(new Test_TC_WNCV_6_1_SimulatedSuite()); - } - if (testName == "Test_TC_WNCV_7_1_Simulated") - { - return std::unique_ptr(new Test_TC_WNCV_7_1_SimulatedSuite()); - } - if (testName == "Test_TC_CC_3_4_Simulated") - { - return std::unique_ptr(new Test_TC_CC_3_4_SimulatedSuite()); - } - if (testName == "Test_TC_CC_4_5_Simulated") - { - return std::unique_ptr(new Test_TC_CC_4_5_SimulatedSuite()); - } - if (testName == "Test_TC_CC_5_4_Simulated") - { - return std::unique_ptr(new Test_TC_CC_5_4_SimulatedSuite()); - } - if (testName == "Test_TC_CC_6_4_Simulated") - { - return std::unique_ptr(new Test_TC_CC_6_4_SimulatedSuite()); - } - if (testName == "Test_TC_CC_7_5_Simulated") - { - return std::unique_ptr(new Test_TC_CC_7_5_SimulatedSuite()); - } - if (testName == "Test_TC_CC_9_4_Simulated") - { - return std::unique_ptr(new Test_TC_CC_9_4_SimulatedSuite()); - } - if (testName == "Test_TC_DGTHREAD_3_4_Simulated") - { - return std::unique_ptr(new Test_TC_DGTHREAD_3_4_SimulatedSuite()); - } - if (testName == "Test_TC_OO_3_2_Simulated") - { - return std::unique_ptr(new Test_TC_OO_3_2_SimulatedSuite()); - } - - return nullptr; -} - -void PrintTestCommands() -{ - ChipLogError(chipTool, "Supported commands:"); - ChipLogError(chipTool, "\t* Test_TC_WNCV_5_1_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_OCC_2_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_DGSW_3_2_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_DGETH_3_2_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_DGWIFI_3_2_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_WNCV_6_1_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_WNCV_7_1_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_3_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_4_5_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_5_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_6_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_7_5_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_9_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_DGTHREAD_3_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_OO_3_2_Simulated"); -} diff --git a/zzz_generated/placeholder/app2/zap-generated/test/Commands.h b/zzz_generated/placeholder/app2/zap-generated/test/Commands.h deleted file mode 100644 index fd7e5da8588d13..00000000000000 --- a/zzz_generated/placeholder/app2/zap-generated/test/Commands.h +++ /dev/null @@ -1,1719 +0,0 @@ -/* - * - * Copyright (c) 2022 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. - */ - -// THIS FILE IS GENERATED BY ZAP - -#pragma once - -#include "TestCommand.h" - -#include - -class Test_TC_WNCV_5_1_SimulatedSuite : public TestCommand -{ -public: - Test_TC_WNCV_5_1_SimulatedSuite() : TestCommand("Test_TC_WNCV_5_1_Simulated", 5) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_WNCV_5_1_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Step 1a: DUT reads the FeatureMap attribute from TH"); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::FeatureMap::Id); - } - case 1: { - LogStep(1, "Step 2a: DUT reads the Type attribute from TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.A0000"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::Type::Id); - } - case 2: { - LogStep(2, "Step 2b: DUT reads the EndProductType attribute from TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.A000d"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::EndProductType::Id); - } - case 3: { - LogStep(3, "Step 3a: DUT reads the Mode attribute from TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.A0017"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::Mode::Id); - } - case 4: { - LogStep(4, "Step 3b: DUT reads the ConfigStatus attribute from TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.A0007"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), WindowCovering::Id, WindowCovering::Attributes::ConfigStatus::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OCC_2_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_OCC_2_4_SimulatedSuite() : TestCommand("Test_TC_OCC_2_4_Simulated", 2) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_OCC_2_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "TH reads OccupancySensorType attribute from DUT"); - VerifyOrDo(!ShouldSkip("OCC.C.A0001"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), OccupancySensing::Id, OccupancySensing::Attributes::OccupancySensorType::Id); - } - case 1: { - LogStep(1, "TH reads OccupancySensorTypeBitmap attribute from DUT"); - VerifyOrDo(!ShouldSkip("OCC.C.A0002"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), OccupancySensing::Id, OccupancySensing::Attributes::OccupancySensorTypeBitmap::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGSW_3_2_SimulatedSuite : public TestCommand -{ -public: - Test_TC_DGSW_3_2_SimulatedSuite() : TestCommand("Test_TC_DGSW_3_2_Simulated", 1) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DGSW_3_2_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT sends ResetWatermarks to TH"); - VerifyOrDo(!ShouldSkip("DGSW.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), SoftwareDiagnostics::Id, SoftwareDiagnostics::Commands::ResetWatermarks::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_3_2_SimulatedSuite : public TestCommand -{ -public: - Test_TC_DGETH_3_2_SimulatedSuite() : TestCommand("Test_TC_DGETH_3_2_Simulated", 1) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DGETH_3_2_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT sends ResetCounts to TH"); - VerifyOrDo(!ShouldSkip("DGETH.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), EthernetNetworkDiagnostics::Id, - EthernetNetworkDiagnostics::Commands::ResetCounts::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_3_2_SimulatedSuite : public TestCommand -{ -public: - Test_TC_DGWIFI_3_2_SimulatedSuite() : TestCommand("Test_TC_DGWIFI_3_2_Simulated", 1) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DGWIFI_3_2_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT sends ResetCounts command to TH"); - VerifyOrDo(!ShouldSkip("DGWIFI.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WiFiNetworkDiagnostics::Id, WiFiNetworkDiagnostics::Commands::ResetCounts::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_6_1_SimulatedSuite : public TestCommand -{ -public: - Test_TC_WNCV_6_1_SimulatedSuite() : TestCommand("Test_TC_WNCV_6_1_Simulated", 3) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_WNCV_6_1_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Step 1a: DUT sends UpOrOpen command to TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::UpOrOpen::Id); - } - case 1: { - LogStep(1, "Step 2a: DUT sends DownOrClose command to TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.C01.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::DownOrClose::Id); - } - case 2: { - LogStep(2, "Step 3a: DUT sends StopMotion command to TH"); - VerifyOrDo(!ShouldSkip("WNCV.C.C02.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::StopMotion::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_7_1_SimulatedSuite : public TestCommand -{ -public: - Test_TC_WNCV_7_1_SimulatedSuite() : TestCommand("Test_TC_WNCV_7_1_Simulated", 2) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_WNCV_7_1_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Step 1a: If (PA_LF & LF) DUT sends GoToLiftPercentage command with 50% to DUT"); - VerifyOrDo(!ShouldSkip("WNCV.C.C05.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::GoToLiftPercentage::Id); - } - case 1: { - LogStep(1, "Step 2a: If (PA_TL & TL) DUT sends GoToTiltPercentage command with 50% to DUT"); - VerifyOrDo(!ShouldSkip("WNCV.C.C08.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), WindowCovering::Id, WindowCovering::Commands::GoToTiltPercentage::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_3_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_3_4_SimulatedSuite() : TestCommand("Test_TC_CC_3_4_Simulated", 16) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_3_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends MoveToHue command to TH an Hue with _TransitionTime 300"); - VerifyOrDo(!ShouldSkip("CC.C.C00.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToHue::Id); - } - case 2: { - LogStep(2, "DUT reads CurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C00.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 3: { - LogStep(3, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 4: { - LogStep(4, "DUT reads CurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C00.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 5: { - LogStep(5, "DUT sends MoveHue command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C01.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveHue::Id); - } - case 6: { - LogStep(6, "DUT reads CurrentHue attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C01.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 7: { - LogStep(7, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 8: { - LogStep(8, "DUT reads CurrentHue attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C01.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 9: { - LogStep(9, "DUT sends StepHue command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C02.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StepHue::Id); - } - case 10: { - LogStep(10, "DUT reads CurrentHue attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C02.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 11: { - LogStep(11, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 12: { - LogStep(12, "DUT reads CurrentHue attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C02.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 13: { - LogStep(13, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 14: { - LogStep(14, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 15: { - LogStep(15, "Over TransitionTime, DUT reads CurrentHue attribute from TH"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_5_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_4_5_SimulatedSuite() : TestCommand("Test_TC_CC_4_5_Simulated", 22) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_4_5_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends MoveToSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToSaturation::Id); - } - case 2: { - LogStep(2, "DUT reads CurrentSaturation attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 3: { - LogStep(3, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 4: { - LogStep(4, "DUT reads CurrentSaturation attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C03.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 5: { - LogStep(5, "DUT sends MoveSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C04.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveSaturation::Id); - } - case 6: { - LogStep(6, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C04.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 7: { - LogStep(7, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 8: { - LogStep(8, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C04.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 9: { - LogStep(9, "DUT sends StepSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C05.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StepSaturation::Id); - } - case 10: { - LogStep(10, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C05.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 11: { - LogStep(11, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 12: { - LogStep(12, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C05.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 13: { - LogStep(13, "DUT sends MoveToHueAndSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToHueAndSaturation::Id); - } - case 14: { - LogStep(14, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 15: { - LogStep(15, "DUT reads CurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 16: { - LogStep(16, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 17: { - LogStep(17, "DUT reads CurrentSaturation attribute from TH several times."); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 18: { - LogStep(18, "DUT reads CurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.C06.Tx && CC.C.A0000 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); - } - case 19: { - LogStep(19, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 20: { - LogStep(20, "Wait for ConfigTransitionTime"); - VerifyOrDo(!ShouldSkip("CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 21: { - LogStep(21, "Over TransitionTime, DUT reads CurrentSaturation attribute from TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.A0001 && CC.C.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_5_4_SimulatedSuite() : TestCommand("Test_TC_CC_5_4_Simulated", 9) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_5_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mTimeout; - chip::Optional mEndpoint; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends MoveToColor command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C07.Tx && CC.C.F03"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToColor::Id); - } - case 2: { - LogStep(2, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 3: { - LogStep(3, "DUT sends MoveColor command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C08.Tx && CC.C.F03"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveColor::Id); - } - case 4: { - LogStep(4, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 5: { - LogStep(5, "DUT sends StepColor command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C09.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StepColor::Id); - } - case 6: { - LogStep(6, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 7: { - LogStep(7, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 8: { - LogStep(8, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_6_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_6_4_SimulatedSuite() : TestCommand("Test_TC_CC_6_4_Simulated", 18) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_6_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mTimeout; - chip::Optional mEndpoint; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, - "* TH provides a server implementation of Color Control with F04(CT)=true and reasonable values of " - "ColorTempPhysicalMinMireds (e.g. 153 (6500K), ColorTempPhysicalMaxMireds (e.g. 454 (2200K)) DUT read " - "attribute ColorTempPhysicalMinMireds from TH"); - VerifyOrDo(!ShouldSkip("CC.C.A400b && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTempPhysicalMinMireds::Id); - } - case 2: { - LogStep(2, - "* TH provides a server implementation of Color Control with F04(CT)=true and reasonable values of " - "ColorTempPhysicalMinMireds (e.g. 153 (6500K), ColorTempPhysicalMaxMireds (e.g. 454 (2200K)) DUT read " - "attribute ColorTempPhysicalMaxMireds from TH"); - VerifyOrDo(!ShouldSkip("CC.C.A400c && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTempPhysicalMaxMireds::Id); - } - case 3: { - LogStep(3, "DUT sends MoveToColorTemperature command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C0a.Tx && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveToColorTemperature::Id); - } - case 4: { - LogStep(4, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C0a.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 5: { - LogStep(5, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 6: { - LogStep(6, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C0a.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 7: { - LogStep(7, "DUT sends MoveColorTemperatureMireds command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C4b.Tx && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::MoveColorTemperature::Id); - } - case 8: { - LogStep(8, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C4b.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 9: { - LogStep(9, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 10: { - LogStep(10, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C4b.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 11: { - LogStep(11, "DUT sends StepColorTemperature command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C4c.Tx && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StepColorTemperature::Id); - } - case 12: { - LogStep(12, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C4c.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 13: { - LogStep(13, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 14: { - LogStep(14, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C4c.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - case 15: { - LogStep(15, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 16: { - LogStep(16, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 17: { - LogStep(17, "DUT reads CurrentColorTemperatureMireds attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.A0007 && CC.C.F04"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_7_5_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_7_5_SimulatedSuite() : TestCommand("Test_TC_CC_7_5_Simulated", 23) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigTransitionTime", 0, UINT16_MAX, &mConfigTransitionTime); - } - - ~Test_TC_CC_7_5_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mTimeout; - chip::Optional mEndpoint; - chip::Optional mConfigTransitionTime; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends MoveToEnhancedHue command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C40.Tx && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::EnhancedMoveToHue::Id); - } - case 2: { - LogStep(2, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C40.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 3: { - LogStep(3, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 4: { - LogStep(4, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C40.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 5: { - LogStep(5, "DUT sends MoveEnhanced Hue command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C41.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::EnhancedMoveHue::Id); - } - case 6: { - LogStep(6, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C41.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 7: { - LogStep(7, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 8: { - LogStep(8, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C41.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 9: { - LogStep(9, "DUT sends StepEnhanced command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C42.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::EnhancedStepHue::Id); - } - case 10: { - LogStep(10, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C42.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 11: { - LogStep(11, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 12: { - LogStep(12, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C42.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 13: { - LogStep(13, "DUT sends EnhancedMoveToHueAndSaturation command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::EnhancedMoveToHueAndSaturation::Id); - } - case 14: { - LogStep(14, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 15: { - LogStep(15, "DUT reads CurrentSaturation attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.A0001 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 16: { - LogStep(16, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 17: { - LogStep(17, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 18: { - LogStep(18, "DUT reads CurrentSaturation attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C43.Tx && CC.C.A0001 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); - } - case 19: { - LogStep(19, "DUT sends StopMoveStep command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::StopMoveStep::Id); - } - case 20: { - LogStep(20, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 21: { - LogStep(21, "Wait for ConfigTransitionTime"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigTransitionTime.HasValue() ? mConfigTransitionTime.Value() : 3000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 22: { - LogStep(22, "DUT reads EnhancedCurrentHue attribute from TH (potentially multiple times)"); - VerifyOrDo(!ShouldSkip("CC.C.C47.Tx && CC.C.A4000 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_9_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_CC_9_4_SimulatedSuite() : TestCommand("Test_TC_CC_9_4_Simulated", 19) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - - ~Test_TC_CC_9_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mTimeout; - chip::Optional mCluster; - chip::Optional mEndpoint; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "PreCondition: Set TH OnOff to On"); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 1: { - LogStep(1, "DUT sends ColorLoopSet command to TH"); - VerifyOrDo(!ShouldSkip("CC.C.C44.Tx && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), ColorControl::Id, ColorControl::Commands::ColorLoopSet::Id); - } - case 2: { - LogStep(2, "DUT reads ColorLoopActive attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4002 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorLoopActive::Id); - } - case 3: { - LogStep(3, "DUT reads ColorLoopDirection attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4003 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorLoopDirection::Id); - } - case 4: { - LogStep(4, "DUT reads ColorLoopTime attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4004 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorLoopTime::Id); - } - case 5: { - LogStep(5, "DUT reads ColorLoopStartEnhancedHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4005 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::ColorLoopStartEnhancedHue::Id); - } - case 6: { - LogStep(6, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 7: { - LogStep(7, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 8: { - LogStep(8, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 9: { - LogStep(9, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 10: { - LogStep(10, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 11: { - LogStep(11, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 12: { - LogStep(12, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 13: { - LogStep(13, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 14: { - LogStep(14, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 15: { - LogStep(15, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 16: { - LogStep(16, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - case 17: { - LogStep(17, "Wait 5000ms"); - VerifyOrDo(!ShouldSkip("CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 18: { - LogStep(18, "DUT reads EnhancedCurrentHue attribute from TH periodically"); - VerifyOrDo(!ShouldSkip("CC.C.A4000 && CC.C.F02 && CC.C.F01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(1), ColorControl::Id, ColorControl::Attributes::EnhancedCurrentHue::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGTHREAD_3_4_SimulatedSuite : public TestCommand -{ -public: - Test_TC_DGTHREAD_3_4_SimulatedSuite() : TestCommand("Test_TC_DGTHREAD_3_4_Simulated", 2) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DGTHREAD_3_4_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT sends ResetCounts command to TH"); - VerifyOrDo(!ShouldSkip("DGTHREAD.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(0), ThreadNetworkDiagnostics::Id, ThreadNetworkDiagnostics::Commands::ResetCounts::Id); - } - case 1: { - LogStep(1, "DUT reads OverrunCount attribute value from TH"); - VerifyOrDo(!ShouldSkip("DGTHREAD.C.A0006"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitAttribute(GetEndpoint(0), ThreadNetworkDiagnostics::Id, - ThreadNetworkDiagnostics::Attributes::OverrunCount::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_3_2_SimulatedSuite : public TestCommand -{ -public: - Test_TC_OO_3_2_SimulatedSuite() : TestCommand("Test_TC_OO_3_2_Simulated", 6) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_OO_3_2_SimulatedSuite() {} - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "DUT issues an Off command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C00.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::Off::Id); - } - case 1: { - LogStep(1, "DUT issues an On command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C01.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::On::Id); - } - case 2: { - LogStep(2, "DUT issues an Toggle command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C02.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::Toggle::Id); - } - case 3: { - LogStep(3, "DUT issues an OffWithEffect command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C40.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::OffWithEffect::Id); - } - case 4: { - LogStep(4, "DUT issues an OnWithRecallGlobalScene command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C41.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::OnWithRecallGlobalScene::Id); - } - case 5: { - LogStep(5, "DUT issues an OnWithTimedOff command to the TH"); - VerifyOrDo(!ShouldSkip("OO.C.C42.Tx"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return WaitCommand(GetEndpoint(1), OnOff::Id, OnOff::Commands::OnWithTimedOff::Id); - } - } - return CHIP_NO_ERROR; - } -}; - -std::unique_ptr GetTestCommand(std::string testName) -{ - if (testName == "Test_TC_WNCV_5_1_Simulated") - { - return std::unique_ptr(new Test_TC_WNCV_5_1_SimulatedSuite()); - } - if (testName == "Test_TC_OCC_2_4_Simulated") - { - return std::unique_ptr(new Test_TC_OCC_2_4_SimulatedSuite()); - } - if (testName == "Test_TC_DGSW_3_2_Simulated") - { - return std::unique_ptr(new Test_TC_DGSW_3_2_SimulatedSuite()); - } - if (testName == "Test_TC_DGETH_3_2_Simulated") - { - return std::unique_ptr(new Test_TC_DGETH_3_2_SimulatedSuite()); - } - if (testName == "Test_TC_DGWIFI_3_2_Simulated") - { - return std::unique_ptr(new Test_TC_DGWIFI_3_2_SimulatedSuite()); - } - if (testName == "Test_TC_WNCV_6_1_Simulated") - { - return std::unique_ptr(new Test_TC_WNCV_6_1_SimulatedSuite()); - } - if (testName == "Test_TC_WNCV_7_1_Simulated") - { - return std::unique_ptr(new Test_TC_WNCV_7_1_SimulatedSuite()); - } - if (testName == "Test_TC_CC_3_4_Simulated") - { - return std::unique_ptr(new Test_TC_CC_3_4_SimulatedSuite()); - } - if (testName == "Test_TC_CC_4_5_Simulated") - { - return std::unique_ptr(new Test_TC_CC_4_5_SimulatedSuite()); - } - if (testName == "Test_TC_CC_5_4_Simulated") - { - return std::unique_ptr(new Test_TC_CC_5_4_SimulatedSuite()); - } - if (testName == "Test_TC_CC_6_4_Simulated") - { - return std::unique_ptr(new Test_TC_CC_6_4_SimulatedSuite()); - } - if (testName == "Test_TC_CC_7_5_Simulated") - { - return std::unique_ptr(new Test_TC_CC_7_5_SimulatedSuite()); - } - if (testName == "Test_TC_CC_9_4_Simulated") - { - return std::unique_ptr(new Test_TC_CC_9_4_SimulatedSuite()); - } - if (testName == "Test_TC_DGTHREAD_3_4_Simulated") - { - return std::unique_ptr(new Test_TC_DGTHREAD_3_4_SimulatedSuite()); - } - if (testName == "Test_TC_OO_3_2_Simulated") - { - return std::unique_ptr(new Test_TC_OO_3_2_SimulatedSuite()); - } - - return nullptr; -} - -void PrintTestCommands() -{ - ChipLogError(chipTool, "Supported commands:"); - ChipLogError(chipTool, "\t* Test_TC_WNCV_5_1_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_OCC_2_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_DGSW_3_2_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_DGETH_3_2_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_DGWIFI_3_2_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_WNCV_6_1_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_WNCV_7_1_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_3_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_4_5_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_5_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_6_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_7_5_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_CC_9_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_DGTHREAD_3_4_Simulated"); - ChipLogError(chipTool, "\t* Test_TC_OO_3_2_Simulated"); -}