Skip to content

Commit

Permalink
Update Update src/app/tests/suites/commands/log/LogCommands.*
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed May 4, 2022
1 parent 514065a commit 4e5ae02
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
28 changes: 14 additions & 14 deletions src/app/tests/suites/commands/log/LogCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@
#include "LogCommands.h"
#include <iostream>

CHIP_ERROR LogCommands::Log(const char * message)
CHIP_ERROR LogCommands::Log(const char * identity, const chip::app::Clusters::LogCommands::Commands::Log::Type & value)
{
ChipLogDetail(chipTool, "%s", message);
ChipLogDetail(chipTool, "%.*s", static_cast<int>(value.message.size()), value.message.data());
return ContinueOnChipMainThread(CHIP_NO_ERROR);
}

CHIP_ERROR LogCommands::UserPrompt(const char * message, const char * expectedValue)
CHIP_ERROR LogCommands::UserPrompt(const char * identity,
const chip::app::Clusters::LogCommands::Commands::UserPrompt::Type & value)
{
CHIP_ERROR err = CHIP_NO_ERROR;
std::string line;
ChipLogDetail(chipTool, "USER_PROMPT: %s", message);
if (expectedValue == nullptr)
{
return ContinueOnChipMainThread(err);
}
ChipLogDetail(chipTool, "USER_PROMPT: %.*s", static_cast<int>(value.message.size()), value.message.data());

std::getline(std::cin, line);
if (line != expectedValue)
if (value.expectedValue.HasValue())
{
err = CHIP_ERROR_INVALID_ARGUMENT;
std::string line;
std::getline(std::cin, line);
if (line != value.expectedValue.Value().data())
{
return ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT);
}
}
return ContinueOnChipMainThread(err);

return ContinueOnChipMainThread(CHIP_NO_ERROR);
}
6 changes: 4 additions & 2 deletions src/app/tests/suites/commands/log/LogCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <lib/support/CodeUtils.h>

#include <app-common/zap-generated/tests/simulated-cluster-objects.h>

class LogCommands
{
public:
Expand All @@ -28,6 +30,6 @@ class LogCommands

virtual CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) = 0;

CHIP_ERROR Log(const char * message);
CHIP_ERROR UserPrompt(const char * message, const char * expectedValue = nullptr);
CHIP_ERROR Log(const char * identity, const chip::app::Clusters::LogCommands::Commands::Log::Type & value);
CHIP_ERROR UserPrompt(const char * identity, const chip::app::Clusters::LogCommands::Commands::UserPrompt::Type & value);
};

0 comments on commit 4e5ae02

Please sign in to comment.