From d75c469db3c2d610bdc71832d1335a474c88bda8 Mon Sep 17 00:00:00 2001 From: mideayanghui <106149377+mideayanghui@users.noreply.github.com> Date: Sat, 22 Jul 2023 12:12:45 +0800 Subject: [PATCH] [OPSTATE] fix: Transition error in the Paused Command (#28187) * fix:when in a Stopped State, will transition to the Paused State on reception of a Pause command. * Fix CI error in TestRVCOperationalState.yaml * zap regen all for test plan --- .../operational-state-server.cpp | 6 +++++- src/app/tests/suites/TestRVCOperationalState.yaml | 10 +++++----- zzz_generated/chip-tool/zap-generated/test/Commands.h | 10 +++++----- .../zap-generated/test/Commands.h | 10 +++++----- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index b3fd2d89523f00..a91f13d2f257a5 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -113,7 +113,11 @@ void OperationalStateServer::HandlePauseState(HandlerContext & ctx, const Comman VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); uint8_t opState = delegate->GetCurrentOperationalState(); - if (opState != to_underlying(OperationalStateEnum::kPaused)) + if (opState != to_underlying(OperationalStateEnum::kPaused) && opState != to_underlying(OperationalStateEnum::kRunning)) + { + err.Set(to_underlying(ErrorStateEnum::kCommandInvalidInState)); + } + else if (opState != to_underlying(OperationalStateEnum::kPaused)) { delegate->HandlePauseStateCallback(err); } diff --git a/src/app/tests/suites/TestRVCOperationalState.yaml b/src/app/tests/suites/TestRVCOperationalState.yaml index 3a52d89fb7ad00..de40e7f6088be1 100644 --- a/src/app/tests/suites/TestRVCOperationalState.yaml +++ b/src/app/tests/suites/TestRVCOperationalState.yaml @@ -89,26 +89,26 @@ tests: response: values: - name: "CommandResponseState" - value: { ErrorStateID: 0 } + value: { ErrorStateID: 3 } - label: "Read current Operational State" command: "readAttribute" attribute: "OperationalState" response: - value: 2 + value: 0 - label: "Resume Command" command: "Resume" response: values: - name: "CommandResponseState" - value: { ErrorStateID: 0 } + value: { ErrorStateID: 3 } - label: "Read current Operational State" command: "readAttribute" attribute: "OperationalState" response: - value: 1 + value: 0 - label: "Stop Command" command: "Stop" @@ -119,4 +119,4 @@ tests: command: "readAttribute" attribute: "OperationalState" response: - value: 1 + value: 0 diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index cad0d50b715b57..2c0cce594e24a3 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -96662,7 +96662,7 @@ class TestRVCOperationalStateSuite : public TestCommand { chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); + VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 3U)); } break; case 10: @@ -96670,7 +96670,7 @@ class TestRVCOperationalStateSuite : public TestCommand { uint8_t value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState", value, 2U)); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); } break; case 11: @@ -96678,7 +96678,7 @@ class TestRVCOperationalStateSuite : public TestCommand { chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); + VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 3U)); } break; case 12: @@ -96686,7 +96686,7 @@ class TestRVCOperationalStateSuite : public TestCommand { uint8_t value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState", value, 1U)); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); } break; case 13: @@ -96697,7 +96697,7 @@ class TestRVCOperationalStateSuite : public TestCommand { uint8_t value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState", value, 1U)); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); } break; default: diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index fcad5b306ce5ab..2dc568d1ef81d4 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -142893,7 +142893,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = values.commandResponseState; VerifyOrReturn( - CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); } NextTest(); @@ -142918,7 +142918,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 2U)); + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); } NextTest(); @@ -142945,7 +142945,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = values.commandResponseState; VerifyOrReturn( - CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); } NextTest(); @@ -142970,7 +142970,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); } NextTest(); @@ -143017,7 +143017,7 @@ class TestRVCOperationalState : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); } NextTest();