# Copyright (c) 2023 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.
# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default

name: 263.4.1. [TC-DISHM-3.1] On Mode functionality with DUT as Server

PICS:
    - DISHM.S.A0003
    - MOD.S.F00
    - OO.S.C00.Rsp
    - OO.S.C01.Rsp

config:
    nodeId: 0x12344321
    cluster: "Basic Information"
    endpoint: 0

tests:
    - label: "Precondition"
      verification: |
          1 Dishwasher Mode and OnOff clusters are available on the same endpoint

          2 The OnMode attribute is set to a non-NULL value from the mode values indicated by the SupportedModes attribute.

          Read the SupportedModes attribute,  select a value from SupportedModes and save the value as OnMode_value

          ./chip-tool dishwashermode read supported-modes 1 1

          On TH(chip-tool) log, Verify the list of  SupportedModes and below is the sample log provided for the raspi platform:

          [1692170674.471882][3058:3061] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0059 Attribute 0x0000_0000 DataVersion: 2502960191
          [1692170674.472010][3058:3061] CHIP:TOO:   SupportedModes: 3 entries
          [1692170674.472081][3058:3061] CHIP:TOO:     [1]: {
          [1692170674.472110][3058:3061] CHIP:TOO:       Label: Normal
          [1692170674.472135][3058:3061] CHIP:TOO:       Mode: 0
          [1692170674.472163][3058:3061] CHIP:TOO:       ModeTags: 1 entries
          [1692170674.472223][3058:3061] CHIP:TOO:         [1]: {
          [1692170674.472252][3058:3061] CHIP:TOO:           Value: 16384
          [1692170674.472288][3058:3061] CHIP:TOO:          }
          [1692170674.472314][3058:3061] CHIP:TOO:      }
          [1692170674.472385][3058:3061] CHIP:TOO:     [2]: {
          [1692170674.472411][3058:3061] CHIP:TOO:       Label: Heavy
          [1692170674.472435][3058:3061] CHIP:TOO:       Mode: 1
          [1692170674.472475][3058:3061] CHIP:TOO:       ModeTags: 2 entries
          [1692170674.472506][3058:3061] CHIP:TOO:         [1]: {
          [1692170674.472542][3058:3061] CHIP:TOO:           Value: 7
          [1692170674.472567][3058:3061] CHIP:TOO:          }
          [1692170674.472595][3058:3061] CHIP:TOO:         [2]: {
          [1692170674.472632][3058:3061] CHIP:TOO:           Value: 16385
          [1692170674.472658][3058:3061] CHIP:TOO:          }
          [1692170674.472683][3058:3061] CHIP:TOO:      }
          [1692170674.472730][3058:3061] CHIP:TOO:     [3]: {
          [1692170674.472755][3058:3061] CHIP:TOO:       Label: Light
          [1692170674.472778][3058:3061] CHIP:TOO:       Mode: 2
          [1692170674.472820][3058:3061] CHIP:TOO:       ModeTags: 3 entries
          [1692170674.472851][3058:3061] CHIP:TOO:         [1]: {
          [1692170674.472886][3058:3061] CHIP:TOO:           Value: 16386
          [1692170674.472910][3058:3061] CHIP:TOO:          }
          [1692170674.472938][3058:3061] CHIP:TOO:         [2]: {
          [1692170674.472973][3058:3061] CHIP:TOO:           Value: 8
          [1692170674.472996][3058:3061] CHIP:TOO:          }
          [1692170674.473024][3058:3061] CHIP:TOO:         [3]: {
          [1692170674.473048][3058:3061] CHIP:TOO:           Value: 2
          [1692170674.473071][3058:3061] CHIP:TOO:          }
          [1692170674.473095][3058:3061] CHIP:TOO:      }

          Set the OnMode attribute value to OnMode_value

          ./chip-tool dishwashermode write on-mode 0 1 1

          On TH(chip-tool) log, Verify DUT responds with a SUCCESS (value 0x00) status response and below is the sample log provided for the raspi platform:

          [1692170913.264454][3071:3073] CHIP:DMG:                         StatusIB =
          [1692170913.264489][3071:3073] CHIP:DMG:                         {
          [1692170913.264522][3071:3073] CHIP:DMG:                                 status = 0x00 (SUCCESS),
          [1692170913.264557][3071:3073] CHIP:DMG:                         },
      disabled: true

    - label:
          "Step 1: Commission DUT to TH (can be skipped if done in a preceding
          test)."
      verification: |

      disabled: true

    - label: "Step 2: TH reads from the DUT the OnMode attribute."
      PICS: DISHM.S.A0003 && MOD.S.F00
      verification: |
          ./chip-tool dishwashermode read on-mode 1 1

          On TH(chip-tool), Verify that OnMode attribute value is an Integer
          Save the value as on_mode_dut and below is the sample log provided for the raspi platform, here OnMode value is 0

          [1690188734.934221][15978:15980] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0059 Attribute 0x0000_0003 DataVersion: 74242734
          [1690188734.934259][15978:15980] CHIP:TOO:   OnMode: 0
      disabled: true

    - label: "Step 3: TH reads from the DUT the CurrentMode attribute."
      PICS: DISHM.S.A0001 && MOD.S.F00
      verification: |
          ./chip-tool dishwashermode read current-mode 1 1

          On TH(chip-tool), Verify that CurrentMode attribute is an integer.
          Save the value as old_current_mode_dut and below is the sample log provided for the raspi platform, Here CurrentMode value is 0

          NOTE: If startup_mode_dut is equal to old_current_mode_dut proceed to step 4. Else proceed to step 6.

          [1690188747.957507][15982:15984] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0059 Attribute 0x0000_0001 DataVersion: 74242734
          [1690188747.957564][15982:15984] CHIP:TOO:   CurrentMode: 0
      disabled: true

    - label: "Step 4: TH reads from the DUT the SupportedModes attribute."
      PICS: DISHM.S.A0000 && MOD.S.F00
      verification: |
          ./chip-tool dishwashermode read supported-modes 1 1

          On TH(chip-tool) log, Verify DUT response contains a list of ModeOptionsStruct entries
          - Verify that the list has two or more entries
          - Save the Mode field values as supported_modes_dut
          - Select a value from supported_modes_dut different from on_mode_dut. Save the value as new_mode_th, below is the sample log provided for the raspi platform:

          [1690188771.532158][15986:15988] CHIP:DMG: }
          [1690188771.532258][15986:15988] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0059 Attribute 0x0000_0000 DataVersion: 74242734
          [1690188771.532287][15986:15988] CHIP:TOO:   SupportedModes: 3 entries
          [1690188771.532305][15986:15988] CHIP:TOO:     [1]: {
          [1690188771.532309][15986:15988] CHIP:TOO:       Label: Normal
          [1690188771.532316][15986:15988] CHIP:TOO:       Mode: 0
          [1690188771.532321][15986:15988] CHIP:TOO:       ModeTags: 1 entries
          [1690188771.532327][15986:15988] CHIP:TOO:         [1]: {
          [1690188771.532331][15986:15988] CHIP:TOO:           Value: 16384
          [1690188771.532334][15986:15988] CHIP:TOO:          }
          [1690188771.532338][15986:15988] CHIP:TOO:      }
          [1690188771.532345][15986:15988] CHIP:TOO:     [2]: {
          [1690188771.532348][15986:15988] CHIP:TOO:       Label: Heavy
          [1690188771.532352][15986:15988] CHIP:TOO:       Mode: 1
          [1690188771.532358][15986:15988] CHIP:TOO:       ModeTags: 2 entries
          [1690188771.532363][15986:15988] CHIP:TOO:         [1]: {
          [1690188771.532366][15986:15988] CHIP:TOO:           Value: 7
          [1690188771.532368][15986:15988] CHIP:TOO:          }
          [1690188771.532372][15986:15988] CHIP:TOO:         [2]: {
          [1690188771.532374][15986:15988] CHIP:TOO:           Value: 16385
          [1690188771.532376][15986:15988] CHIP:TOO:          }
          [1690188771.532379][15986:15988] CHIP:TOO:      }
          [1690188771.532386][15986:15988] CHIP:TOO:     [3]: {
          [1690188771.532388][15986:15988] CHIP:TOO:       Label: Light
          [1690188771.532390][15986:15988] CHIP:TOO:       Mode: 2
          [1690188771.532395][15986:15988] CHIP:TOO:       ModeTags: 3 entries
          [1690188771.532398][15986:15988] CHIP:TOO:         [1]: {
          [1690188771.532401][15986:15988] CHIP:TOO:           Value: 16386
          [1690188771.532403][15986:15988] CHIP:TOO:          }
          [1690188771.532406][15986:15988] CHIP:TOO:         [2]: {
          [1690188771.532409][15986:15988] CHIP:TOO:           Value: 8
          [1690188771.532411][15986:15988] CHIP:TOO:          }
          [1690188771.532414][15986:15988] CHIP:TOO:         [3]: {
          [1690188771.532417][15986:15988] CHIP:TOO:           Value: 2
          [1690188771.532419][15986:15988] CHIP:TOO:          }
          [1690188771.532421][15986:15988] CHIP:TOO:      }
      disabled: true

    - label:
          "Step 5: TH sends a ChangeToMode command to the DUT with NewMode set
          to new_mode_th"
      PICS: DISHM.S.C00.Rsp && MOD.S.F00
      verification: |
          ./chip-tool dishwashermode change-to-mode 2 1 1

          Verify on TH(chip-tool) log, DUT responds contains a ChangeToModeResponse command with a SUCCESS (value 0x00) status response and below is the sample log provided for the raspi platform:

          [1690198333.074192][17405:17407] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0059 Command 0x0000_0001
          [1690198333.074208][17405:17407] CHIP:TOO:   ChangeToModeResponse: {
          [1690198333.074213][17405:17407] CHIP:TOO:     status: 0
          [1690198333.074216][17405:17407] CHIP:TOO:    }
      disabled: true

    - label: "Step 6: TH sends a Off command to the DUT"
      PICS: OO.S.C00.Rsp && MOD.S.F00
      verification: |
          ./chip-tool onoff off 1 1

          On TH(chip-tool) log, Verify DUT responds with a successful (value 0x00) status response and below is the sample log provided for the raspi platform:

          [1684931101.118659][20709:20711] CHIP:DMG: {
          [1684931101.118663][20709:20711] CHIP:DMG: status = 0x00 (SUCCESS),
          [1684931101.118665][20709:20711] CHIP:DMG: },
      disabled: true

    - label: "Step 7: TH sends a On command to the DUT"
      PICS: OO.S.C01.Rsp && MOD.S.F00
      verification: |
          ./chip-tool onoff on 1 1

          On TH(chip-tool) log, Verify DUT responds with a successful (value 0x00) status response and below is the sample log provided for the raspi platform:

          [1684931217.055517][20729:20731] CHIP:DMG: {
          [1684931217.055520][20729:20731] CHIP:DMG: status = 0x00 (SUCCESS),
          [1684931217.055523][20729:20731] CHIP:DMG: },
      disabled: true

    - label: "Step 8: TH reads from the DUT the CurrentMode attribute."
      PICS: DISHM.S.A0001 && MOD.S.F00
      verification: |
          ./chip-tool dishwashermode read current-mode 1 1

          On TH(chip-tool), Verify that CurrentMode attribute value is an integer value and equal to  on_mode_dut,  below is the sample log provided for the raspi platform, here CurrentMode attribute value is 0

          [1690188859.713934][16004:16006] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0059 Attribute 0x0000_0001 DataVersion: 74242736
          [1690188859.713980][16004:16006] CHIP:TOO:   CurrentMode: 0
      disabled: true
