8000 Use EncodableToTLV in TestCommandInteraction by andy31415 · Pull Request #33694 · project-chip/connectedhomeip · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use EncodableToTLV in TestCommandInteraction #33694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions src/app/tests/TestCommandInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ constexpr CommandId kTestCommandIdFillResponseMessage = 7;
constexpr CommandId kTestNonExistCommandId = 0;

const app::CommandSender::TestOnlyMarker kCommandSenderTestOnlyMarker;

class SimpleTLVPayload : public app::DataModel::EncodableToTLV
{
public:
CHIP_ERROR EncodeTo(TLV::TLVWriter & writer, TLV::Tag tag) const override
{
TLV::TLVType outerType;
ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outerType));
ReturnErrorOnFailure(writer.PutBoolean(chip::TLV::ContextTag(1), true));
return writer.EndContainer(outerType);
}
};

} // namespace

namespace app {
Expand Down Expand Up @@ -199,12 +212,8 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aRequestCommandPat
}
else
{
const CommandHandler::InvokeResponseParameters prepareParams(aRequestCommandPath);
const ConcreteCommandPath responseCommandPath = aRequestCommandPath;
apCommandObj->PrepareInvokeResponseCommand(responseCommandPath, prepareParams);
chip::TLV::TLVWriter * writer = apCommandObj->GetCommandDataIBTLVWriter();
writer->PutBoolean(chip::TLV::ContextTag(1), true);
apCommandObj->FinishCommand();
SimpleTLVPayload payloadWriter;
apCommandObj->AddResponse(aRequestCommandPath, aRequestCommandPath.mCommandId, payloadWriter);
}
}

Expand Down Expand Up @@ -597,8 +606,6 @@ void TestCommandInteraction::AddInvalidInvokeRequestData(nlTestSuite * apSuite,
void TestCommandInteraction::AddInvokeResponseData(nlTestSuite * apSuite, void * apContext, CommandHandler * apCommandHandler,
bool aNeedStatusCode, CommandId aResponseCommandId, CommandId aRequestCommandId)
{
CHIP_ERROR err = CHIP_NO_ERROR;

constexpr EndpointId kTestEndpointId = 1;
constexpr ClusterId kTestClusterId = 3;
ConcreteCommandPath requestCommandPath = { kTestEndpointId, kTestClusterId, aRequestCommandId };
Expand All @@ -608,17 +615,8 @@ void TestCommandInteraction::AddInvokeResponseData(nlTestSuite * apSuite, void *
}
else
{
const CommandHandler::InvokeResponseParameters prepareParams(requestCommandPath);
ConcreteCommandPath responseCommandPath = { kTestEndpointId, kTestClusterId, aResponseCommandId };
err = apCommandHandler->PrepareInvokeResponseCommand(responseCommandPath, prepareParams);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

chip::TLV::TLVWriter * writer = apCommandHandler->GetCommandDataIBTLVWriter();

err = writer->PutBoolean(chip::TLV::ContextTag(1), true);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

err = apCommandHandler->FinishCommand();
SimpleTLVPayload payloadWriter;
CHIP_ERROR err = apCommandHandler->AddResponseData(requestCommandPath, aResponseCommandId, payloadWriter);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
}
}
Expand Down
Loading
0