diff --git a/examples/chip-tool/commands/tests/TestCommand.cpp b/examples/chip-tool/commands/tests/TestCommand.cpp index be7dc5d6d312ad..d1c17636ce9572 100644 --- a/examples/chip-tool/commands/tests/TestCommand.cpp +++ b/examples/chip-tool/commands/tests/TestCommand.cpp @@ -60,7 +60,14 @@ CHIP_ERROR TestCommand::Wait(chip::System::Clock::Timeout duration) CHIP_ERROR TestCommand::Log(const char * message) { ChipLogDetail(chipTool, "%s", message); - WaitForMs(0); + ReturnErrorOnFailure(ContinueOnChipMainThread()); + return CHIP_NO_ERROR; +} + +CHIP_ERROR TestCommand::UserPrompt(const char * message) +{ + ChipLogDetail(chipTool, "USER_PROMPT: %s", message); + ReturnErrorOnFailure(ContinueOnChipMainThread()); return CHIP_NO_ERROR; } @@ -175,7 +182,7 @@ bool TestCommand::ShouldSkip(const char * expression) if (shouldSkip) { ChipLogProgress(chipTool, " **** Skipping: %s == false\n", expression); - WaitForMs(0); + ContinueOnChipMainThread(); } return shouldSkip; } diff --git a/examples/chip-tool/commands/tests/TestCommand.h b/examples/chip-tool/commands/tests/TestCommand.h index e19d19ed389f3d..b07638fc28eb83 100644 --- a/examples/chip-tool/commands/tests/TestCommand.h +++ b/examples/chip-tool/commands/tests/TestCommand.h @@ -60,7 +60,7 @@ class TestCommand : public CHIPCommand CHIP_ERROR WaitForMs(uint16_t ms) { return Wait(chip::System::Clock::Milliseconds32(ms)); } CHIP_ERROR WaitForCommissionee(); CHIP_ERROR Log(const char * message); - CHIP_ERROR Prompt(const char * message); + CHIP_ERROR UserPrompt(const char * message); protected: ChipDevice * mDevice; @@ -70,6 +70,8 @@ class TestCommand : public CHIPCommand static void OnDeviceConnectionFailureFn(void * context, NodeId deviceId, CHIP_ERROR error); static void OnWaitForMsFn(chip::System::Layer * systemLayer, void * context); + CHIP_ERROR ContinueOnChipMainThread() { return WaitForMs(0); }; + void Exit(std::string message); void ThrowFailureResponse(); void ThrowSuccessResponse(); diff --git a/examples/placeholder/linux/include/TestCommand.h b/examples/placeholder/linux/include/TestCommand.h index 15488f3cc91287..04d1bd9b883fc1 100644 --- a/examples/placeholder/linux/include/TestCommand.h +++ b/examples/placeholder/linux/include/TestCommand.h @@ -51,6 +51,13 @@ class TestCommand return CHIP_NO_ERROR; } + CHIP_ERROR UserPrompt(const char * message) + { + ChipLogProgress(chipTool, "USER_PROMPT: %s", message); + NextTest(); + return CHIP_NO_ERROR; + } + CHIP_ERROR WaitForCommissioning() { isRunning = false; diff --git a/src/app/tests/suites/TestLogCommands.yaml b/src/app/tests/suites/TestLogCommands.yaml index 75dca381822131..fa4acd47c2d12c 100644 --- a/src/app/tests/suites/TestLogCommands.yaml +++ b/src/app/tests/suites/TestLogCommands.yaml @@ -26,3 +26,11 @@ tests: values: - name: "message" value: "This is a simple message" + + - label: "Do a simple user prompt message" + cluster: "LogCommands" + command: "UserPrompt" + arguments: + values: + - name: "message" + value: "This is a simple message" diff --git a/src/app/zap-templates/common/simulated-clusters/TestLogCommands.js b/src/app/zap-templates/common/simulated-clusters/TestLogCommands.js index f90ef284287750..a35de84b1e17ac 100644 --- a/src/app/zap-templates/common/simulated-clusters/TestLogCommands.js +++ b/src/app/zap-templates/common/simulated-clusters/TestLogCommands.js @@ -30,9 +30,15 @@ const Log = { response : { arguments : [] } }; +const UserPrompt = { + name : 'UserPrompt', + arguments : [ { type : 'CHAR_STRING', name : 'message' } ], + response : { arguments : [] } +}; + const LogCommands = { name : 'LogCommands', - commands : [ Log ], + commands : [ Log, UserPrompt ], }; // diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index c729eea617ae69..51dc4188d7e083 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -40260,6 +40260,10 @@ class TestLogCommands : public TestCommand ChipLogProgress(chipTool, " ***** Test Step 0 : Log a simple message\n"); err = TestLogASimpleMessage_0(); break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Do a simple user prompt message\n"); + err = TestDoASimpleUserPromptMessage_1(); + break; } if (CHIP_NO_ERROR != err) @@ -40271,13 +40275,15 @@ class TestLogCommands : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 1; + const uint16_t mTestCount = 2; // // Tests methods // CHIP_ERROR TestLogASimpleMessage_0() { return Log("This is a simple message"); } + + CHIP_ERROR TestDoASimpleUserPromptMessage_1() { return UserPrompt("This is a simple message"); } }; class TestSaveAs : public TestCommand