# Copyright (c) 2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name:
    Window Covering [TC-WNCV-4.1] GoToLiftPercentage command Long-Run
    Verification [DUT as Server]

PICS:
    - WNCV.S

config:
    nodeId: 0x12344321
    cluster: "Window Covering"
    endpoint: 1
    fullMotionDuration:
        type: int16u
        defaultValue: 6000

tests:
    - label: "Step 0: Wait for the commissioned device to be retrieved"
      cluster: "DelayCommands"
      command: "WaitForCommissionee"
      arguments:
          values:
              - name: "nodeId"
                value: nodeId

    ### Step 1x -> Initialize the Covering position before any testing
    ### MANDATORY Init Commands
    - label:
          "Step 1a: TH sends DownOrClose command to preposition the DUT in the
          opposite direction"
      command: "DownOrClose"
      PICS: WNCV.S.C01.Rsp

    ### Step 5x -> Verify the DUT has moved
    ### DUT moves toward its DownOrClose position
    - label: "Step 1b: TH waits for x seconds movement(s) on the DUT"
      cluster: "DelayCommands"
      command: "WaitForMs"
      arguments:
          values:
              - name: "ms"
                value: fullMotionDuration

    ### Depends on the FeatureMap -> Check CurrentPosition attributes
    - label:
          "Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths
          attribute from DUT"
      command: "readAttribute"
      attribute: "CurrentPositionLiftPercent100ths"
      PICS: WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e
      response:
          constraints:
              notValue: 0

    ######## GoToLiftPercentage Long-Run 25 percent #######
    ### Step 2x ->  Check GoToLiftPercentage 25% Long-Run effects
    - label:
          "Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT"
      command: "GoToLiftPercentage"
      PICS: "WNCV.S.F00 && WNCV.S.C05.Rsp"
      arguments:
          values:
              - name: "LiftPercent100thsValue"
                value: 2500

    ### Depends on a sleep/wait command how to do this with a real device for CI keep at 100ms
    - label: "Step 2b: TH waits for 100-1000 ms"
      cluster: "DelayCommands"
      command: "WaitForMs"
      arguments:
          values:
              - name: "ms"
                value: 100

    ### Mandatory Depends on the FeatureMap
    - label:
          "Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths
          attribute from DUT"
      command: "readAttribute"
      attribute: "TargetPositionLiftPercent100ths"
      PICS: WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b
      response:
          value: 2500

    ### Step 3x ->  Verify the DUT has reached its 25%
    ### DUT moves toward its 25% position
    - label: "Step 3a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT"
      cluster: "DelayCommands"
      command: "WaitForMs"
      arguments:
          values:
              - name: "ms"
                value: fullMotionDuration

    ### Check for END OF MOVEMENTs
    - label: "Step 3b: TH checks OperationalStatus attribute from DUT"
      command: "readAttribute"
      attribute: "OperationalStatus"
      PICS: WNCV.S.A000a
      response:
          value: 0

    ### Mandatory Depends on the FeatureMap
    - label:
          "Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths
          attribute from DUT"
      command: "readAttribute"
      attribute: "CurrentPositionLiftPercent100ths"
      PICS: WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e
      response:
          value: 2500

    ### Optional Depends on the FeatureMap
    - label:
          "Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional
          attribute from DUT"
      command: "readAttribute"
      attribute: "CurrentPositionLiftPercentage"
      PICS: WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008
      response:
          value: 25

    ######## GoToLiftPercentage Long-Run for 75.2 percent #######
    ### Step 4x ->  Check GoToLiftPercentage 75.20% Long-Run effects
    - label:
          "Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to
          DUT"
      command: "GoToLiftPercentage"
      PICS: WNCV.S.F00 && WNCV.S.C05.Rsp
      arguments:
          values:
              - name: "LiftPercent100thsValue"
                value: 7520

    ### Depends on a sleep/wait command how to do this with a real device for CI keep at 100ms
    - label: "Step 4b: TH waits for 100-1000 ms"
      cluster: "DelayCommands"
      command: "WaitForMs"
      arguments:
          values:
              - name: "ms"
                value: 100

    ### Mandatory Depends on the FeatureMap
    - label:
          "Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths
          attribute from DUT"
      command: "readAttribute"
      attribute: "TargetPositionLiftPercent100ths"
      PICS: WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b
      response:
          value: 7520

    ### Step 5x ->  Verify the DUT has reached its 75.2%
    ### DUT moves toward its 75.2% position
    - label: "Step 5a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT"
      cluster: "DelayCommands"
      command: "WaitForMs"
      arguments:
          values:
              - name: "ms"
                value: fullMotionDuration

    ### Check for END OF MOVEMENTs
    - label: "Step 5b: TH checks OperationalStatus attribute from DUT"
      command: "readAttribute"
      attribute: "OperationalStatus"
      PICS: WNCV.S.A000a
      response:
          value: 0

    ### Mandatory Depends on the FeatureMap
    - label:
          "Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths
          attribute from DUT"
      command: "readAttribute"
      attribute: "CurrentPositionLiftPercent100ths"
      PICS: WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e
      response:
          value: 7520

    ### Optional Depends on the FeatureMap
    - label:
          "Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional
          attribute from DUT"
      PICS: WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008
      command: "readAttribute"
      attribute: "CurrentPositionLiftPercentage"
      response:
          value: 75
