From 983fedfcbc38909d73b80f8b5c1d2d8ac163d0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=A9gevand?= <77852424+jmeg-sfy@users.noreply.github.com> Date: Wed, 9 Feb 2022 15:32:14 +0100 Subject: [PATCH] WindowCovering: Add operational-status + YAML tests (#14606) * YAML: Update WindowCovering tests 3.1 3.2 to latest test plan * DEV: Expose and Use HasFeaturePas * DEV: Add mOperationalStatus var to class WindowApp * DEV: Add fake motion simulator for CI * DEV: add to All-cluster-app the missing callback * ZAP: Add missing diff from regen * YAML: Tests - Add Feature conditional PICS to WNCV 3.1 3.2 * CFG: ZAP all-cluster-app allows LF + PA_LF and TL + PA_TL by default * TEST: YAML update value and report * DEV: Add PostEvent for Attributes Changes * DEV: WindowAppImpl Add DispatchEventAttributeChange function * DEV: Remove StopMotion - prefer single method of goto current position * DEV: Rewrite position movement using attributes * DEV: Window-covering-server cleanup * DEV: Remove Todos we use PICS to enable/disable tests * TEST: YAML update WNCV 3.3 StopMotion * Test: YAML WNCV 3.3 disable steps relying on saveAS - add a todo on issue #14502 * TEST: Declare YAML test accordingly w/ Test Plan * TEST: YAML WNCV 3.2 fix target * TEST: YAML adjust timing * DEV: remove unused option from ConvertValue * DEV: Up or Down are inverted compare to the spec * CFG: Zap Window-app update feature-map * Restyled by whitespace * Restyled by clang-format * Restyled by prettier-yaml * DEV: Use generated callback rather than declaring one * DEV: Remove Post attribute declaration * Restyled by whitespace * Restyled by clang-format * YAML: Update attributes check * Rebase/Regen * Restyled by whitespace * TEST: YAML enable test on WNCV 3.3 - issue #14502 fixes by PR# 14602 * DEV: REbase / regen Co-authored-by: Restyled.io --- .../all-clusters-common/all-clusters-app.zap | 2 +- .../window-app/common/include/WindowApp.h | 50 +- examples/window-app/common/src/WindowApp.cpp | 208 +- .../window-app/common/src/ZclCallbacks.cpp | 75 +- examples/window-app/common/window-app.zap | 4 +- .../window-app/efr32/include/WindowAppImpl.h | 2 + .../window-app/efr32/src/WindowAppImpl.cpp | 41 +- .../window-covering-server.cpp | 185 +- .../window-covering-server.h | 2 + src/app/tests/suites/certification/PICS.yaml | 30 +- .../certification/Test_TC_WNCV_3_1.yaml | 243 +- .../certification/Test_TC_WNCV_3_2.yaml | 243 +- .../certification/Test_TC_WNCV_3_3.yaml | 143 +- src/app/tests/suites/certification/tests.yaml | 26 +- src/app/zap-templates/templates/app/helper.js | 9 +- .../Framework/CHIPTests/CHIPClustersTests.m | 1445 +++++++++- .../zap-generated/endpoint_config.h | 11 +- .../chip-tool/zap-generated/test/Commands.h | 2370 +++++++++++++++-- .../zap-generated/endpoint_config.h | 7 +- .../zap-generated/endpoint_config.h | 19 +- 20 files changed, 4506 insertions(+), 609 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index b7d934aab2759d..3f535ce0a8c78e 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -11921,7 +11921,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "0x17", "reportable": 1, "minInterval": 0, "maxInterval": 65344, diff --git a/examples/window-app/common/include/WindowApp.h b/examples/window-app/common/include/WindowApp.h index f5dc1f582ba35a..b51aef9fdd7846 100644 --- a/examples/window-app/common/include/WindowApp.h +++ b/examples/window-app/common/include/WindowApp.h @@ -17,10 +17,11 @@ #pragma once -#include -#include +#include #include +using namespace chip::app::Clusters::WindowCovering; + class WindowApp { public: @@ -76,13 +77,10 @@ class WindowApp CoverChange, CoverTypeChange, TiltModeChange, - LiftUp, - LiftDown, - LiftChanged, - TiltUp, - TiltDown, - TiltChanged, - StopMotion, + + // Cover Attribute update events + AttributeChange, + // Provisioning events ProvisionedStateChanged, ConnectivityStateChanged, @@ -95,32 +93,48 @@ class WindowApp { Event(EventId id) : mId(id), mEndpoint(0) {} Event(EventId id, chip::EndpointId endpoint) : mId(id), mEndpoint(endpoint) {} + Event(EventId id, chip::EndpointId endpoint, chip::AttributeId attributeId) : + mId(id), mEndpoint(endpoint), mAttributeId(attributeId) + {} EventId mId; chip::EndpointId mEndpoint; + chip::AttributeId mAttributeId; }; struct Cover { void Init(chip::EndpointId endpoint); void Finish(); + + void LiftUpdate(bool newTarget); + void LiftGoToTarget() { LiftUpdate(true); } + void LiftContinueToTarget() { LiftUpdate(false); } void LiftUp(); void LiftDown(); - void GotoLift(EventId action = EventId::None); + + void TiltUpdate(bool newTarget); + void TiltGoToTarget() { TiltUpdate(true); } + void TiltContinueToTarget() { TiltUpdate(false); } void TiltUp(); void TiltDown(); - void GotoTilt(EventId action = EventId::None); - void StopMotion(); + EmberAfWcType CycleType(); static void OnLiftTimeout(Timer & timer); static void OnTiltTimeout(Timer & timer); chip::EndpointId mEndpoint = 0; - Timer * mLiftTimer = nullptr; - Timer * mTiltTimer = nullptr; - EventId mLiftAction = EventId::None; - EventId mTiltAction = EventId::None; + + // Attribute: Id 10 OperationalStatus + OperationalStatus mOperationalStatus = { .global = OperationalState::Stall, + .lift = OperationalState::Stall, + .tilt = OperationalState::Stall }; + + Timer * mLiftTimer = nullptr; + Timer * mTiltTimer = nullptr; + OperationalState mLiftOpState = OperationalState::Stall; + OperationalState mTiltOpState = OperationalState::Stall; }; static WindowApp & Instance(); @@ -130,7 +144,8 @@ class WindowApp virtual CHIP_ERROR Start() = 0; virtual CHIP_ERROR Run(); virtual void Finish(); - virtual void PostEvent(const Event & event) = 0; + virtual void PostEvent(const Event & event) = 0; + virtual void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId) = 0; protected: struct StateFlags @@ -172,6 +187,7 @@ class WindowApp private: void HandleLongPress(); + void DispatchEventAttributeChange(chip::EndpointId endpoint, chip::AttributeId attribute); Cover mCoverList[WINDOW_COVER_COUNT]; uint8_t mCurrentCover = 0; diff --git a/examples/window-app/common/src/WindowApp.cpp b/examples/window-app/common/src/WindowApp.cpp index d69e128257e9f2..f00b01379da8e4 100644 --- a/examples/window-app/common/src/WindowApp.cpp +++ b/examples/window-app/common/src/WindowApp.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -201,8 +200,6 @@ void WindowApp::Finish() void WindowApp::DispatchEvent(const WindowApp::Event & event) { - Cover * cover = nullptr; - switch (event.mId) { case EventId::ResetWarning: @@ -296,33 +293,54 @@ void WindowApp::DispatchEvent(const WindowApp::Event & event) GetCover().LiftDown(); } break; - - case EventId::LiftUp: - case EventId::LiftDown: - cover = GetCover(event.mEndpoint); - if (cover) - { - cover->GotoLift(event.mId); - } + case EventId::AttributeChange: + DispatchEventAttributeChange(event.mEndpoint, event.mAttributeId); break; - - case EventId::TiltUp: - case EventId::TiltDown: - cover = GetCover(event.mEndpoint); - if (cover) - { - cover->GotoTilt(event.mId); - } + default: break; + } +} - case EventId::StopMotion: - cover = GetCover(event.mEndpoint); - if (cover) - { - cover->StopMotion(); - } - break; +void WindowApp::DispatchEventAttributeChange(chip::EndpointId endpoint, chip::AttributeId attribute) +{ + Cover * cover = GetCover(endpoint); + + if (nullptr == cover) + { + emberAfWindowCoveringClusterPrint("Ep[%u] not supported AttributeId=%u\n", endpoint, (unsigned int) attribute); + return; + } + switch (attribute) + { + /* For a device supporting Position Awareness : Changing the Target triggers motions on the real or simulated device */ + case Attributes::TargetPositionLiftPercent100ths::Id: + cover->LiftGoToTarget(); + break; + /* For a device supporting Position Awareness : Changing the Target triggers motions on the real or simulated device */ + case Attributes::TargetPositionTiltPercent100ths::Id: + cover->TiltGoToTarget(); + break; + /* RO OperationalStatus */ + case Attributes::OperationalStatus::Id: + emberAfWindowCoveringClusterPrint("Global OpState: %02X\n", (unsigned int) OperationalStatusGet(endpoint).global); + break; + /* RW Mode */ + case Attributes::Mode::Id: + emberAfWindowCoveringClusterPrint("Mode set: ignored"); + break; + /* ### ATTRIBUTEs CHANGEs IGNORED ### */ + /* RO Type: not supposed to dynamically change */ + case Attributes::Type::Id: + /* RO EndProductType: not supposed to dynamically change */ + case Attributes::EndProductType::Id: + /* RO ConfigStatus: set by WC server */ + case Attributes::ConfigStatus::Id: + /* RO SafetyStatus: set by WC server */ + case Attributes::SafetyStatus::Id: + /* ============= Positions for Position Aware ============= */ + case Attributes::CurrentPositionLiftPercent100ths::Id: + case Attributes::CurrentPositionTiltPercent100ths::Id: default: break; } @@ -405,17 +423,13 @@ void WindowApp::Cover::Init(chip::EndpointId endpoint) ConfigStatus configStatus = { .operational = 1, .online = 1, .liftIsReversed = 0, - .liftIsPA = 1, - .tiltIsPA = 1, + .liftIsPA = HasFeaturePaLift(endpoint), + .tiltIsPA = HasFeaturePaTilt(endpoint), .liftIsEncoderControlled = 1, .tiltIsEncoderControlled = 1 }; ConfigStatusSet(endpoint, configStatus); - // Attribute: Id 10 OperationalStatus - OperationalStatus operationalStatus = { .global = OperationalState::Stall, - .lift = OperationalState::Stall, - .tilt = OperationalState::Stall }; - OperationalStatusSet(endpoint, operationalStatus); + OperationalStatusSetWithGlobalUpdated(endpoint, mOperationalStatus); // Attribute: Id 13 EndProductType EndProductTypeSet(endpoint, EMBER_ZCL_WC_END_PRODUCT_TYPE_INTERIOR_BLIND); @@ -435,7 +449,7 @@ void WindowApp::Cover::Finish() WindowApp::Instance().DestroyTimer(mTiltTimer); } -void WindowApp::Cover::LiftUp() +void WindowApp::Cover::LiftDown() { EmberAfStatus status; chip::app::DataModel::Nullable current; @@ -457,7 +471,7 @@ void WindowApp::Cover::LiftUp() LiftPositionSet(mEndpoint, percent100ths); } -void WindowApp::Cover::LiftDown() +void WindowApp::Cover::LiftUp() { EmberAfStatus status; chip::app::DataModel::Nullable current; @@ -479,53 +493,54 @@ void WindowApp::Cover::LiftDown() LiftPositionSet(mEndpoint, percent100ths); } -void WindowApp::Cover::GotoLift(EventId action) +void WindowApp::Cover::LiftUpdate(bool newTarget) { - chip::app::DataModel::Nullable current; - chip::app::DataModel::Nullable target; + NPercent100ths current, target; Attributes::TargetPositionLiftPercent100ths::Get(mEndpoint, target); Attributes::CurrentPositionLiftPercent100ths::Get(mEndpoint, current); - if (current.IsNull() || target.IsNull()) - { - return; - } + OperationalStatus opStatus = OperationalStatusGet(mEndpoint); + OperationalState opState = ComputeOperationalState(target, current); - if (EventId::None != action) + /* If Triggered by a TARGET update */ + if (newTarget) { - mLiftAction = action; + mLiftTimer->Stop(); // Cancel previous motion if any + mLiftOpState = opState; } - if (EventId::LiftUp == mLiftAction) + if (mLiftOpState == opState) { - if (current.Value() < target.Value()) + /* Actuator still need to move, not reached/crossed Target yet */ + switch (mLiftOpState) { + case OperationalState::MovingDownOrClose: + LiftDown(); + break; + case OperationalState::MovingUpOrOpen: LiftUp(); - } - else - { - mLiftAction = EventId::None; + break; + default: + break; } } - else + else /* CURRENT reached TARGET or crossed it */ { - if (current.Value() > target.Value()) - { - LiftDown(); - } - else - { - mLiftAction = EventId::None; - } + /* Actuator finalize the movement AND CURRENT Must be equal to TARGET at the end */ + Attributes::CurrentPositionLiftPercent100ths::Set(mEndpoint, target); + mLiftOpState = OperationalState::Stall; } - if (EventId::None != mLiftAction && mLiftTimer) + opStatus.lift = mLiftOpState; + OperationalStatusSetWithGlobalUpdated(mEndpoint, opStatus); + + if ((OperationalState::Stall != mLiftOpState) && mLiftTimer) { mLiftTimer->Start(); } } -void WindowApp::Cover::TiltUp() +void WindowApp::Cover::TiltDown() { EmberAfStatus status; chip::app::DataModel::Nullable current; @@ -547,7 +562,7 @@ void WindowApp::Cover::TiltUp() TiltPositionSet(mEndpoint, percent100ths); } -void WindowApp::Cover::TiltDown() +void WindowApp::Cover::TiltUp() { EmberAfStatus status; chip::app::DataModel::Nullable current; @@ -569,47 +584,48 @@ void WindowApp::Cover::TiltDown() TiltPositionSet(mEndpoint, percent100ths); } -void WindowApp::Cover::GotoTilt(EventId action) +void WindowApp::Cover::TiltUpdate(bool newTarget) { - chip::app::DataModel::Nullable current; - chip::app::DataModel::Nullable target; + NPercent100ths current, target; Attributes::TargetPositionTiltPercent100ths::Get(mEndpoint, target); Attributes::CurrentPositionTiltPercent100ths::Get(mEndpoint, current); - if (current.IsNull() || target.IsNull()) - { - return; - } + OperationalStatus opStatus = OperationalStatusGet(mEndpoint); + OperationalState opState = ComputeOperationalState(target, current); - if (EventId::None != action) + /* If Triggered by a TARGET update */ + if (newTarget) { - mTiltAction = action; + mTiltTimer->Stop(); // Cancel previous motion if any + mTiltOpState = opState; } - if (EventId::TiltUp == mTiltAction) + if (mTiltOpState == opState) { - if (current.Value() < target.Value()) + /* Actuator still need to move, not reached/crossed Target yet */ + switch (mTiltOpState) { + case OperationalState::MovingDownOrClose: + TiltDown(); + break; + case OperationalState::MovingUpOrOpen: TiltUp(); - } - else - { - mTiltAction = EventId::None; + break; + default: + break; } } - else + else /* CURRENT reached TARGET or crossed it */ { - if (current.Value() > target.Value()) - { - TiltDown(); - } - else - { - mTiltAction = EventId::None; - } + /* Actuator finalize the movement AND CURRENT Must be equal to TARGET at the end */ + Attributes::CurrentPositionTiltPercent100ths::Set(mEndpoint, target); + mTiltOpState = OperationalState::Stall; } - if (EventId::None != mTiltAction && mTiltTimer) + opStatus.tilt = mTiltOpState; + OperationalStatusSetWithGlobalUpdated(mEndpoint, opStatus); + + if ((OperationalState::Stall != mTiltOpState) && mTiltTimer) { mTiltTimer->Start(); } @@ -639,26 +655,12 @@ EmberAfWcType WindowApp::Cover::CycleType() return type; } -void WindowApp::Cover::StopMotion() -{ - mLiftAction = EventId::None; - if (mLiftTimer) - { - mLiftTimer->Stop(); - } - mTiltAction = EventId::None; - if (mTiltTimer) - { - mTiltTimer->Stop(); - } -} - void WindowApp::Cover::OnLiftTimeout(WindowApp::Timer & timer) { WindowApp::Cover * cover = static_cast(timer.mContext); if (cover) { - cover->GotoLift(); + cover->LiftContinueToTarget(); } } @@ -667,6 +669,6 @@ void WindowApp::Cover::OnTiltTimeout(WindowApp::Timer & timer) WindowApp::Cover * cover = static_cast(timer.mContext); if (cover) { - cover->GotoTilt(); + cover->TiltContinueToTarget(); } } diff --git a/examples/window-app/common/src/ZclCallbacks.cpp b/examples/window-app/common/src/ZclCallbacks.cpp index c662dfdf99e462..d18b1fe199ec8e 100644 --- a/examples/window-app/common/src/ZclCallbacks.cpp +++ b/examples/window-app/common/src/ZclCallbacks.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -39,83 +40,19 @@ using namespace ::chip::app::Clusters::WindowCovering; void MatterPostAttributeChangeCallback(const app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type, uint16_t size, uint8_t * value) { - if (attributePath.mClusterId == app::Clusters::Identify::Id) + switch (attributePath.mClusterId) { + case app::Clusters::Identify::Id: ChipLogProgress(Zcl, "Identify cluster ID: " ChipLogFormatMEI " Type: %" PRIu8 " Value: %" PRIu16 ", length %" PRIu16, ChipLogValueMEI(attributePath.mAttributeId), type, *value, size); - } - else if (attributePath.mClusterId == Id) - { - ChipLogProgress(Zcl, "Window cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(attributePath.mClusterId)); - } - else - { - ChipLogProgress(Zcl, "Unknown cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(attributePath.mClusterId)); - } - - WindowApp & app = WindowApp::Instance(); - EndpointId endpoint = attributePath.mEndpointId; - - chip::app::DataModel::Nullable current; - chip::app::DataModel::Nullable target; - OperationalState opState; - - switch (attributePath.mAttributeId) - { - case Attributes::Type::Id: - app.PostEvent(WindowApp::Event(WindowApp::EventId::CoverTypeChange, endpoint)); - break; - - case Attributes::CurrentPositionLiftPercent100ths::Id: - app.PostEvent(WindowApp::Event(WindowApp::EventId::LiftChanged, endpoint)); - break; - - case Attributes::CurrentPositionTiltPercent100ths::Id: - app.PostEvent(WindowApp::Event(WindowApp::EventId::TiltChanged, endpoint)); - break; - - case Attributes::TargetPositionLiftPercent100ths::Id: - Attributes::TargetPositionLiftPercent100ths::Get(endpoint, target); - Attributes::CurrentPositionLiftPercent100ths::Get(endpoint, current); - opState = ComputeOperationalState(target, current); - if (OperationalState::MovingDownOrClose == opState) - { - app.PostEvent(WindowApp::Event(WindowApp::EventId::LiftDown, endpoint)); - } - else if (OperationalState::MovingUpOrOpen == opState) - { - app.PostEvent(WindowApp::Event(WindowApp::EventId::LiftUp, endpoint)); - } break; - - case Attributes::TargetPositionTiltPercent100ths::Id: - Attributes::TargetPositionTiltPercent100ths::Get(endpoint, target); - Attributes::CurrentPositionTiltPercent100ths::Get(endpoint, current); - opState = ComputeOperationalState(target, current); - if (OperationalState::MovingDownOrClose == opState) - { - app.PostEvent(WindowApp::Event(WindowApp::EventId::TiltDown, endpoint)); - } - else if (OperationalState::MovingUpOrOpen == opState) - { - app.PostEvent(WindowApp::Event(WindowApp::EventId::TiltUp, endpoint)); - } - break; - default: break; } } -/** - * @brief Cluster StopMotion Command callback (from client) - */ -bool emberAfWindowCoveringClusterStopMotionCallback(chip::app::CommandHandler * commandObj, - const chip::app::ConcreteCommandPath & commandPath, - const Commands::StopMotion::DecodableType & commandData) +/* Forwards all attributes changes */ +void MatterWindowCoveringClusterServerAttributeChangedCallback(const app::ConcreteAttributePath & attributePath) { - ChipLogProgress(Zcl, "StopMotion command received"); - WindowApp::Instance().PostEvent(WindowApp::Event(WindowApp::EventId::StopMotion, commandPath.mEndpointId)); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; + WindowApp::Instance().PostAttributeChange(attributePath.mEndpointId, attributePath.mAttributeId); } diff --git a/examples/window-app/common/window-app.zap b/examples/window-app/common/window-app.zap index 3c3239d196d57a..6e59b94ccc348d 100644 --- a/examples/window-app/common/window-app.zap +++ b/examples/window-app/common/window-app.zap @@ -6741,7 +6741,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0001", + "defaultValue": "0x0017", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -8067,7 +8067,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0001", + "defaultValue": "0x0017", "reportable": 1, "minInterval": 0, "maxInterval": 65344, diff --git a/examples/window-app/efr32/include/WindowAppImpl.h b/examples/window-app/efr32/include/WindowAppImpl.h index b61dafc7138175..7c03131955b524 100644 --- a/examples/window-app/efr32/include/WindowAppImpl.h +++ b/examples/window-app/efr32/include/WindowAppImpl.h @@ -36,6 +36,7 @@ class WindowAppImpl : public WindowApp CHIP_ERROR Start() override; void Finish() override; void PostEvent(const WindowApp::Event & event) override; + void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId) override; friend void sl_button_on_change(const sl_button_t * handle); protected: @@ -71,6 +72,7 @@ class WindowAppImpl : public WindowApp static void OnIconTimeout(WindowApp::Timer & timer); private: + void DispatchEventAttributeChange(chip::EndpointId endpoint, chip::AttributeId attribute); TaskHandle_t mHandle = nullptr; QueueHandle_t mQueue = nullptr; LEDWidget mStatusLED; diff --git a/examples/window-app/efr32/src/WindowAppImpl.cpp b/examples/window-app/efr32/src/WindowAppImpl.cpp index e97387dc77122c..97a874ca7ff200 100644 --- a/examples/window-app/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/efr32/src/WindowAppImpl.cpp @@ -235,6 +235,11 @@ void WindowAppImpl::PostEvent(const WindowApp::Event & event) } } +void WindowAppImpl::PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId) +{ + Instance().PostEvent(WindowApp::Event(WindowApp::EventId::AttributeChange, endpoint, attributeId)); +} + void WindowAppImpl::ProcessEvents() { WindowApp::Event event = EventId::None; @@ -258,11 +263,43 @@ WindowApp::Button * WindowAppImpl::CreateButton(WindowApp::Button::Id id, const return new Button(id, name); } +void WindowAppImpl::DispatchEventAttributeChange(chip::EndpointId endpoint, chip::AttributeId attribute) +{ + switch (attribute) + { + /* RO OperationalStatus */ + case Attributes::OperationalStatus::Id: + UpdateLEDs(); + break; + /* RO Type: not supposed to dynamically change -> Cycling Window Covering Demo */ + case Attributes::Type::Id: + /* ============= Positions for Position Aware ============= */ + case Attributes::CurrentPositionLiftPercent100ths::Id: + case Attributes::CurrentPositionTiltPercent100ths::Id: + UpdateLCD(); + break; + /* ### ATTRIBUTEs CHANGEs IGNORED ### */ + /* RO EndProductType: not supposed to dynamically change */ + case Attributes::EndProductType::Id: + /* RO ConfigStatus: set by WC server */ + case Attributes::ConfigStatus::Id: + /* RO SafetyStatus: set by WC server */ + case Attributes::SafetyStatus::Id: + /* RW Mode: User can change */ + case Attributes::Mode::Id: + default: + break; + } +} + void WindowAppImpl::DispatchEvent(const WindowApp::Event & event) { WindowApp::DispatchEvent(event); switch (event.mId) { + case EventId::AttributeChange: + DispatchEventAttributeChange(event.mEndpoint, event.mAttributeId); + break; case EventId::ResetWarning: EFR32_LOG("Factory Reset Triggered. Release button within %ums to cancel.", LONG_PRESS_TIMEOUT); // Turn off all LEDs before starting blink to make sure blink is @@ -288,8 +325,6 @@ void WindowAppImpl::DispatchEvent(const WindowApp::Event & event) UpdateLEDs(); break; case EventId::CoverTypeChange: - case EventId::LiftChanged: - case EventId::TiltChanged: UpdateLCD(); break; case EventId::CoverChange: @@ -349,7 +384,7 @@ void WindowAppImpl::UpdateLEDs() liftLimit = CheckLimitState(current.Value(), limits); } - if (EventId::None != cover.mLiftAction || EventId::None != cover.mTiltAction) + if (OperationalState::Stall != cover.mLiftOpState) { mActionLED.Blink(100); } diff --git a/src/app/clusters/window-covering-server/window-covering-server.cpp b/src/app/clusters/window-covering-server/window-covering-server.cpp index 98a8abd15c88be..c7b9877ce8e2cb 100644 --- a/src/app/clusters/window-covering-server/window-covering-server.cpp +++ b/src/app/clusters/window-covering-server/window-covering-server.cpp @@ -42,15 +42,15 @@ using namespace chip::app::Clusters::WindowCovering; #define CHECK_BOUNDS_INVALID(MIN, VAL, MAX) ((VAL < MIN) || (VAL > MAX)) #define CHECK_BOUNDS_VALID(MIN, VAL, MAX) (!CHECK_BOUNDS_INVALID(MIN, VAL, MAX)) +#define FAKE_MOTION_DELAY_MS 5000 + /* * ConvertValue: Converts values from one range to another * Range In -> from inputLowValue to inputHighValue * Range Out -> from outputLowValue to outputtHighValue - * offset true -> allows to take into account the minimum of each range in the conversion - * offset false -> applies only the basic "rule of three" for the conversion */ static uint16_t ConvertValue(uint16_t inputLowValue, uint16_t inputHighValue, uint16_t outputLowValue, uint16_t outputHighValue, - uint16_t value, bool offset) + uint16_t value) { uint16_t inputMin = inputLowValue, inputMax = inputHighValue, inputRange = UINT16_MAX; uint16_t outputMin = outputLowValue, outputMax = outputHighValue, outputRange = UINT16_MAX; @@ -70,29 +70,19 @@ static uint16_t ConvertValue(uint16_t inputLowValue, uint16_t inputHighValue, ui inputRange = static_cast(inputMax - inputMin); outputRange = static_cast(outputMax - outputMin); - if (offset) + if (value < inputMin) { - if (value < inputMin) - { - return outputMin; - } - - if (value > inputMax) - { - return outputMax; - } + return outputMin; + } - if (inputRange > 0) - { - return static_cast(outputMin + ((outputRange * (value - inputMin) / inputRange))); - } + if (value > inputMax) + { + return outputMax; } - else + + if (inputRange > 0) { - if (inputRange > 0) - { - return static_cast((outputRange * (value) / inputRange)); - } + return static_cast(outputMin + ((outputRange * (value - inputMin) / inputRange))); } return outputMax; @@ -100,12 +90,12 @@ static uint16_t ConvertValue(uint16_t inputLowValue, uint16_t inputHighValue, ui static Percent100ths ValueToPercent100ths(AbsoluteLimits limits, uint16_t absolute) { - return ConvertValue(limits.open, limits.closed, WC_PERCENT100THS_MIN_OPEN, WC_PERCENT100THS_MAX_CLOSED, absolute, true); + return ConvertValue(limits.open, limits.closed, WC_PERCENT100THS_MIN_OPEN, WC_PERCENT100THS_MAX_CLOSED, absolute); } static uint16_t Percent100thsToValue(AbsoluteLimits limits, Percent100ths relative) { - return ConvertValue(WC_PERCENT100THS_MIN_OPEN, WC_PERCENT100THS_MAX_CLOSED, limits.open, limits.closed, relative, true); + return ConvertValue(WC_PERCENT100THS_MIN_OPEN, WC_PERCENT100THS_MAX_CLOSED, limits.open, limits.closed, relative); } static OperationalState ValueToOperationalState(uint8_t value) @@ -158,12 +148,12 @@ bool HasFeature(chip::EndpointId endpoint, WcFeature feature) return hasFeature; } -static bool HasFeaturePaLift(chip::EndpointId endpoint) +bool HasFeaturePaLift(chip::EndpointId endpoint) { return (HasFeature(endpoint, WcFeature::kLift) && HasFeature(endpoint, WcFeature::kPositionAwareLift)); } -static bool HasFeaturePaTilt(chip::EndpointId endpoint) +bool HasFeaturePaTilt(chip::EndpointId endpoint) { return (HasFeature(endpoint, WcFeature::kTilt) && HasFeature(endpoint, WcFeature::kPositionAwareTilt)); } @@ -443,6 +433,132 @@ OperationalState ComputeOperationalState(NPercent100ths target, NPercent100ths c return OperationalState::Stall; } +void emberAfPluginWindowCoveringFinalizeFakeMotionEventHandler(EndpointId endpoint) +{ + NPercent100ths position; + OperationalStatus opStatus = OperationalStatusGet(endpoint); + emberAfWindowCoveringClusterPrint("WC DELAYED CALLBACK 100ms w/ OpStatus=0x%02X", (unsigned char) opStatus.global); + + /* Update position to simulate movement to pass the CI */ + if (OperationalState::Stall != opStatus.lift) + { + Attributes::TargetPositionLiftPercent100ths::Get(endpoint, position); + if (!position.IsNull()) + { + LiftPositionSet(endpoint, position.Value()); + } + } + + /* Update position to simulate movement to pass the CI */ + if (OperationalState::Stall != opStatus.tilt) + { + Attributes::TargetPositionTiltPercent100ths::Get(endpoint, position); + if (!position.IsNull()) + { + TiltPositionSet(endpoint, position.Value()); + } + } +} + +/** + * @brief Get event control object for an endpoint + * + * @param[in] endpoint + * @return EmberEventControl* + */ +EmberEventControl * GetEventControl(EndpointId endpoint) +{ + static EmberEventControl eventControls[EMBER_AF_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT]; + uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, WindowCovering::Id); + EmberEventControl * event = nullptr; + + if (index < ArraySize(eventControls)) + { + event = &eventControls[index]; + } + return event; +} + +/** + * @brief Configure Fake Motion event control object for an endpoint + * + * @param[in] endpoint + * @return EmberEventControl* + */ +EmberEventControl * ConfigureFakeMotionEventControl(EndpointId endpoint) +{ + EmberEventControl * controller = GetEventControl(endpoint); + + controller->endpoint = endpoint; + controller->callback = &emberAfPluginWindowCoveringFinalizeFakeMotionEventHandler; + + return controller; +} + +/** + * @brief PostAttributeChange is called when an Attribute is modified + * + * @param[in] endpoint + * @param[in] attributeId + */ +void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId) +{ + // all-cluster-app: simulation for the CI testing + // otherwise it is defined for manufacturer specific implementation */ + NPercent100ths current, target; + OperationalStatus prevOpStatus = OperationalStatusGet(endpoint); + OperationalStatus opStatus = prevOpStatus; + + emberAfWindowCoveringClusterPrint("WC POST ATTRIBUTE=%u OpStatus global=0x%02X lift=0x%02X tilt=0x%02X", + (unsigned int) attributeId, (unsigned int) opStatus.global, (unsigned int) opStatus.lift, + (unsigned int) opStatus.tilt); + + switch (attributeId) + { + /* RO OperationalStatus */ + case Attributes::OperationalStatus::Id: + if (OperationalState::Stall != opStatus.global) + { + // Finish the fake motion attribute update: + emberEventControlSetDelayMS(ConfigureFakeMotionEventControl(endpoint), FAKE_MOTION_DELAY_MS); + } + break; + /* ============= Positions for Position Aware ============= */ + case Attributes::CurrentPositionLiftPercent100ths::Id: + if (OperationalState::Stall != opStatus.lift) + { + opStatus.lift = OperationalState::Stall; + emberAfWindowCoveringClusterPrint("Lift stop"); + } + break; + case Attributes::CurrentPositionTiltPercent100ths::Id: + if (OperationalState::Stall != opStatus.tilt) + { + opStatus.tilt = OperationalState::Stall; + emberAfWindowCoveringClusterPrint("Tilt stop"); + } + break; + /* For a device supporting Position Awareness : Changing the Target triggers motions on the real or simulated device */ + case Attributes::TargetPositionLiftPercent100ths::Id: + Attributes::TargetPositionLiftPercent100ths::Get(endpoint, target); + Attributes::CurrentPositionLiftPercent100ths::Get(endpoint, current); + opStatus.lift = ComputeOperationalState(target, current); + break; + /* For a device supporting Position Awareness : Changing the Target triggers motions on the real or simulated device */ + case Attributes::TargetPositionTiltPercent100ths::Id: + Attributes::TargetPositionTiltPercent100ths::Get(endpoint, target); + Attributes::CurrentPositionTiltPercent100ths::Get(endpoint, current); + opStatus.tilt = ComputeOperationalState(target, current); + break; + default: + break; + } + + /* This decides and triggers fake motion for the selected endpoint */ + if ((opStatus.lift != prevOpStatus.lift) || (opStatus.tilt != prevOpStatus.tilt)) + OperationalStatusSetWithGlobalUpdated(endpoint, opStatus); +} + } // namespace WindowCovering } // namespace Clusters } // namespace app @@ -508,9 +624,8 @@ bool emberAfWindowCoveringClusterDownOrCloseCallback(app::CommandHandler * comma /** * @brief Cluster StopMotion Command callback (from client) */ -bool __attribute__((weak)) -emberAfWindowCoveringClusterStopMotionCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - const Commands::StopMotion::DecodableType & fields) +bool emberAfWindowCoveringClusterStopMotionCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + const Commands::StopMotion::DecodableType & fields) { emberAfWindowCoveringClusterPrint("StopMotion command received"); app::DataModel::Nullable current; @@ -649,4 +764,16 @@ bool emberAfWindowCoveringClusterGoToTiltPercentageCallback(app::CommandHandler return true; } +/** + * @brief Cluster Attribute Changed Callback + */ +void __attribute__((weak)) +MatterWindowCoveringClusterServerAttributeChangedCallback(const app::ConcreteAttributePath & attributePath) +{ + PostAttributeChange(attributePath.mEndpointId, attributePath.mAttributeId); +} + +/** + * @brief Cluster Plugin Init Callback + */ void MatterWindowCoveringPluginServerInitCallback() {} diff --git a/src/app/clusters/window-covering-server/window-covering-server.h b/src/app/clusters/window-covering-server/window-covering-server.h index 40e523c4e74839..d02c8e8f082f94 100644 --- a/src/app/clusters/window-covering-server/window-covering-server.h +++ b/src/app/clusters/window-covering-server/window-covering-server.h @@ -110,6 +110,8 @@ struct AbsoluteLimits }; bool HasFeature(chip::EndpointId endpoint, WcFeature feature); +bool HasFeaturePaLift(chip::EndpointId endpoint); +bool HasFeaturePaTilt(chip::EndpointId endpoint); void TypeSet(chip::EndpointId endpoint, EmberAfWcType type); EmberAfWcType TypeGet(chip::EndpointId endpoint); diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index e6939e2e2db644..9707b541a42c11 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -190,15 +190,39 @@ PICS: id: MANUAL_OCCUPANCY_CHANGE # Window covering cluster - - label: "Does the device implement the Type" + ## WC-Features + - label: "Does the device implement the Lift feature?" + id: WNCV_LF + + - label: "Does the device implement the Position Aware Lift feature?" + id: WNCV_PA_LF + + - label: "Does the device implement the Lift feature?" + id: WNCV_TL + + - label: "Does the device implement the Position Aware Lift feature?" + id: WNCV_PA_TL + + ## WC-Attributes + - label: "Does the device implement the Type attribute?" id: A_TYPE - - label: "Does the device implement the ConfigStatus" + - label: "Does the device implement the ConfigStatus attribute?" id: A_CONFIGSTATUS - - label: "Does the device implement the EndProductType" + - label: "Does the device implement the EndProductType attribute?" id: A_ENDPRODUCTTYPE + - label: + "Does the device implement the CurrentPositionLiftPercentage + attribute?" + id: A_CURRENTPOSITIONLIFTPERCENTAGE + + - label: + "Does the device implement the CurrentPositionTiltPercentage + attribute?" + id: A_CURRENTPOSITIONTILTPERCENTAGE + # On/Off Cluster - label: "Does the device implement the OnOff attribute?" id: A_ONOFF diff --git a/src/app/tests/suites/certification/Test_TC_WNCV_3_1.yaml b/src/app/tests/suites/certification/Test_TC_WNCV_3_1.yaml index 5eeb10070edec9..705c811aad68c0 100644 --- a/src/app/tests/suites/certification/Test_TC_WNCV_3_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_WNCV_3_1.yaml @@ -12,103 +12,278 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Window Covering [TC-WNCV-3.1] UpOrOpen Verification with server as DUT +name: + Window Covering [TC-WNCV-3.1] UpOrOpen Command & Report Verification with + server as DUT -# TODO: WindowCovering tests TC-WNCV-3.1 finalize featuremap conditional dependencies +# TC-WNCV tests featuremap conditional dependencies -> use PICS config: cluster: "Window Covering" endpoint: 1 tests: - - label: "Wait for the commissioned device to be retrieved" + - label: "0: Wait for the commissioned device to be retrieved" cluster: "DelayCommands" command: "WaitForCommissionee" - ### Step 1x -> Initialize Position - ### MANDATORY Command - - label: "1a: TH adjusts the the DUT to a non-open position" + ################ Position Init Phase ############# + ### Step 1x -> Initialize the Covering position before any testing + ### MANDATORY Init Commands + - label: + "1a: TH sends DownOrClose command to preposition the DUT in the + opposite direction" command: "DownOrClose" - ### Depends on the FeatureMap + - label: "1b: TH Waits for 10 seconds movement(s) on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 10000 + + ### + ### Mandatory Depends on the FeatureMap - label: - "1b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute + "1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" attribute: "CurrentPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: constraints: type: uint16 + minValue: 1 + maxValue: 10000 - ### Depends on the FeatureMap + ### Optional Depends on the FeatureMap - label: - "1b: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute + "1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional + attribute from DUT" + command: "readAttribute" + attribute: "CurrentPositionLiftPercentage" + PICS: WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE + response: + constraints: + type: uint8 + minValue: 1 + maxValue: 100 + + ### Mandatory Depends on the FeatureMap + - label: + "1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" attribute: "CurrentPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL response: constraints: type: uint16 + minValue: 1 + maxValue: 10000 + + ### Optional Depends on the FeatureMap + - label: + "1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional + attribute from DUT" + command: "readAttribute" + attribute: "CurrentPositionTiltPercentage" + PICS: WNCV_TL && WNCV_PA_TL && A_CURRENTPOSITIONTILTPERCENTAGE + response: + constraints: + type: uint8 + minValue: 1 + maxValue: 100 + + ######## UpOrOpen Command ####### + ### Step 2x -> Check UpOrOpen Fast effects + + - label: "2: Subscribe to DUT reports on OperationalStatus attribute" + command: "subscribeAttribute" + attribute: "OperationalStatus" + minInterval: 4 + maxInterval: 5 + response: + constraints: + type: map8 - ### Step 2x -> Check Command instant effect ### MANDATORY Command - label: "2a: TH sends UpOrOpen command to DUT" command: "UpOrOpen" - ### Depends on the FeatureMap + ### Depending on the DUT specs we might prefer a arguments here + - label: "2b: DUT updates its attributes" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 100 + + ### Mandatory Depends on the FeatureMap - label: - "2b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute + "2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" attribute: "TargetPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: - constraints: - type: uint16 + value: 0 - ### Depends on the FeatureMap + ### Mandatory Depends on the FeatureMap - label: - "2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute + "2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT" disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" attribute: "TargetPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL + response: + value: 0 + + - label: "2e: TH leave the device moving for 2 seconds" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 2000 + + ######## UpOrOpen Reports ####### + ### Step 3x -> Check UpOrOpen Mid term effects + ### Depends on the FeatureMap + # The value of bit 0..1 must be 01b & if (LF) value of bit 2..3 must be 01b else 00b & if (TL) value of bit 4..5 must be 01b else 00b + # Only 3 possibilities are possible here : 05h = 5, 11h = 17 or 15h = 21 then check a range for simplicity [5 - 21] + - label: + "3a1: Verify DUT reports OperationalStatus attribute to TH after a + UpOrOpen" + command: "waitForReport" + attribute: "OperationalStatus" + response: + constraints: + type: map8 + minValue: 5 + maxValue: 21 + + ### Depending on the DUT specs we might prefer a arguments here + - label: "3a2: DUT updates its attributes" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 2000 + + ### Mandatory Depends on the FeatureMap + - label: + "3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute + from DUT" + command: "readAttribute" + attribute: "CurrentPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: constraints: type: uint16 + minValue: 0 + maxValue: 9999 - ### Depends on a sleep/wait command how to do this with a real device - - label: "2d: Wait for the movement to finish" - disabled: true + ### Optional Depends on the FeatureMap + - label: + "3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional + attribute from DUT" + command: "readAttribute" + attribute: "CurrentPositionLiftPercentage" + PICS: WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE + response: + constraints: + type: uint8 + minValue: 0 + maxValue: 99 - ### Step 3x -> Check longer period effect - ### MANDATORY reads - - label: "3a: TH reads OperationalStatus attribute from DUT" + ### Mandatory Depends on the FeatureMap + - label: + "3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute + from DUT" + command: "readAttribute" + attribute: "CurrentPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL + response: + constraints: + type: uint16 + minValue: 0 + maxValue: 9999 + + ### Optional Depends on the FeatureMap + - label: + "3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional + attribute from DUT" + command: "readAttribute" + attribute: "CurrentPositionTiltPercentage" + PICS: WNCV_TL && WNCV_PA_TL && A_CURRENTPOSITIONTILTPERCENTAGE + response: + constraints: + type: uint8 + minValue: 0 + maxValue: 99 + + ######## STOP ####### + ### Step 4x -> Check StopMotion fast effects + ### MANDATORY Command + - label: "4a: TH sends a StopMotion command to DUT" + command: "StopMotion" + + - label: + "4b: TH waits for 3 seconds the end of inertial movement(s) on the + device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 3000 + + ### Must Be ZERO + # The value of bit 0..1 must be 00b & if (LF) value of bit 2..3 must be 00b & if (TL) value of bit 4..5 must be 00b + - label: + "4c: Verify DUT update OperationalStatus attribute to TH after a + StopMotion" command: "readAttribute" attribute: "OperationalStatus" response: value: 0 - ### Depends on the FeatureMap + ### Step 5x -> Check Stop Motion longer period effect + - label: "5a: TH waits for x seconds attributes update on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 1000 + + ### Mandatory Depends on the FeatureMap shall be tested as equals CurrentPositionLiftPercent100ths - label: - "3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute + "5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" - attribute: "CurrentPositionLiftPercent100ths" + attribute: "TargetPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: constraints: type: uint16 + minValue: 0 + maxValue: 9999 - ### Depends on the FeatureMap + ### Mandatory Depends on the FeatureMap shall be tested as equals CurrentPositionTiltPercent100ths - label: - "3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute + "5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" - attribute: "CurrentPositionTiltPercent100ths" + attribute: "TargetPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL response: constraints: type: uint16 + minValue: 0 + maxValue: 9999 diff --git a/src/app/tests/suites/certification/Test_TC_WNCV_3_2.yaml b/src/app/tests/suites/certification/Test_TC_WNCV_3_2.yaml index 9efc3c573255fd..b63b14f3acd489 100644 --- a/src/app/tests/suites/certification/Test_TC_WNCV_3_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_WNCV_3_2.yaml @@ -12,103 +12,278 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Window Covering [TC-WNCV-3.2] DownOrClose Verification with server as DUT +name: + Window Covering [TC-WNCV-3.2] DownOrClose Command & Report Verification with + server as DUT -# TODO: WindowCovering tests TC-WNCV-3.2 finalize featuremap conditional dependencies +# TC-WNCV tests featuremap conditional dependencies -> use PICS config: cluster: "Window Covering" endpoint: 1 tests: - - label: "Wait for the commissioned device to be retrieved" + - label: "0: Wait for the commissioned device to be retrieved" cluster: "DelayCommands" command: "WaitForCommissionee" - ### Step 1x -> Initialize Position - ### MANDATORY Command - - label: "1a: TH adjusts the the DUT to a non-closed position" + ################ Position Init Phase ############# + ### Step 1x -> Initialize the Covering position before any testing + ### MANDATORY Init Commands + - label: + "1a: TH sends UpOrOpen command to preposition the DUT in the opposite + direction" command: "UpOrOpen" - ### Depends on the FeatureMap + - label: "1b: TH Waits for 10 seconds movement(s) on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 10000 + + ### + ### Mandatory Depends on the FeatureMap - label: - "1b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute + "1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" attribute: "CurrentPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: constraints: type: uint16 + minValue: 0 + maxValue: 9999 - ### Depends on the FeatureMap + ### Optional Depends on the FeatureMap - label: - "1b: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute + "1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional + attribute from DUT" + command: "readAttribute" + attribute: "CurrentPositionLiftPercentage" + PICS: WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE + response: + constraints: + type: uint8 + minValue: 0 + maxValue: 99 + + ### Mandatory Depends on the FeatureMap + - label: + "1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" attribute: "CurrentPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL response: constraints: type: uint16 + minValue: 0 + maxValue: 9999 + + ### Optional Depends on the FeatureMap + - label: + "1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional + attribute from DUT" + command: "readAttribute" + attribute: "CurrentPositionTiltPercentage" + PICS: WNCV_TL && WNCV_PA_TL && A_CURRENTPOSITIONTILTPERCENTAGE + response: + constraints: + type: uint8 + minValue: 0 + maxValue: 99 + + ######## DownOrClose Command ####### + ### Step 2x -> Check DownOrClose Fast effects + + - label: "2: Subscribe to DUT reports on OperationalStatus attribute" + command: "subscribeAttribute" + attribute: "OperationalStatus" + minInterval: 4 + maxInterval: 5 + response: + constraints: + type: map8 - ### Step 2x -> Check Command instant effect ### MANDATORY Command - label: "2a: TH sends DownOrClose command to DUT" command: "DownOrClose" - ### Depends on the FeatureMap + ### Depending on the DUT specs we might prefer a arguments here + - label: "2b: DUT updates its attributes" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 100 + + ### Mandatory Depends on the FeatureMap - label: - "2b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute + "2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" attribute: "TargetPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: - constraints: - type: uint16 + value: 10000 - ### Depends on the FeatureMap + ### Mandatory Depends on the FeatureMap - label: - "2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute + "2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT" disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" attribute: "TargetPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL + response: + value: 10000 + + - label: "2e: TH leave the device moving for 2 seconds" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 2000 + + ######## DownOrClose Reports ####### + ### Step 3x -> Check DownOrClose Mid term effects + ### Depends on the FeatureMap + # The value of bit 0..1 must be 10b & if (LF) value of bit 2..3 must be 10b else 00b & if (TL) value of bit 4..5 must be 10b else 00b + # Only 3 possibilities are possible here : 0Ah = 10, 22h = 34 or 2Ah = 42 then check a range for simplicity [10 - 42] + - label: + "3a: Verify DUT reports OperationalStatus attribute to TH after a + DownOrClose" + command: "waitForReport" + attribute: "OperationalStatus" + response: + constraints: + type: map8 + minValue: 10 + maxValue: 42 + + ### Depending on the DUT specs we might prefer a arguments here + - label: "3a2: DUT updates its attributes" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 2000 + + ### Mandatory Depends on the FeatureMap + - label: + "3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute + from DUT" + command: "readAttribute" + attribute: "CurrentPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF + response: + constraints: + type: uint16 + minValue: 1 + maxValue: 10000 + + ### Optional Depends on the FeatureMap + - label: + "3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional + attribute from DUT" + command: "readAttribute" + attribute: "CurrentPositionLiftPercentage" + PICS: WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE + response: + constraints: + type: uint8 + minValue: 1 + maxValue: 100 + + ### Mandatory Depends on the FeatureMap + - label: + "3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute + from DUT" + command: "readAttribute" + attribute: "CurrentPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL response: constraints: type: uint16 + minValue: 1 + maxValue: 10000 + + ### Optional Depends on the FeatureMap + - label: + "3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional + attribute from DUT" + command: "readAttribute" + attribute: "CurrentPositionTiltPercentage" + PICS: WNCV_TL && WNCV_PA_TL && A_CURRENTPOSITIONTILTPERCENTAGE + response: + constraints: + type: uint8 + minValue: 1 + maxValue: 100 + + ######## STOP ####### + ### Step 4x -> Check StopMotion fast effects + ### MANDATORY Command + - label: "4a: TH sends a StopMotion command to DUT" + command: "StopMotion" - ### Depends on a sleep/wait command how to do this with a real device - - label: "2d: Wait for the movement to finish" - disabled: true + - label: + "4b: TH waits for 3 seconds the end of inertial movement(s) on the + device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 3000 - ### Step 3x -> Check longer period effect - ### MANDATORY reads - - label: "3a: TH reads OperationalStatus attribute from DUT" + ### Must Be ZERO + # The value of bit 0..1 must be 00b & if (LF) value of bit 2..3 must be 00b & if (TL) value of bit 4..5 must be 00b + - label: + "4c: Verify DUT update OperationalStatus attribute to TH after a + StopMotion" command: "readAttribute" attribute: "OperationalStatus" response: value: 0 - ### Depends on the FeatureMap + ### Step 5x -> Check Stop Motion longer period effect + - label: "5a: TH waits for x seconds attributes update on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 1000 + + ### Mandatory Depends on the FeatureMap shall be tested as equals CurrentPositionLiftPercent100ths - label: - "3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute + "5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" - attribute: "CurrentPositionLiftPercent100ths" + attribute: "TargetPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: constraints: type: uint16 + minValue: 1 + maxValue: 10000 - ### Depends on the FeatureMap + ### Mandatory Depends on the FeatureMap shall be tested as equals CurrentPositionTiltPercent100ths - label: - "3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute + "5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" - attribute: "CurrentPositionTiltPercent100ths" + attribute: "TargetPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL response: constraints: type: uint16 + minValue: 1 + maxValue: 10000 diff --git a/src/app/tests/suites/certification/Test_TC_WNCV_3_3.yaml b/src/app/tests/suites/certification/Test_TC_WNCV_3_3.yaml index 066368d8e50412..651420e8e5126e 100644 --- a/src/app/tests/suites/certification/Test_TC_WNCV_3_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_WNCV_3_3.yaml @@ -14,78 +14,151 @@ name: Window Covering [TC-WNCV-3.3] StopMotion Verification with server as DUT -# TODO: WindowCovering tests TC-WNCV-3.3 finalize featuremap conditional dependencies +# TC-WNCV tests featuremap conditional dependencies -> use PICS config: cluster: "Window Covering" endpoint: 1 tests: - - label: "Wait for the commissioned device to be retrieved" + - label: "0: Wait for the commissioned device to be retrieved" cluster: "DelayCommands" command: "WaitForCommissionee" - ### Step 1x -> Initialize Position - ### MANDATORY Command - - label: "1a: TH adjusts the the DUT to a non-open position" + ################ Position Init Phase ############# + ### Step 1x -> Initialize the Covering position before any testing + ### MANDATORY Init Commands + - label: + "1a: TH sends DownOrClose command to preposition the DUT in the + opposite direction" + command: "DownOrClose" + + - label: "1b: TH Waits for 6-8 seconds movement(s) on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 6000 + + - label: + "1c: TH sends UpOrOpen command to preposition the DUT in the opposite + direction" command: "UpOrOpen" - ### Depends on a sleep/wait command how to do this with a real device - - label: "1b: Wait for the movement to start and go on for a few seconds" - disabled: true + - label: "1d: TH Waits for 2 seconds movement(s) on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 2000 + + ######## StopMotion Command ####### + ### Step 2x -> Check StopMotion fast effects + ### Before subscribe to reports + - label: "2: Subscribe to DUT reports on OperationalStatus attribute" + command: "subscribeAttribute" + attribute: "OperationalStatus" + minInterval: 4 + maxInterval: 5 + response: + constraints: + type: map8 - ### Step 2x -> Check Command instant effects + longer effects ### MANDATORY Command - - label: "2a: TH sends StopMotion command to DUT" + - label: "2a: TH sends a StopMotion command to DUT" command: "StopMotion" + ### DUT Slow down and stop + - label: + "2b: TH waits for 3 seconds the end of inertial movement(s) on the + device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 3000 + + ### Must Be ZERO + # The value of bit 0..1 must be 00b & if (LF) value of bit 2..3 must be 00b & if (TL) value of bit 4..5 must be 00b + - label: + "2c: Verify DUT reports OperationalStatus attribute to TH after a + StopMotion" + command: "waitForReport" + attribute: "OperationalStatus" + response: + value: 0 + + ### DUT updates its attributes + - label: "2d: TH waits for 100ms - 3s attributes update on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 2000 + ### MANDATORY reads - - label: "2b: TH reads OperationalStatus attribute from DUT" + - label: "2e: TH reads OperationalStatus attribute from DUT" command: "readAttribute" attribute: "OperationalStatus" response: value: 0 - ### 2c Check equality with a tolerance between Target & Current for Lift - ### Depends on the FeatureMap + ######## StopMotion w/ Lift ####### + ### Step 3x -> Verify StopMotion longer period effects on Lift + ### Mandatory/Optionality Depends on (PA & LF) for all 4x Steps + + ### Read Current Position -> Store this value for step 4c - label: - "2c-1: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute + "3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" - attribute: "TargetPositionLiftPercent100ths" + attribute: "CurrentPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: + saveAs: attrCurrentPositionLift constraints: - type: uint16 + minValue: 0 + maxValue: 10000 + ### Read Target Position -> Compare this value w/ Current + ### Shall be tested as equals CurrentPositionLiftPercent100ths - label: - "2c-2: If (PA & LF) TH reads CurrentPositionLiftPercent100ths - attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value + "3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute + 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT" command: "readAttribute" - attribute: "CurrentPositionLiftPercent100ths" + attribute: "TargetPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: - constraints: - type: uint16 + value: attrCurrentPositionLift - ### 2d Check equality with a tolerance between Target & Current for Tilt - ### Depends on the FeatureMap + ######## StopMotion w/ Tilt ####### + ### Step 4x -> Verify StopMotion longer period effects on Tilt + ### Mandatory/Optionality Depends on (PA & TL) for all 4x Steps + + ### Read Current Position -> Store this value for step 4c - label: - "2d-1: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute + "4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" - attribute: "TargetPositionTiltPercent100ths" + attribute: "CurrentPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL response: + saveAs: attrCurrentPositionTilt constraints: - type: uint16 + minValue: 0 + maxValue: 10000 + ### Read Target Position -> Compare this value w/ Current + ### Shall be tested as equals CurrentPositionTiltPercent100ths - label: - "2d-2: If (PA & TL) TH reads CurrentPositionTiltPercent100ths - attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value + "4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute + 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT" command: "readAttribute" - attribute: "CurrentPositionTiltPercent100ths" + attribute: "TargetPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL response: - constraints: - type: uint16 + value: attrCurrentPositionTilt diff --git a/src/app/tests/suites/certification/tests.yaml b/src/app/tests/suites/certification/tests.yaml index d9c6171a9eb185..738b7be6619df1 100644 --- a/src/app/tests/suites/certification/tests.yaml +++ b/src/app/tests/suites/certification/tests.yaml @@ -274,5 +274,27 @@ Test Plans: - name: Global attributes with server as DUT 2: - name: Attributes with server as DUT - - name: Primary functionality with server as DUT - - name: Secondary functionality with server as DUT + - name: ConfigStatus Attribute with server as DUT + - name: Mode Attribute with server as DUT + - name: Type Attribute with server as DUT + - name: EndProductType Attribute with server as DUT + 3: + - name: + UpOrOpen Command & Report Verification with server as DUT + - name: + DownOrClose Command & Report Verification with server as + DUT + - name: StopMotion Verification with server as DUT + - name: UpOrOpen Long-Run Verification with server as DUT + - name: DownOrClose Long-Run Verification with server as DUT + 4: + - name: + GoToLiftPercentage Long-Run Verification with server as + DUT + - name: + GoToTiltPercentage Long-Run Verification with server as + DUT + - name: + GoToLiftPercentage Limits Verification with server as DUT + - name: + GoToTiltPercentage Limits Verification with server as DUT diff --git a/src/app/zap-templates/templates/app/helper.js b/src/app/zap-templates/templates/app/helper.js index c3535878e8586a..18b05fb7e686cb 100644 --- a/src/app/zap-templates/templates/app/helper.js +++ b/src/app/zap-templates/templates/app/helper.js @@ -121,8 +121,13 @@ var endpointClusterWithInit = [ 'Time Format Localization', 'Thermostat', ]; -var endpointClusterWithAttributeChanged = [ 'Identify', 'Door Lock', 'Pump Configuration and Control' ]; -var endpointClusterWithPreAttribute = [ +var endpointClusterWithAttributeChanged = [ + 'Identify', + 'Door Lock', + 'Pump Configuration and Control', + 'Window Covering', +]; +var endpointClusterWithPreAttribute = [ 'IAS Zone', 'Door Lock', 'Thermostat User Interface Configuration', 'Time Format Localization', 'Localization Configuration' ]; var endpointClusterWithMessageSent = [ 'IAS Zone' ]; diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 0f93c76c0f7f01..459a73c1d7c3e1 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -25938,15 +25938,1198 @@ - (void)testSendClusterTest_TC_WNCV_2_5_000002_ReadAttribute - (void)testSendClusterTest_TC_WNCV_3_1_000000_WaitForCommissionee { - XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + XCTestExpectation * expectation = [self expectationWithDescription:@"0: Wait for the commissioned device to be retrieved"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForCommissionee(expectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000001_DownOrClose +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1a: TH sends DownOrClose command to preposition the DUT in the opposite direction"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster downOrCloseWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"1a: TH sends DownOrClose command to preposition the DUT in the opposite direction Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000002_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"1b: TH Waits for 10 seconds movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 10000); + [self waitForExpectationsWithTimeout:(10000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000003_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 1U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000004_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercentageWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 1); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 100); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000005_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 1U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000006_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionTiltPercentageWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 1); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 100); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +bool testSendClusterTest_TC_WNCV_3_1_000007_WaitForReport_Fulfilled = false; +ResponseHandler test_Test_TC_WNCV_3_1_OperationalStatus_Reported = nil; +- (void)testSendClusterTest_TC_WNCV_3_1_000007_WaitForReport +{ + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + test_Test_TC_WNCV_3_1_OperationalStatus_Reported = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Report: 2: Subscribe to DUT reports on OperationalStatus attribute Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + testSendClusterTest_TC_WNCV_3_1_000007_WaitForReport_Fulfilled = true; + }; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000008_SubscribeAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"2: Subscribe to DUT reports on OperationalStatus attribute"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + uint16_t minIntervalArgument = 4U; + uint16_t maxIntervalArgument = 5U; + [cluster subscribeAttributeOperationalStatusWithMinInterval:minIntervalArgument + maxInterval:maxIntervalArgument + subscriptionEstablished:^{ + XCTAssertEqual(testSendClusterTest_TC_WNCV_3_1_000007_WaitForReport_Fulfilled, true); + [expectation fulfill]; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"2: Subscribe to DUT reports on OperationalStatus attribute Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + if (test_Test_TC_WNCV_3_1_OperationalStatus_Reported != nil) { + ResponseHandler callback = test_Test_TC_WNCV_3_1_OperationalStatus_Reported; + test_Test_TC_WNCV_3_1_OperationalStatus_Reported = nil; + callback(value, err); + } + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000009_UpOrOpen +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"2a: TH sends UpOrOpen command to DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster upOrOpenWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"2a: TH sends UpOrOpen command to DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000010_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"2b: DUT updates its attributes"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 100); + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000011_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeTargetPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertFalse(actualValue == nil); + XCTAssertEqual([actualValue unsignedShortValue], 0U); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000012_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"2e: TH leave the device moving for 2 seconds"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 2000); + [self waitForExpectationsWithTimeout:(2000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000013_WaitForReport +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3a1: Verify DUT reports OperationalStatus attribute to TH after a UpOrOpen"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + test_Test_TC_WNCV_3_1_OperationalStatus_Reported = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3a1: Verify DUT reports OperationalStatus attribute to TH after a UpOrOpen Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 5); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 21); + } + } + + [expectation fulfill]; + }; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000014_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"3a2: DUT updates its attributes"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 2000); + [self waitForExpectationsWithTimeout:(2000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000015_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 9999U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000016_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercentageWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 0); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 99); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000017_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 9999U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000018_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionTiltPercentageWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 0); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 99); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000019_StopMotion +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"4a: TH sends a StopMotion command to DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster stopMotionWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"4a: TH sends a StopMotion command to DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000020_WaitForMs +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"4b: TH waits for 3 seconds the end of inertial movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 3000); + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000021_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"4c: Verify DUT update OperationalStatus attribute to TH after a StopMotion"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeOperationalStatusWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"4c: Verify DUT update OperationalStatus attribute to TH after a StopMotion Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertEqual([actualValue unsignedCharValue], 0); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000022_WaitForMs +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"5a: TH waits for x seconds attributes update on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 1000); + [self waitForExpectationsWithTimeout:(1000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000023_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeTargetPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 9999U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_1_000024_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeTargetPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 9999U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterTest_TC_WNCV_3_2_000000_WaitForCommissionee +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"0: Wait for the commissioned device to be retrieved"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForCommissionee(expectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000001_UpOrOpen +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster upOrOpenWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000002_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"1b: TH Waits for 10 seconds movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 10000); + [self waitForExpectationsWithTimeout:(10000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000003_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 9999U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000004_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercentageWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 0); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 99); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000005_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 9999U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000006_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionTiltPercentageWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 0); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 99); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +bool testSendClusterTest_TC_WNCV_3_2_000007_WaitForReport_Fulfilled = false; +ResponseHandler test_Test_TC_WNCV_3_2_OperationalStatus_Reported = nil; +- (void)testSendClusterTest_TC_WNCV_3_2_000007_WaitForReport +{ + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + test_Test_TC_WNCV_3_2_OperationalStatus_Reported = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Report: 2: Subscribe to DUT reports on OperationalStatus attribute Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + testSendClusterTest_TC_WNCV_3_2_000007_WaitForReport_Fulfilled = true; + }; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000008_SubscribeAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"2: Subscribe to DUT reports on OperationalStatus attribute"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + uint16_t minIntervalArgument = 4U; + uint16_t maxIntervalArgument = 5U; + [cluster subscribeAttributeOperationalStatusWithMinInterval:minIntervalArgument + maxInterval:maxIntervalArgument + subscriptionEstablished:^{ + XCTAssertEqual(testSendClusterTest_TC_WNCV_3_2_000007_WaitForReport_Fulfilled, true); + [expectation fulfill]; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"2: Subscribe to DUT reports on OperationalStatus attribute Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + if (test_Test_TC_WNCV_3_2_OperationalStatus_Reported != nil) { + ResponseHandler callback = test_Test_TC_WNCV_3_2_OperationalStatus_Reported; + test_Test_TC_WNCV_3_2_OperationalStatus_Reported = nil; + callback(value, err); + } + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000009_DownOrClose +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"2a: TH sends DownOrClose command to DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster downOrCloseWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"2a: TH sends DownOrClose command to DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000010_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"2b: DUT updates its attributes"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 100); + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000011_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeTargetPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertFalse(actualValue == nil); + XCTAssertEqual([actualValue unsignedShortValue], 10000U); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000012_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"2e: TH leave the device moving for 2 seconds"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 2000); + [self waitForExpectationsWithTimeout:(2000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000013_WaitForReport +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3a: Verify DUT reports OperationalStatus attribute to TH after a DownOrClose"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + test_Test_TC_WNCV_3_2_OperationalStatus_Reported = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3a: Verify DUT reports OperationalStatus attribute to TH after a DownOrClose Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 10); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 42); + } + } + + [expectation fulfill]; + }; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000014_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"3a2: DUT updates its attributes"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 2000); + [self waitForExpectationsWithTimeout:(2000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000015_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 1U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000016_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercentageWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 1); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 100); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000017_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 1U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000018_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionTiltPercentageWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 1); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 100); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000019_StopMotion +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"4a: TH sends a StopMotion command to DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster stopMotionWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"4a: TH sends a StopMotion command to DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000020_WaitForMs +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"4b: TH waits for 3 seconds the end of inertial movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 3000); + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000021_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"4c: Verify DUT update OperationalStatus attribute to TH after a StopMotion"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeOperationalStatusWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"4c: Verify DUT update OperationalStatus attribute to TH after a StopMotion Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertEqual([actualValue unsignedCharValue], 0); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000022_WaitForMs +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"5a: TH waits for x seconds attributes update on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 1000); + [self waitForExpectationsWithTimeout:(1000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000023_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeTargetPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 1U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_2_000024_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeTargetPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 1U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterTest_TC_WNCV_3_3_000000_WaitForCommissionee +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"0: Wait for the commissioned device to be retrieved"]; dispatch_queue_t queue = dispatch_get_main_queue(); WaitForCommissionee(expectation, queue); [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_1_000001_DownOrClose +- (void)testSendClusterTest_TC_WNCV_3_3_000001_DownOrClose { - XCTestExpectation * expectation = [self expectationWithDescription:@"1a: TH adjusts the the DUT to a non-open position"]; + XCTestExpectation * expectation = + [self expectationWithDescription:@"1a: TH sends DownOrClose command to preposition the DUT in the opposite direction"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); @@ -25954,7 +27137,7 @@ - (void)testSendClusterTest_TC_WNCV_3_1_000001_DownOrClose XCTAssertNotNil(cluster); [cluster downOrCloseWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"1a: TH adjusts the the DUT to a non-open position Error: %@", err); + NSLog(@"1a: TH sends DownOrClose command to preposition the DUT in the opposite direction Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); @@ -25963,9 +27146,18 @@ - (void)testSendClusterTest_TC_WNCV_3_1_000001_DownOrClose [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_1_000002_UpOrOpen +- (void)testSendClusterTest_TC_WNCV_3_3_000002_WaitForMs { - XCTestExpectation * expectation = [self expectationWithDescription:@"2a: TH sends UpOrOpen command to DUT"]; + XCTestExpectation * expectation = [self expectationWithDescription:@"1b: TH Waits for 6-8 seconds movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 6000); + [self waitForExpectationsWithTimeout:(6000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000003_UpOrOpen +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); @@ -25973,7 +27165,7 @@ - (void)testSendClusterTest_TC_WNCV_3_1_000002_UpOrOpen XCTAssertNotNil(cluster); [cluster upOrOpenWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"2a: TH sends UpOrOpen command to DUT Error: %@", err); + NSLog(@"1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); @@ -25982,50 +27174,74 @@ - (void)testSendClusterTest_TC_WNCV_3_1_000002_UpOrOpen [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_1_000003_ReadAttribute +- (void)testSendClusterTest_TC_WNCV_3_3_000004_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"1d: TH Waits for 2 seconds movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 2000); + [self waitForExpectationsWithTimeout:(2000 / 1000) + kTimeoutInSeconds handler:nil]; +} +bool testSendClusterTest_TC_WNCV_3_3_000005_WaitForReport_Fulfilled = false; +ResponseHandler test_Test_TC_WNCV_3_3_OperationalStatus_Reported = nil; +- (void)testSendClusterTest_TC_WNCV_3_3_000005_WaitForReport { - XCTestExpectation * expectation = [self expectationWithDescription:@"3a: TH reads OperationalStatus attribute from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; XCTAssertNotNil(cluster); - [cluster readAttributeOperationalStatusWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"3a: TH reads OperationalStatus attribute from DUT Error: %@", err); + test_Test_TC_WNCV_3_3_OperationalStatus_Reported = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Report: 2: Subscribe to DUT reports on OperationalStatus attribute Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - { - id actualValue = value; - XCTAssertEqual([actualValue unsignedCharValue], 0); - } - - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + testSendClusterTest_TC_WNCV_3_3_000005_WaitForReport_Fulfilled = true; + }; } - -- (void)testSendClusterTest_TC_WNCV_3_2_000000_WaitForCommissionee +- (void)testSendClusterTest_TC_WNCV_3_3_000006_SubscribeAttribute { - XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + XCTestExpectation * expectation = + [self expectationWithDescription:@"2: Subscribe to DUT reports on OperationalStatus attribute"]; + CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); - WaitForCommissionee(expectation, queue); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + uint16_t minIntervalArgument = 4U; + uint16_t maxIntervalArgument = 5U; + [cluster subscribeAttributeOperationalStatusWithMinInterval:minIntervalArgument + maxInterval:maxIntervalArgument + subscriptionEstablished:^{ + XCTAssertEqual(testSendClusterTest_TC_WNCV_3_3_000005_WaitForReport_Fulfilled, true); + [expectation fulfill]; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"2: Subscribe to DUT reports on OperationalStatus attribute Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + if (test_Test_TC_WNCV_3_3_OperationalStatus_Reported != nil) { + ResponseHandler callback = test_Test_TC_WNCV_3_3_OperationalStatus_Reported; + test_Test_TC_WNCV_3_3_OperationalStatus_Reported = nil; + callback(value, err); + } + }]; + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_2_000001_UpOrOpen +- (void)testSendClusterTest_TC_WNCV_3_3_000007_StopMotion { - XCTestExpectation * expectation = [self expectationWithDescription:@"1a: TH adjusts the the DUT to a non-closed position"]; + XCTestExpectation * expectation = [self expectationWithDescription:@"2a: TH sends a StopMotion command to DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; XCTAssertNotNil(cluster); - [cluster upOrOpenWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"1a: TH adjusts the the DUT to a non-closed position Error: %@", err); + [cluster stopMotionWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"2a: TH sends a StopMotion command to DUT Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); @@ -26034,28 +27250,52 @@ - (void)testSendClusterTest_TC_WNCV_3_2_000001_UpOrOpen [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_2_000002_DownOrClose +- (void)testSendClusterTest_TC_WNCV_3_3_000008_WaitForMs { - XCTestExpectation * expectation = [self expectationWithDescription:@"2a: TH sends DownOrClose command to DUT"]; + XCTestExpectation * expectation = + [self expectationWithDescription:@"2b: TH waits for 3 seconds the end of inertial movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 3000); + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000009_WaitForReport +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"2c: Verify DUT reports OperationalStatus attribute to TH after a StopMotion"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; XCTAssertNotNil(cluster); - [cluster downOrCloseWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"2a: TH sends DownOrClose command to DUT Error: %@", err); + test_Test_TC_WNCV_3_3_OperationalStatus_Reported = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"2c: Verify DUT reports OperationalStatus attribute to TH after a StopMotion Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + { + id actualValue = value; + XCTAssertEqual([actualValue unsignedCharValue], 0); + } + [expectation fulfill]; - }]; + }; [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_2_000003_ReadAttribute +- (void)testSendClusterTest_TC_WNCV_3_3_000010_WaitForMs +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"2d: TH waits for 100ms - 3s attributes update on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 2000); + [self waitForExpectationsWithTimeout:(2000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000011_ReadAttribute { - XCTestExpectation * expectation = [self expectationWithDescription:@"3a: TH reads OperationalStatus attribute from DUT"]; + XCTestExpectation * expectation = [self expectationWithDescription:@"2e: TH reads OperationalStatus attribute from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); @@ -26063,7 +27303,7 @@ - (void)testSendClusterTest_TC_WNCV_3_2_000003_ReadAttribute XCTAssertNotNil(cluster); [cluster readAttributeOperationalStatusWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"3a: TH reads OperationalStatus attribute from DUT Error: %@", err); + NSLog(@"2e: TH reads OperationalStatus attribute from DUT Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); @@ -26077,74 +27317,149 @@ - (void)testSendClusterTest_TC_WNCV_3_2_000003_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } - -- (void)testSendClusterTest_TC_WNCV_3_3_000000_WaitForCommissionee +NSNumber * _Nullable attrCurrentPositionLift; +- (void)testSendClusterTest_TC_WNCV_3_3_000012_ReadAttribute { - XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + XCTestExpectation * expectation = + [self expectationWithDescription:@"3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT"]; + CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); - WaitForCommissionee(expectation, queue); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + { + id actualValue = value; + attrCurrentPositionLift = actualValue; + } + + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_3_000001_UpOrOpen +- (void)testSendClusterTest_TC_WNCV_3_3_000013_ReadAttribute { - XCTestExpectation * expectation = [self expectationWithDescription:@"1a: TH adjusts the the DUT to a non-open position"]; + XCTestExpectation * expectation = + [self expectationWithDescription:@"3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be " + @"equal with CurrentPositionLiftPercent100ths from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; XCTAssertNotNil(cluster); - [cluster upOrOpenWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"1a: TH adjusts the the DUT to a non-open position Error: %@", err); + [cluster + readAttributeTargetPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with " + @"CurrentPositionLiftPercent100ths from DUT Error: %@", + err); - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - [expectation fulfill]; - }]; + { + id actualValue = value; + if (attrCurrentPositionLift == nil) { + XCTAssertTrue(actualValue == nil); + } else { + XCTAssertFalse(actualValue == nil); + XCTAssertEqualObjects(actualValue, attrCurrentPositionLift); + } + } + + [expectation fulfill]; + }]; [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_3_000002_StopMotion +NSNumber * _Nullable attrCurrentPositionTilt; +- (void)testSendClusterTest_TC_WNCV_3_3_000014_ReadAttribute { - XCTestExpectation * expectation = [self expectationWithDescription:@"2a: TH sends StopMotion command to DUT"]; + XCTestExpectation * expectation = + [self expectationWithDescription:@"4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; XCTAssertNotNil(cluster); - [cluster stopMotionWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"2a: TH sends StopMotion command to DUT Error: %@", err); + [cluster + readAttributeCurrentPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT Error: %@", err); - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - [expectation fulfill]; - }]; + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + { + id actualValue = value; + attrCurrentPositionTilt = actualValue; + } + + [expectation fulfill]; + }]; [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_3_000003_ReadAttribute +- (void)testSendClusterTest_TC_WNCV_3_3_000015_ReadAttribute { - XCTestExpectation * expectation = [self expectationWithDescription:@"2b: TH reads OperationalStatus attribute from DUT"]; + XCTestExpectation * expectation = + [self expectationWithDescription:@"4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be " + @"equal with CurrentPositionTiltPercent100ths from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; XCTAssertNotNil(cluster); - [cluster readAttributeOperationalStatusWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"2b: TH reads OperationalStatus attribute from DUT Error: %@", err); + [cluster + readAttributeTargetPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with " + @"CurrentPositionTiltPercent100ths from DUT Error: %@", + err); - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - { - id actualValue = value; - XCTAssertEqual([actualValue unsignedCharValue], 0); - } + { + id actualValue = value; + if (attrCurrentPositionTilt == nil) { + XCTAssertTrue(actualValue == nil); + } else { + XCTAssertFalse(actualValue == nil); + XCTAssertEqualObjects(actualValue, attrCurrentPositionTilt); + } + } - [expectation fulfill]; - }]; + [expectation fulfill]; + }]; [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } diff --git a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h index fc16faf24ef43d..009b95ce0155cc 100644 --- a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h +++ b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h @@ -367,7 +367,7 @@ /* Endpoint: 1, Cluster: Window Covering (server), big-endian */ \ \ /* 957 - FeatureMap, */ \ - 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x17, \ \ /* Endpoint: 1, Cluster: Pump Configuration and Control (server), big-endian */ \ \ @@ -1042,7 +1042,7 @@ /* Endpoint: 1, Cluster: Window Covering (server), little-endian */ \ \ /* 957 - FeatureMap, */ \ - 0x00, 0x00, 0x00, 0x00, \ + 0x17, 0x00, 0x00, 0x00, \ \ /* Endpoint: 1, Cluster: Pump Configuration and Control (server), little-endian */ \ \ @@ -2470,6 +2470,9 @@ (EmberAfGenericClusterFunction) MatterDoorLockClusterServerAttributeChangedCallback, \ (EmberAfGenericClusterFunction) MatterDoorLockClusterServerPreAttributeChangedCallback, \ }; \ + const EmberAfGenericClusterFunction chipFuncArrayWindowCoveringServer[] = { \ + (EmberAfGenericClusterFunction) MatterWindowCoveringClusterServerAttributeChangedCallback, \ + }; \ const EmberAfGenericClusterFunction chipFuncArrayPumpConfigurationAndControlServer[] = { \ (EmberAfGenericClusterFunction) emberAfPumpConfigurationAndControlClusterServerInitCallback, \ (EmberAfGenericClusterFunction) MatterPumpConfigurationAndControlClusterServerAttributeChangedCallback, \ @@ -3359,8 +3362,8 @@ .attributes = ZAP_ATTRIBUTE_INDEX(334), \ .attributeCount = 20, \ .clusterSize = 35, \ - .mask = ZAP_CLUSTER_MASK(SERVER), \ - .functions = NULL, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ + .functions = chipFuncArrayWindowCoveringServer, \ .clientGeneratedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 152 ) ,\ .serverGeneratedCommandList = nullptr ,\ },\ diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 19b01517b6d475..9fb6d9fc63696e 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -46010,155 +46010,1874 @@ class Test_TC_WNCV_3_1 : public TestCommand switch (mTestIndex++) { case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + ChipLogProgress(chipTool, " ***** Test Step 0 : 0: Wait for the commissioned device to be retrieved\n"); + err = Test0WaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : 1a: TH adjusts the the DUT to a non-open position\n"); - err = Test1aThAdjustsTheTheDutToANonOpenPosition_1(); + ChipLogProgress( + chipTool, + " ***** Test Step 1 : 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); + err = Test1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : 2a: TH sends UpOrOpen command to DUT\n"); - err = Test2aThSendsUpOrOpenCommandToDut_2(); + ChipLogProgress(chipTool, " ***** Test Step 2 : 1b: TH Waits for 10 seconds movement(s) on the device\n"); + err = Test1bThWaitsFor10SecondsMovementsOnTheDevice_2(); break; case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : 3a: TH reads OperationalStatus attribute from DUT\n"); - err = Test3aThReadsOperationalStatusAttributeFromDut_3(); + ChipLogProgress(chipTool, + " ***** Test Step 3 : 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); + break; + case 4: + ChipLogProgress( + chipTool, + " ***** Test Step 4 : 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE")) + { + NextTest(); + return; + } + err = Test1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, + " ***** Test Step 5 : 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = Test1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); + break; + case 6: + ChipLogProgress( + chipTool, + " ***** Test Step 6 : 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL && A_CURRENTPOSITIONTILTPERCENTAGE")) + { + NextTest(); + return; + } + err = Test1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Report: 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = TestReport2SubscribeToDutReportsOnOperationalStatusAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = Test2SubscribeToDutReportsOnOperationalStatusAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : 2a: TH sends UpOrOpen command to DUT\n"); + err = Test2aThSendsUpOrOpenCommandToDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : 2b: DUT updates its attributes\n"); + err = Test2bDutUpdatesItsAttributes_10(); + break; + case 11: + ChipLogProgress(chipTool, + " ***** Test Step 11 : 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : 2e: TH leave the device moving for 2 seconds\n"); + err = Test2eThLeaveTheDeviceMovingFor2Seconds_12(); + break; + case 13: + ChipLogProgress(chipTool, + " ***** Test Step 13 : 3a1: Verify DUT reports OperationalStatus attribute to TH after a UpOrOpen\n"); + err = Test3a1VerifyDutReportsOperationalStatusAttributeToThAfterAUpOrOpen_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : 3a2: DUT updates its attributes\n"); + err = Test3a2DutUpdatesItsAttributes_14(); + break; + case 15: + ChipLogProgress( + chipTool, " ***** Test Step 15 : 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_15(); + break; + case 16: + ChipLogProgress( + chipTool, + " ***** Test Step 16 : 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE")) + { + NextTest(); + return; + } + err = Test3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_16(); + break; + case 17: + ChipLogProgress( + chipTool, " ***** Test Step 17 : 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = Test3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_17(); + break; + case 18: + ChipLogProgress( + chipTool, + " ***** Test Step 18 : 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL && A_CURRENTPOSITIONTILTPERCENTAGE")) + { + NextTest(); + return; + } + err = Test3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : 4a: TH sends a StopMotion command to DUT\n"); + err = Test4aThSendsAStopMotionCommandToDut_19(); + break; + case 20: + ChipLogProgress(chipTool, + " ***** Test Step 20 : 4b: TH waits for 3 seconds the end of inertial movement(s) on the device\n"); + err = Test4bThWaitsFor3SecondsTheEndOfInertialMovementsOnTheDevice_20(); + break; + case 21: + ChipLogProgress(chipTool, + " ***** Test Step 21 : 4c: Verify DUT update OperationalStatus attribute to TH after a StopMotion\n"); + err = Test4cVerifyDutUpdateOperationalStatusAttributeToThAfterAStopMotion_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : 5a: TH waits for x seconds attributes update on the device\n"); + err = Test5aThWaitsForXSecondsAttributesUpdateOnTheDevice_22(); + break; + case 23: + ChipLogProgress(chipTool, + " ***** Test Step 23 : 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_23(); + break; + case 24: + ChipLogProgress(chipTool, + " ***** Test Step 24 : 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = Test5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_24(); break; } - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 25; + + chip::Optional mCluster; + chip::Optional mEndpoint; + + void OnDiscoveryCommandsResults(const DiscoveryCommandResult & nodeData) override + { + bool isExpectedDnssdResult = false; + + VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); + NextTest(); + } + + typedef void (*Test_Test_TC_WNCV_3_1_OperationalStatus_ReportCallback)(void * context, uint8_t value); + Test_Test_TC_WNCV_3_1_OperationalStatus_ReportCallback mTest_Test_TC_WNCV_3_1_OperationalStatus_Reported = nullptr; + + static void OnFailureCallback_3(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_3(error); + } + + static void OnSuccessCallback_3(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_3(currentPositionLiftPercent100ths); + } + + static void OnFailureCallback_4(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_4(error); + } + + static void OnSuccessCallback_4(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercentage) + { + (static_cast(context))->OnSuccessResponse_4(currentPositionLiftPercentage); + } + + static void OnFailureCallback_5(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_5(error); + } + + static void OnSuccessCallback_5(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + (static_cast(context))->OnSuccessResponse_5(currentPositionTiltPercent100ths); + } + + static void OnFailureCallback_6(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_6(error); + } + + static void OnSuccessCallback_6(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercentage) + { + (static_cast(context))->OnSuccessResponse_6(currentPositionTiltPercentage); + } + + static void OnFailureCallback_7(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_7(error); + } + + static void OnSuccessCallback_7(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_7(operationalStatus); + } + + bool mReceivedReport_7 = false; + + static void OnFailureCallback_8(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_8(error); + } + + static void OnSuccessCallback_8(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_8(operationalStatus); + } + + static void OnSubscriptionEstablished_8(void * context) + { + (static_cast(context))->OnSubscriptionEstablishedResponse_8(); + } + + static void OnFailureCallback_11(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_11(error); + } + + static void OnSuccessCallback_11(void * context, + const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_11(targetPositionLiftPercent100ths); + } + + static void OnFailureCallback_13(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_13(error); + } + + static void OnSuccessCallback_13(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_13(operationalStatus); + } + + bool mReceivedReport_13 = false; + + static void OnFailureCallback_15(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_15(error); + } + + static void OnSuccessCallback_15(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_15(currentPositionLiftPercent100ths); + } + + static void OnFailureCallback_16(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_16(error); + } + + static void OnSuccessCallback_16(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercentage) + { + (static_cast(context))->OnSuccessResponse_16(currentPositionLiftPercentage); + } + + static void OnFailureCallback_17(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_17(error); + } + + static void OnSuccessCallback_17(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + (static_cast(context))->OnSuccessResponse_17(currentPositionTiltPercent100ths); + } + + static void OnFailureCallback_18(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_18(error); + } + + static void OnSuccessCallback_18(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercentage) + { + (static_cast(context))->OnSuccessResponse_18(currentPositionTiltPercentage); + } + + static void OnFailureCallback_21(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_21(error); + } + + static void OnSuccessCallback_21(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_21(operationalStatus); + } + + static void OnFailureCallback_23(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_23(error); + } + + static void OnSuccessCallback_23(void * context, + const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_23(targetPositionLiftPercent100ths); + } + + static void OnFailureCallback_24(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_24(error); + } + + static void OnSuccessCallback_24(void * context, + const chip::app::DataModel::Nullable & targetPositionTiltPercent100ths) + { + (static_cast(context))->OnSuccessResponse_24(targetPositionTiltPercent100ths); + } + + // + // Tests methods + // + + CHIP_ERROR Test0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(); + } + + CHIP_ERROR Test1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::WindowCovering::Commands::DownOrClose::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_1(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_1(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_1(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_1() { NextTest(); } + + CHIP_ERROR Test1bThWaitsFor10SecondsMovementsOnTheDevice_2() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(10000); + } + + CHIP_ERROR Test1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_3, OnFailureCallback_3)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_3(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_3(const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("currentPositionLiftPercent100ths", currentPositionLiftPercent100ths, 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", + currentPositionLiftPercent100ths, 10000U)); + NextTest(); + } + + CHIP_ERROR Test1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_4, OnFailureCallback_4)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_4(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_4(const chip::app::DataModel::Nullable & currentPositionLiftPercentage) + { + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "", "uint8")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", currentPositionLiftPercentage, 1)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", currentPositionLiftPercentage, 100)); + NextTest(); + } + + CHIP_ERROR Test1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_5, OnFailureCallback_5)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_5(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_5(const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("currentPositionTiltPercent100ths", currentPositionTiltPercent100ths, 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", + currentPositionTiltPercent100ths, 10000U)); + NextTest(); + } + + CHIP_ERROR Test1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_6, OnFailureCallback_6)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_6(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_6(const chip::app::DataModel::Nullable & currentPositionTiltPercentage) + { + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "", "uint8")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", currentPositionTiltPercentage, 1)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", currentPositionTiltPercentage, 100)); + NextTest(); + } + + CHIP_ERROR TestReport2SubscribeToDutReportsOnOperationalStatusAttribute_7() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + mTest_Test_TC_WNCV_3_1_OperationalStatus_Reported = OnSuccessCallback_7; + return WaitForMs(0); + } + + void OnFailureResponse_7(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_7(uint8_t operationalStatus) + { + mReceivedReport_7 = true; + + VerifyOrReturn(CheckConstraintType("operationalStatus", "", "map8")); + } + + CHIP_ERROR Test2SubscribeToDutReportsOnOperationalStatusAttribute_8() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + uint16_t minIntervalArgument; + minIntervalArgument = 4U; + uint16_t maxIntervalArgument; + maxIntervalArgument = 5U; + + ReturnErrorOnFailure( + cluster.SubscribeAttribute( + this, OnSuccessCallback_8, OnFailureCallback_8, minIntervalArgument, maxIntervalArgument, + OnSubscriptionEstablished_8)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_8(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_8(uint8_t value) + { + if (mTest_Test_TC_WNCV_3_1_OperationalStatus_Reported) + { + auto callback = mTest_Test_TC_WNCV_3_1_OperationalStatus_Reported; + mTest_Test_TC_WNCV_3_1_OperationalStatus_Reported = nullptr; + callback(this, value); + } + } + + void OnSubscriptionEstablishedResponse_8() + { + VerifyOrReturn(mReceivedReport_7, Exit("Initial report not received!")); + NextTest(); + } + + CHIP_ERROR Test2aThSendsUpOrOpenCommandToDut_9() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_9(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_9(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_9(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_9() { NextTest(); } + + CHIP_ERROR Test2bDutUpdatesItsAttributes_10() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(100); + } + + CHIP_ERROR Test2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_11() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_11, OnFailureCallback_11)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_11(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_11(const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + VerifyOrReturn(CheckValueNonNull("targetPositionLiftPercent100ths", targetPositionLiftPercent100ths)); + VerifyOrReturn(CheckValue("targetPositionLiftPercent100ths.Value()", targetPositionLiftPercent100ths.Value(), 0U)); + + NextTest(); + } + + CHIP_ERROR Test2eThLeaveTheDeviceMovingFor2Seconds_12() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(2000); + } + + CHIP_ERROR Test3a1VerifyDutReportsOperationalStatusAttributeToThAfterAUpOrOpen_13() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + mTest_Test_TC_WNCV_3_1_OperationalStatus_Reported = OnSuccessCallback_13; + return CHIP_NO_ERROR; + } + + void OnFailureResponse_13(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_13(uint8_t operationalStatus) + { + mReceivedReport_13 = true; + + VerifyOrReturn(CheckConstraintType("operationalStatus", "", "map8")); + VerifyOrReturn(CheckConstraintMinValue("operationalStatus", operationalStatus, 5)); + VerifyOrReturn(CheckConstraintMaxValue("operationalStatus", operationalStatus, 21)); + NextTest(); + } + + CHIP_ERROR Test3a2DutUpdatesItsAttributes_14() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(2000); + } + + CHIP_ERROR Test3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_15() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_15, OnFailureCallback_15)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_15(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_15(const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("currentPositionLiftPercent100ths", currentPositionLiftPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", + currentPositionLiftPercent100ths, 9999U)); + NextTest(); + } + + CHIP_ERROR Test3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_16() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_16, OnFailureCallback_16)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_16(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_16(const chip::app::DataModel::Nullable & currentPositionLiftPercentage) + { + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "", "uint8")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", currentPositionLiftPercentage, 0)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", currentPositionLiftPercentage, 99)); + NextTest(); + } + + CHIP_ERROR Test3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_17() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_17, OnFailureCallback_17)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_17(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_17(const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("currentPositionTiltPercent100ths", currentPositionTiltPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", + currentPositionTiltPercent100ths, 9999U)); + NextTest(); + } + + CHIP_ERROR Test3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_18() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_18, OnFailureCallback_18)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_18(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_18(const chip::app::DataModel::Nullable & currentPositionTiltPercentage) + { + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "", "uint8")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", currentPositionTiltPercentage, 0)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", currentPositionTiltPercentage, 99)); + NextTest(); + } + + CHIP_ERROR Test4aThSendsAStopMotionCommandToDut_19() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::WindowCovering::Commands::StopMotion::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_19(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_19(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_19(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_19() { NextTest(); } + + CHIP_ERROR Test4bThWaitsFor3SecondsTheEndOfInertialMovementsOnTheDevice_20() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(3000); + } + + CHIP_ERROR Test4cVerifyDutUpdateOperationalStatusAttributeToThAfterAStopMotion_21() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_21, OnFailureCallback_21)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_21(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_21(uint8_t operationalStatus) + { + VerifyOrReturn(CheckValue("operationalStatus", operationalStatus, 0)); + + NextTest(); + } + + CHIP_ERROR Test5aThWaitsForXSecondsAttributesUpdateOnTheDevice_22() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); + } + + CHIP_ERROR Test5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_23() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_23, OnFailureCallback_23)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_23(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_23(const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("targetPositionLiftPercent100ths", targetPositionLiftPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", + targetPositionLiftPercent100ths, 9999U)); + NextTest(); + } + + CHIP_ERROR Test5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_24() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_24, OnFailureCallback_24)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_24(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_24(const chip::app::DataModel::Nullable & targetPositionTiltPercent100ths) + { + VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("targetPositionTiltPercent100ths", targetPositionTiltPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", + targetPositionTiltPercent100ths, 9999U)); + NextTest(); + } +}; + +class Test_TC_WNCV_3_2 : public TestCommand +{ +public: + Test_TC_WNCV_3_2(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("Test_TC_WNCV_3_2", credsIssuerConfig), mTestIndex(0) + { + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + } + + ~Test_TC_WNCV_3_2() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_2\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : 0: Wait for the commissioned device to be retrieved\n"); + err = Test0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress( + chipTool, " ***** Test Step 1 : 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); + err = Test1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : 1b: TH Waits for 10 seconds movement(s) on the device\n"); + err = Test1bThWaitsFor10SecondsMovementsOnTheDevice_2(); + break; + case 3: + ChipLogProgress(chipTool, + " ***** Test Step 3 : 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); + break; + case 4: + ChipLogProgress( + chipTool, + " ***** Test Step 4 : 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE")) + { + NextTest(); + return; + } + err = Test1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, + " ***** Test Step 5 : 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = Test1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); + break; + case 6: + ChipLogProgress( + chipTool, + " ***** Test Step 6 : 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL && A_CURRENTPOSITIONTILTPERCENTAGE")) + { + NextTest(); + return; + } + err = Test1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Report: 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = TestReport2SubscribeToDutReportsOnOperationalStatusAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = Test2SubscribeToDutReportsOnOperationalStatusAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : 2a: TH sends DownOrClose command to DUT\n"); + err = Test2aThSendsDownOrCloseCommandToDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : 2b: DUT updates its attributes\n"); + err = Test2bDutUpdatesItsAttributes_10(); + break; + case 11: + ChipLogProgress(chipTool, + " ***** Test Step 11 : 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : 2e: TH leave the device moving for 2 seconds\n"); + err = Test2eThLeaveTheDeviceMovingFor2Seconds_12(); + break; + case 13: + ChipLogProgress(chipTool, + " ***** Test Step 13 : 3a: Verify DUT reports OperationalStatus attribute to TH after a DownOrClose\n"); + err = Test3aVerifyDutReportsOperationalStatusAttributeToThAfterADownOrClose_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : 3a2: DUT updates its attributes\n"); + err = Test3a2DutUpdatesItsAttributes_14(); + break; + case 15: + ChipLogProgress( + chipTool, " ***** Test Step 15 : 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_15(); + break; + case 16: + ChipLogProgress( + chipTool, + " ***** Test Step 16 : 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE")) + { + NextTest(); + return; + } + err = Test3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_16(); + break; + case 17: + ChipLogProgress( + chipTool, " ***** Test Step 17 : 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = Test3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_17(); + break; + case 18: + ChipLogProgress( + chipTool, + " ***** Test Step 18 : 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL && A_CURRENTPOSITIONTILTPERCENTAGE")) + { + NextTest(); + return; + } + err = Test3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : 4a: TH sends a StopMotion command to DUT\n"); + err = Test4aThSendsAStopMotionCommandToDut_19(); + break; + case 20: + ChipLogProgress(chipTool, + " ***** Test Step 20 : 4b: TH waits for 3 seconds the end of inertial movement(s) on the device\n"); + err = Test4bThWaitsFor3SecondsTheEndOfInertialMovementsOnTheDevice_20(); + break; + case 21: + ChipLogProgress(chipTool, + " ***** Test Step 21 : 4c: Verify DUT update OperationalStatus attribute to TH after a StopMotion\n"); + err = Test4cVerifyDutUpdateOperationalStatusAttributeToThAfterAStopMotion_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : 5a: TH waits for x seconds attributes update on the device\n"); + err = Test5aThWaitsForXSecondsAttributesUpdateOnTheDevice_22(); + break; + case 23: + ChipLogProgress(chipTool, + " ***** Test Step 23 : 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_23(); + break; + case 24: + ChipLogProgress(chipTool, + " ***** Test Step 24 : 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = Test5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_24(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 25; + + chip::Optional mCluster; + chip::Optional mEndpoint; + + void OnDiscoveryCommandsResults(const DiscoveryCommandResult & nodeData) override + { + bool isExpectedDnssdResult = false; + + VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); + NextTest(); + } + + typedef void (*Test_Test_TC_WNCV_3_2_OperationalStatus_ReportCallback)(void * context, uint8_t value); + Test_Test_TC_WNCV_3_2_OperationalStatus_ReportCallback mTest_Test_TC_WNCV_3_2_OperationalStatus_Reported = nullptr; + + static void OnFailureCallback_3(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_3(error); + } + + static void OnSuccessCallback_3(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_3(currentPositionLiftPercent100ths); + } + + static void OnFailureCallback_4(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_4(error); + } + + static void OnSuccessCallback_4(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercentage) + { + (static_cast(context))->OnSuccessResponse_4(currentPositionLiftPercentage); + } + + static void OnFailureCallback_5(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_5(error); + } + + static void OnSuccessCallback_5(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + (static_cast(context))->OnSuccessResponse_5(currentPositionTiltPercent100ths); + } + + static void OnFailureCallback_6(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_6(error); + } + + static void OnSuccessCallback_6(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercentage) + { + (static_cast(context))->OnSuccessResponse_6(currentPositionTiltPercentage); + } + + static void OnFailureCallback_7(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_7(error); + } + + static void OnSuccessCallback_7(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_7(operationalStatus); + } + + bool mReceivedReport_7 = false; + + static void OnFailureCallback_8(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_8(error); + } + + static void OnSuccessCallback_8(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_8(operationalStatus); + } + + static void OnSubscriptionEstablished_8(void * context) + { + (static_cast(context))->OnSubscriptionEstablishedResponse_8(); + } + + static void OnFailureCallback_11(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_11(error); + } + + static void OnSuccessCallback_11(void * context, + const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_11(targetPositionLiftPercent100ths); + } + + static void OnFailureCallback_13(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_13(error); + } + + static void OnSuccessCallback_13(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_13(operationalStatus); + } + + bool mReceivedReport_13 = false; + + static void OnFailureCallback_15(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_15(error); + } + + static void OnSuccessCallback_15(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_15(currentPositionLiftPercent100ths); + } + + static void OnFailureCallback_16(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_16(error); + } + + static void OnSuccessCallback_16(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercentage) + { + (static_cast(context))->OnSuccessResponse_16(currentPositionLiftPercentage); + } + + static void OnFailureCallback_17(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_17(error); + } + + static void OnSuccessCallback_17(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + (static_cast(context))->OnSuccessResponse_17(currentPositionTiltPercent100ths); + } + + static void OnFailureCallback_18(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_18(error); + } + + static void OnSuccessCallback_18(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercentage) + { + (static_cast(context))->OnSuccessResponse_18(currentPositionTiltPercentage); + } + + static void OnFailureCallback_21(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_21(error); + } + + static void OnSuccessCallback_21(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_21(operationalStatus); + } + + static void OnFailureCallback_23(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_23(error); + } + + static void OnSuccessCallback_23(void * context, + const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_23(targetPositionLiftPercent100ths); + } + + static void OnFailureCallback_24(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_24(error); + } + + static void OnSuccessCallback_24(void * context, + const chip::app::DataModel::Nullable & targetPositionTiltPercent100ths) + { + (static_cast(context))->OnSuccessResponse_24(targetPositionTiltPercent100ths); + } + + // + // Tests methods + // + + CHIP_ERROR Test0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(); + } + + CHIP_ERROR Test1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_1(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_1(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_1(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_1() { NextTest(); } + + CHIP_ERROR Test1bThWaitsFor10SecondsMovementsOnTheDevice_2() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(10000); + } + + CHIP_ERROR Test1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_3, OnFailureCallback_3)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_3(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_3(const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("currentPositionLiftPercent100ths", currentPositionLiftPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", + currentPositionLiftPercent100ths, 9999U)); + NextTest(); + } + + CHIP_ERROR Test1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_4, OnFailureCallback_4)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_4(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_4(const chip::app::DataModel::Nullable & currentPositionLiftPercentage) + { + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "", "uint8")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", currentPositionLiftPercentage, 0)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", currentPositionLiftPercentage, 99)); + NextTest(); + } + + CHIP_ERROR Test1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_5, OnFailureCallback_5)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_5(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_5(const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("currentPositionTiltPercent100ths", currentPositionTiltPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", + currentPositionTiltPercent100ths, 9999U)); + NextTest(); + } + + CHIP_ERROR Test1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_6, OnFailureCallback_6)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_6(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_6(const chip::app::DataModel::Nullable & currentPositionTiltPercentage) + { + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "", "uint8")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", currentPositionTiltPercentage, 0)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", currentPositionTiltPercentage, 99)); + NextTest(); + } + + CHIP_ERROR TestReport2SubscribeToDutReportsOnOperationalStatusAttribute_7() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + mTest_Test_TC_WNCV_3_2_OperationalStatus_Reported = OnSuccessCallback_7; + return WaitForMs(0); + } + + void OnFailureResponse_7(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_7(uint8_t operationalStatus) + { + mReceivedReport_7 = true; + + VerifyOrReturn(CheckConstraintType("operationalStatus", "", "map8")); + } + + CHIP_ERROR Test2SubscribeToDutReportsOnOperationalStatusAttribute_8() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + uint16_t minIntervalArgument; + minIntervalArgument = 4U; + uint16_t maxIntervalArgument; + maxIntervalArgument = 5U; + + ReturnErrorOnFailure( + cluster.SubscribeAttribute( + this, OnSuccessCallback_8, OnFailureCallback_8, minIntervalArgument, maxIntervalArgument, + OnSubscriptionEstablished_8)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_8(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_8(uint8_t value) + { + if (mTest_Test_TC_WNCV_3_2_OperationalStatus_Reported) + { + auto callback = mTest_Test_TC_WNCV_3_2_OperationalStatus_Reported; + mTest_Test_TC_WNCV_3_2_OperationalStatus_Reported = nullptr; + callback(this, value); + } + } + + void OnSubscriptionEstablishedResponse_8() + { + VerifyOrReturn(mReceivedReport_7, Exit("Initial report not received!")); + NextTest(); + } + + CHIP_ERROR Test2aThSendsDownOrCloseCommandToDut_9() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::WindowCovering::Commands::DownOrClose::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_9(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_9(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_9(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_9() { NextTest(); } + + CHIP_ERROR Test2bDutUpdatesItsAttributes_10() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(100); + } + + CHIP_ERROR Test2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_11() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_11, OnFailureCallback_11)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_11(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_11(const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + VerifyOrReturn(CheckValueNonNull("targetPositionLiftPercent100ths", targetPositionLiftPercent100ths)); + VerifyOrReturn(CheckValue("targetPositionLiftPercent100ths.Value()", targetPositionLiftPercent100ths.Value(), 10000U)); + + NextTest(); + } + + CHIP_ERROR Test2eThLeaveTheDeviceMovingFor2Seconds_12() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(2000); + } + + CHIP_ERROR Test3aVerifyDutReportsOperationalStatusAttributeToThAfterADownOrClose_13() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + mTest_Test_TC_WNCV_3_2_OperationalStatus_Reported = OnSuccessCallback_13; + return CHIP_NO_ERROR; + } + + void OnFailureResponse_13(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_13(uint8_t operationalStatus) + { + mReceivedReport_13 = true; + + VerifyOrReturn(CheckConstraintType("operationalStatus", "", "map8")); + VerifyOrReturn(CheckConstraintMinValue("operationalStatus", operationalStatus, 10)); + VerifyOrReturn(CheckConstraintMaxValue("operationalStatus", operationalStatus, 42)); + NextTest(); + } + + CHIP_ERROR Test3a2DutUpdatesItsAttributes_14() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(2000); + } + + CHIP_ERROR Test3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_15() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_15, OnFailureCallback_15)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_15(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_15(const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("currentPositionLiftPercent100ths", currentPositionLiftPercent100ths, 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", + currentPositionLiftPercent100ths, 10000U)); + NextTest(); + } + + CHIP_ERROR Test3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_16() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_16, OnFailureCallback_16)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_16(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); } -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; + void OnSuccessResponse_16(const chip::app::DataModel::Nullable & currentPositionLiftPercentage) + { + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "", "uint8")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", currentPositionLiftPercentage, 1)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", currentPositionLiftPercentage, 100)); + NextTest(); + } - chip::Optional mCluster; - chip::Optional mEndpoint; + CHIP_ERROR Test3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_17() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); - void OnDiscoveryCommandsResults(const DiscoveryCommandResult & nodeData) override + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_17, OnFailureCallback_17)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_17(CHIP_ERROR error) { - bool isExpectedDnssdResult = false; + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } - VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); + void OnSuccessResponse_17(const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("currentPositionTiltPercent100ths", currentPositionTiltPercent100ths, 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", + currentPositionTiltPercent100ths, 10000U)); NextTest(); } - static void OnFailureCallback_3(void * context, CHIP_ERROR error) + CHIP_ERROR Test3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_18() { - (static_cast(context))->OnFailureResponse_3(error); + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_18, OnFailureCallback_18)); + return CHIP_NO_ERROR; } - static void OnSuccessCallback_3(void * context, uint8_t operationalStatus) + void OnFailureResponse_18(CHIP_ERROR error) { - (static_cast(context))->OnSuccessResponse_3(operationalStatus); + chip::app::StatusIB status(error); + ThrowFailureResponse(); } - // - // Tests methods - // - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + void OnSuccessResponse_18(const chip::app::DataModel::Nullable & currentPositionTiltPercentage) { - SetIdentity(kIdentityAlpha); - return WaitForCommissionee(); + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "", "uint8")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", currentPositionTiltPercentage, 1)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", currentPositionTiltPercentage, 100)); + NextTest(); } - CHIP_ERROR Test1aThAdjustsTheTheDutToANonOpenPosition_1() + CHIP_ERROR Test4aThSendsAStopMotionCommandToDut_19() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::WindowCovering::Commands::DownOrClose::Type; + using RequestType = chip::app::Clusters::WindowCovering::Commands::StopMotion::Type; RequestType request; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_1(); + (static_cast(context))->OnSuccessResponse_19(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_1(error); + (static_cast(context))->OnFailureResponse_19(error); }; ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_1(CHIP_ERROR error) + void OnFailureResponse_19(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_1() { NextTest(); } + void OnSuccessResponse_19() { NextTest(); } + + CHIP_ERROR Test4bThWaitsFor3SecondsTheEndOfInertialMovementsOnTheDevice_20() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(3000); + } - CHIP_ERROR Test2aThSendsUpOrOpenCommandToDut_2() + CHIP_ERROR Test4cVerifyDutUpdateOperationalStatusAttributeToThAfterAStopMotion_21() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); - RequestType request; + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_21, OnFailureCallback_21)); + return CHIP_NO_ERROR; + } - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_2(); - }; + void OnFailureResponse_21(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_2(error); - }; + void OnSuccessResponse_21(uint8_t operationalStatus) + { + VerifyOrReturn(CheckValue("operationalStatus", operationalStatus, 0)); - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + NextTest(); + } + + CHIP_ERROR Test5aThWaitsForXSecondsAttributesUpdateOnTheDevice_22() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); + } + + CHIP_ERROR Test5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_23() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_23, OnFailureCallback_23)); return CHIP_NO_ERROR; } - void OnFailureResponse_2(CHIP_ERROR error) + void OnFailureResponse_23(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_2() { NextTest(); } + void OnSuccessResponse_23(const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("targetPositionLiftPercent100ths", targetPositionLiftPercent100ths, 1U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", + targetPositionLiftPercent100ths, 10000U)); + NextTest(); + } - CHIP_ERROR Test3aThReadsOperationalStatusAttributeFromDut_3() + CHIP_ERROR Test5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_24() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::WindowCoveringClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); - ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_3, OnFailureCallback_3)); + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_24, OnFailureCallback_24)); return CHIP_NO_ERROR; } - void OnFailureResponse_3(CHIP_ERROR error) + void OnFailureResponse_24(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_3(uint8_t operationalStatus) + void OnSuccessResponse_24(const chip::app::DataModel::Nullable & targetPositionTiltPercent100ths) { - VerifyOrReturn(CheckValue("operationalStatus", operationalStatus, 0)); - + VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "", "uint16")); + VerifyOrReturn( + CheckConstraintMinValue("targetPositionTiltPercent100ths", targetPositionTiltPercent100ths, 1U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", + targetPositionTiltPercent100ths, 10000U)); NextTest(); } }; -class Test_TC_WNCV_3_2 : public TestCommand +class Test_TC_WNCV_3_3 : public TestCommand { public: - Test_TC_WNCV_3_2(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("Test_TC_WNCV_3_2", credsIssuerConfig), mTestIndex(0) + Test_TC_WNCV_3_3(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("Test_TC_WNCV_3_3", credsIssuerConfig), mTestIndex(0) { AddArgument("cluster", &mCluster); AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); } - ~Test_TC_WNCV_3_2() {} + ~Test_TC_WNCV_3_3() {} /////////// TestCommand Interface ///////// void NextTest() override @@ -46167,12 +47886,12 @@ class Test_TC_WNCV_3_2 : public TestCommand if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_2\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_3\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_2\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_3\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -46186,20 +47905,101 @@ class Test_TC_WNCV_3_2 : public TestCommand switch (mTestIndex++) { case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + ChipLogProgress(chipTool, " ***** Test Step 0 : 0: Wait for the commissioned device to be retrieved\n"); + err = Test0WaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : 1a: TH adjusts the the DUT to a non-closed position\n"); - err = Test1aThAdjustsTheTheDutToANonClosedPosition_1(); + ChipLogProgress( + chipTool, + " ***** Test Step 1 : 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); + err = Test1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : 2a: TH sends DownOrClose command to DUT\n"); - err = Test2aThSendsDownOrCloseCommandToDut_2(); + ChipLogProgress(chipTool, " ***** Test Step 2 : 1b: TH Waits for 6-8 seconds movement(s) on the device\n"); + err = Test1bThWaitsFor68SecondsMovementsOnTheDevice_2(); break; case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : 3a: TH reads OperationalStatus attribute from DUT\n"); - err = Test3aThReadsOperationalStatusAttributeFromDut_3(); + ChipLogProgress( + chipTool, " ***** Test Step 3 : 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); + err = Test1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : 1d: TH Waits for 2 seconds movement(s) on the device\n"); + err = Test1dThWaitsFor2SecondsMovementsOnTheDevice_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Report: 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = TestReport2SubscribeToDutReportsOnOperationalStatusAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = Test2SubscribeToDutReportsOnOperationalStatusAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : 2a: TH sends a StopMotion command to DUT\n"); + err = Test2aThSendsAStopMotionCommandToDut_7(); + break; + case 8: + ChipLogProgress(chipTool, + " ***** Test Step 8 : 2b: TH waits for 3 seconds the end of inertial movement(s) on the device\n"); + err = Test2bThWaitsFor3SecondsTheEndOfInertialMovementsOnTheDevice_8(); + break; + case 9: + ChipLogProgress(chipTool, + " ***** Test Step 9 : 2c: Verify DUT reports OperationalStatus attribute to TH after a StopMotion\n"); + err = Test2cVerifyDutReportsOperationalStatusAttributeToThAfterAStopMotion_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : 2d: TH waits for 100ms - 3s attributes update on the device\n"); + err = Test2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : 2e: TH reads OperationalStatus attribute from DUT\n"); + err = Test2eThReadsOperationalStatusAttributeFromDut_11(); + break; + case 12: + ChipLogProgress( + chipTool, " ***** Test Step 12 : 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, + " ***** Test Step 13 : 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must " + "be equal with CurrentPositionLiftPercent100ths from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = + Test3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_13(); + break; + case 14: + ChipLogProgress( + chipTool, " ***** Test Step 14 : 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = Test4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, + " ***** Test Step 15 : 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must " + "be equal with CurrentPositionTiltPercent100ths from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = + Test4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_15(); break; } @@ -46212,52 +48012,141 @@ class Test_TC_WNCV_3_2 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; + const uint16_t mTestCount = 16; chip::Optional mCluster; chip::Optional mEndpoint; + chip::app::DataModel::Nullable attrCurrentPositionLift; + chip::app::DataModel::Nullable attrCurrentPositionTilt; + void OnDiscoveryCommandsResults(const DiscoveryCommandResult & nodeData) override { bool isExpectedDnssdResult = false; - VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); - NextTest(); + VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); + NextTest(); + } + + typedef void (*Test_Test_TC_WNCV_3_3_OperationalStatus_ReportCallback)(void * context, uint8_t value); + Test_Test_TC_WNCV_3_3_OperationalStatus_ReportCallback mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported = nullptr; + + static void OnFailureCallback_5(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_5(error); + } + + static void OnSuccessCallback_5(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_5(operationalStatus); + } + + bool mReceivedReport_5 = false; + + static void OnFailureCallback_6(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_6(error); + } + + static void OnSuccessCallback_6(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_6(operationalStatus); + } + + static void OnSubscriptionEstablished_6(void * context) + { + (static_cast(context))->OnSubscriptionEstablishedResponse_6(); + } + + static void OnFailureCallback_9(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_9(error); + } + + static void OnSuccessCallback_9(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_9(operationalStatus); + } + + bool mReceivedReport_9 = false; + + static void OnFailureCallback_11(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_11(error); + } + + static void OnSuccessCallback_11(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_11(operationalStatus); + } + + static void OnFailureCallback_12(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_12(error); + } + + static void OnSuccessCallback_12(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_12(currentPositionLiftPercent100ths); + } + + static void OnFailureCallback_13(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_13(error); + } + + static void OnSuccessCallback_13(void * context, + const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_13(targetPositionLiftPercent100ths); + } + + static void OnFailureCallback_14(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_14(error); + } + + static void OnSuccessCallback_14(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + (static_cast(context))->OnSuccessResponse_14(currentPositionTiltPercent100ths); } - static void OnFailureCallback_3(void * context, CHIP_ERROR error) + static void OnFailureCallback_15(void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_3(error); + (static_cast(context))->OnFailureResponse_15(error); } - static void OnSuccessCallback_3(void * context, uint8_t operationalStatus) + static void OnSuccessCallback_15(void * context, + const chip::app::DataModel::Nullable & targetPositionTiltPercent100ths) { - (static_cast(context))->OnSuccessResponse_3(operationalStatus); + (static_cast(context))->OnSuccessResponse_15(targetPositionTiltPercent100ths); } // // Tests methods // - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + CHIP_ERROR Test0WaitForTheCommissionedDeviceToBeRetrieved_0() { SetIdentity(kIdentityAlpha); return WaitForCommissionee(); } - CHIP_ERROR Test1aThAdjustsTheTheDutToANonClosedPosition_1() + CHIP_ERROR Test1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type; + using RequestType = chip::app::Clusters::WindowCovering::Commands::DownOrClose::Type; RequestType request; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_1(); + (static_cast(context))->OnSuccessResponse_1(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_1(error); + (static_cast(context))->OnFailureResponse_1(error); }; ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); @@ -46272,229 +48161,318 @@ class Test_TC_WNCV_3_2 : public TestCommand void OnSuccessResponse_1() { NextTest(); } - CHIP_ERROR Test2aThSendsDownOrCloseCommandToDut_2() + CHIP_ERROR Test1bThWaitsFor68SecondsMovementsOnTheDevice_2() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(6000); + } + + CHIP_ERROR Test1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::WindowCovering::Commands::DownOrClose::Type; + using RequestType = chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type; RequestType request; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_2(); + (static_cast(context))->OnSuccessResponse_3(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_2(error); + (static_cast(context))->OnFailureResponse_3(error); }; ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_2(CHIP_ERROR error) + void OnFailureResponse_3(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_2() { NextTest(); } + void OnSuccessResponse_3() { NextTest(); } + + CHIP_ERROR Test1dThWaitsFor2SecondsMovementsOnTheDevice_4() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(2000); + } - CHIP_ERROR Test3aThReadsOperationalStatusAttributeFromDut_3() + CHIP_ERROR TestReport2SubscribeToDutReportsOnOperationalStatusAttribute_5() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::WindowCoveringClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); - ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_3, OnFailureCallback_3)); - return CHIP_NO_ERROR; + mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported = OnSuccessCallback_5; + return WaitForMs(0); } - void OnFailureResponse_3(CHIP_ERROR error) + void OnFailureResponse_5(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_3(uint8_t operationalStatus) + void OnSuccessResponse_5(uint8_t operationalStatus) { - VerifyOrReturn(CheckValue("operationalStatus", operationalStatus, 0)); + mReceivedReport_5 = true; - NextTest(); + VerifyOrReturn(CheckConstraintType("operationalStatus", "", "map8")); } -}; -class Test_TC_WNCV_3_3 : public TestCommand -{ -public: - Test_TC_WNCV_3_3(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("Test_TC_WNCV_3_3", credsIssuerConfig), mTestIndex(0) + CHIP_ERROR Test2SubscribeToDutReportsOnOperationalStatusAttribute_6() { - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); - ~Test_TC_WNCV_3_3() {} + uint16_t minIntervalArgument; + minIntervalArgument = 4U; + uint16_t maxIntervalArgument; + maxIntervalArgument = 5U; - /////////// TestCommand Interface ///////// - void NextTest() override + ReturnErrorOnFailure( + cluster.SubscribeAttribute( + this, OnSuccessCallback_6, OnFailureCallback_6, minIntervalArgument, maxIntervalArgument, + OnSubscriptionEstablished_6)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_6(CHIP_ERROR error) { - CHIP_ERROR err = CHIP_NO_ERROR; + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } - if (0 == mTestIndex) + void OnSuccessResponse_6(uint8_t value) + { + if (mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_3\n"); + auto callback = mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported; + mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported = nullptr; + callback(this, value); } + } - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } + void OnSubscriptionEstablishedResponse_6() + { + VerifyOrReturn(mReceivedReport_5, Exit("Initial report not received!")); + NextTest(); + } - Wait(); + CHIP_ERROR Test2aThSendsAStopMotionCommandToDut_7() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::WindowCovering::Commands::StopMotion::Type; - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) - { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : 1a: TH adjusts the the DUT to a non-open position\n"); - err = Test1aThAdjustsTheTheDutToANonOpenPosition_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : 2a: TH sends StopMotion command to DUT\n"); - err = Test2aThSendsStopMotionCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : 2b: TH reads OperationalStatus attribute from DUT\n"); - err = Test2bThReadsOperationalStatusAttributeFromDut_3(); - break; - } + RequestType request; - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_7(); + }; -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_7(error); + }; - chip::Optional mCluster; - chip::Optional mEndpoint; + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } - void OnDiscoveryCommandsResults(const DiscoveryCommandResult & nodeData) override + void OnFailureResponse_7(CHIP_ERROR error) { - bool isExpectedDnssdResult = false; + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } - VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); - NextTest(); + void OnSuccessResponse_7() { NextTest(); } + + CHIP_ERROR Test2bThWaitsFor3SecondsTheEndOfInertialMovementsOnTheDevice_8() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(3000); } - static void OnFailureCallback_3(void * context, CHIP_ERROR error) + CHIP_ERROR Test2cVerifyDutReportsOperationalStatusAttributeToThAfterAStopMotion_9() { - (static_cast(context))->OnFailureResponse_3(error); + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported = OnSuccessCallback_9; + return CHIP_NO_ERROR; } - static void OnSuccessCallback_3(void * context, uint8_t operationalStatus) + void OnFailureResponse_9(CHIP_ERROR error) { - (static_cast(context))->OnSuccessResponse_3(operationalStatus); + chip::app::StatusIB status(error); + ThrowFailureResponse(); } - // - // Tests methods - // + void OnSuccessResponse_9(uint8_t operationalStatus) + { + mReceivedReport_9 = true; - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + VerifyOrReturn(CheckValue("operationalStatus", operationalStatus, 0)); + + NextTest(); + } + + CHIP_ERROR Test2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_10() { SetIdentity(kIdentityAlpha); - return WaitForCommissionee(); + return WaitForMs(2000); } - CHIP_ERROR Test1aThAdjustsTheTheDutToANonOpenPosition_1() + CHIP_ERROR Test2eThReadsOperationalStatusAttributeFromDut_11() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); - RequestType request; + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_11, OnFailureCallback_11)); + return CHIP_NO_ERROR; + } - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_1(); - }; + void OnFailureResponse_11(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_1(error); - }; + void OnSuccessResponse_11(uint8_t operationalStatus) + { + VerifyOrReturn(CheckValue("operationalStatus", operationalStatus, 0)); - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + NextTest(); + } + + CHIP_ERROR Test3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_12() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_12, OnFailureCallback_12)); return CHIP_NO_ERROR; } - void OnFailureResponse_1(CHIP_ERROR error) + void OnFailureResponse_12(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_1() { NextTest(); } + void OnSuccessResponse_12(const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + VerifyOrReturn( + CheckConstraintMinValue("currentPositionLiftPercent100ths", currentPositionLiftPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", + currentPositionLiftPercent100ths, 10000U)); + attrCurrentPositionLift = currentPositionLiftPercent100ths; + NextTest(); + } - CHIP_ERROR Test2aThSendsStopMotionCommandToDut_2() + CHIP_ERROR + Test3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_13() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::WindowCovering::Commands::StopMotion::Type; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); - RequestType request; + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_13, OnFailureCallback_13)); + return CHIP_NO_ERROR; + } - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_2(); - }; + void OnFailureResponse_13(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_2(error); - }; + void OnSuccessResponse_13(const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + if (attrCurrentPositionLift.IsNull()) + { + VerifyOrReturn(CheckValueNull("targetPositionLiftPercent100ths", targetPositionLiftPercent100ths)); + } + else + { + VerifyOrReturn(CheckValueNonNull("targetPositionLiftPercent100ths", targetPositionLiftPercent100ths)); + VerifyOrReturn(CheckValue("targetPositionLiftPercent100ths.Value()", targetPositionLiftPercent100ths.Value(), + attrCurrentPositionLift.Value())); + } - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + NextTest(); + } + + CHIP_ERROR Test4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_14() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_14, OnFailureCallback_14)); return CHIP_NO_ERROR; } - void OnFailureResponse_2(CHIP_ERROR error) + void OnFailureResponse_14(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_2() { NextTest(); } + void OnSuccessResponse_14(const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + VerifyOrReturn( + CheckConstraintMinValue("currentPositionTiltPercent100ths", currentPositionTiltPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", + currentPositionTiltPercent100ths, 10000U)); + attrCurrentPositionTilt = currentPositionTiltPercent100ths; + NextTest(); + } - CHIP_ERROR Test2bThReadsOperationalStatusAttributeFromDut_3() + CHIP_ERROR + Test4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_15() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::WindowCoveringClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); - ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_3, OnFailureCallback_3)); + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_15, OnFailureCallback_15)); return CHIP_NO_ERROR; } - void OnFailureResponse_3(CHIP_ERROR error) + void OnFailureResponse_15(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_3(uint8_t operationalStatus) + void OnSuccessResponse_15(const chip::app::DataModel::Nullable & targetPositionTiltPercent100ths) { - VerifyOrReturn(CheckValue("operationalStatus", operationalStatus, 0)); + if (attrCurrentPositionTilt.IsNull()) + { + VerifyOrReturn(CheckValueNull("targetPositionTiltPercent100ths", targetPositionTiltPercent100ths)); + } + else + { + VerifyOrReturn(CheckValueNonNull("targetPositionTiltPercent100ths", targetPositionTiltPercent100ths)); + VerifyOrReturn(CheckValue("targetPositionTiltPercent100ths.Value()", targetPositionTiltPercent100ths.Value(), + attrCurrentPositionTilt.Value())); + } NextTest(); } diff --git a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h index 89b3b75b5fb7ea..357c018ce8418d 100644 --- a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h +++ b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h @@ -1491,6 +1491,9 @@ (EmberAfGenericClusterFunction) MatterDoorLockClusterServerAttributeChangedCallback, \ (EmberAfGenericClusterFunction) MatterDoorLockClusterServerPreAttributeChangedCallback, \ }; \ + const EmberAfGenericClusterFunction chipFuncArrayWindowCoveringServer[] = { \ + (EmberAfGenericClusterFunction) MatterWindowCoveringClusterServerAttributeChangedCallback, \ + }; \ const EmberAfGenericClusterFunction chipFuncArrayThermostatServer[] = { \ (EmberAfGenericClusterFunction) emberAfThermostatClusterServerInitCallback, \ }; \ @@ -2102,8 +2105,8 @@ .attributes = ZAP_ATTRIBUTE_INDEX(275), \ .attributeCount = 19, \ .clusterSize = 31, \ - .mask = ZAP_CLUSTER_MASK(SERVER), \ - .functions = NULL, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ + .functions = chipFuncArrayWindowCoveringServer, \ .clientGeneratedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 110 ) ,\ .serverGeneratedCommandList = nullptr ,\ },\ diff --git a/zzz_generated/window-app/zap-generated/endpoint_config.h b/zzz_generated/window-app/zap-generated/endpoint_config.h index 08d648933e6b73..2d2840193f8f7a 100644 --- a/zzz_generated/window-app/zap-generated/endpoint_config.h +++ b/zzz_generated/window-app/zap-generated/endpoint_config.h @@ -275,12 +275,12 @@ /* Endpoint: 1, Cluster: Window Covering (server), big-endian */ \ \ /* 383 - FeatureMap, */ \ - 0x00, 0x00, 0x00, 0x01, \ + 0x00, 0x00, 0x00, 0x17, \ \ /* Endpoint: 2, Cluster: Window Covering (server), big-endian */ \ \ /* 387 - FeatureMap, */ \ - 0x00, 0x00, 0x00, 0x01, \ + 0x00, 0x00, 0x00, 0x17, \ } #else // !BIGENDIAN_CPU @@ -533,12 +533,12 @@ /* Endpoint: 1, Cluster: Window Covering (server), little-endian */ \ \ /* 383 - FeatureMap, */ \ - 0x01, 0x00, 0x00, 0x00, \ + 0x17, 0x00, 0x00, 0x00, \ \ /* Endpoint: 2, Cluster: Window Covering (server), little-endian */ \ \ /* 387 - FeatureMap, */ \ - 0x01, 0x00, 0x00, 0x00, \ + 0x17, 0x00, 0x00, 0x00, \ } #endif // BIGENDIAN_CPU @@ -954,6 +954,9 @@ const EmberAfGenericClusterFunction chipFuncArrayIdentifyServer[] = { \ (EmberAfGenericClusterFunction) emberAfIdentifyClusterServerInitCallback, \ (EmberAfGenericClusterFunction) MatterIdentifyClusterServerAttributeChangedCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayWindowCoveringServer[] = { \ + (EmberAfGenericClusterFunction) MatterWindowCoveringClusterServerAttributeChangedCallback, \ }; // clang-format off @@ -1266,8 +1269,8 @@ .attributes = ZAP_ATTRIBUTE_INDEX(192), \ .attributeCount = 20, \ .clusterSize = 35, \ - .mask = ZAP_CLUSTER_MASK(SERVER), \ - .functions = NULL, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ + .functions = chipFuncArrayWindowCoveringServer, \ .clientGeneratedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 46 ) ,\ .serverGeneratedCommandList = nullptr ,\ },\ @@ -1288,8 +1291,8 @@ .attributes = ZAP_ATTRIBUTE_INDEX(217), \ .attributeCount = 20, \ .clusterSize = 35, \ - .mask = ZAP_CLUSTER_MASK(SERVER), \ - .functions = NULL, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ + .functions = chipFuncArrayWindowCoveringServer, \ .clientGeneratedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 54 ) ,\ .serverGeneratedCommandList = nullptr ,\ },\