Skip to content

Commit

Permalink
[YAML] Add a prompt command to the LogCommands cluster (#11852)
Browse files Browse the repository at this point in the history
* [YAML] Add a prompt command to the LogCommands cluster

* Update generated tests content
  • Loading branch information
vivien-apple authored and pull[bot] committed May 4, 2022
1 parent 38e0bd9 commit 4781319
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
11 changes: 9 additions & 2 deletions examples/chip-tool/commands/tests/TestCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -175,7 +182,7 @@ bool TestCommand::ShouldSkip(const char * expression)
if (shouldSkip)
{
ChipLogProgress(chipTool, " **** Skipping: %s == false\n", expression);
WaitForMs(0);
ContinueOnChipMainThread();
}
return shouldSkip;
}
4 changes: 3 additions & 1 deletion examples/chip-tool/commands/tests/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions examples/placeholder/linux/include/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/app/tests/suites/TestLogCommands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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 ],
};

//
Expand Down
8 changes: 7 additions & 1 deletion zzz_generated/chip-tool/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4781319

Please sign in to comment.