Skip to content
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

Add an Invoke implementation in CodegenDataModel #34220

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/app/codegen-data-model/CodegenDataModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ CHIP_ERROR CodegenDataModel::Invoke(const InteractionModel::InvokeRequest & requ
// TODO: CommandHandlerInterface support is currently
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
// residing in InteractionModelEngine itself. We may want to separate this out
// into its own registry, similar to attributes, so that IM is decoupled from actual storage of things.
//
// Open issue at https://github.com/project-chip/connectedhomeip/issues/34258

// Ember dispatching automatically uses `handler` to set an appropriate result or status
// This never fails (as handler error is encoded as needed).
Expand Down
14 changes: 10 additions & 4 deletions src/app/codegen-data-model/tests/TestCodegenModelViaMocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2437,8 +2437,12 @@ TEST(TestCodegenModelViaMocks, EmberWriteAttributeAccessInterfaceTest)

TEST(TestCodegenModelViaMocks, EmberInvokeTest)
{
// Ember invoke is extrealy hard-coded, so generally we just need to validate that
// correct paths are invoked.
// Ember invoke is fully code-generated - there is a single function for Dispatch
// that will do a `switch` on the path elements and invoke a corresponding `emberAf*`
// callback.
//
// The only thing that can be validated is that this `DispatchSingleClusterCommand`
// is actually invoked.

UseMockNodeConfig config(gTestNodeConfig);
chip::app::CodegenDataModel model;
Expand All @@ -2450,7 +2454,8 @@ TEST(TestCodegenModelViaMocks, EmberInvokeTest)

const uint32_t kDispatchCountPre = chip::Test::DispatchCount();

ASSERT_EQ(model.Invoke(kInvokeRequest, tlvReader, nullptr /* handler, NOT used by impl*/), CHIP_NO_ERROR);
// Using a handler set to nullpotr as it is not used by the impl
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
ASSERT_EQ(model.Invoke(kInvokeRequest, tlvReader, /* handler = */ nullptr), CHIP_NO_ERROR);

EXPECT_EQ(chip::Test::DispatchCount(), kDispatchCountPre + 1); // single dispatch
EXPECT_EQ(chip::Test::GetLastDispatchPath(), kCommandPath); // for the right path
Expand All @@ -2463,7 +2468,8 @@ TEST(TestCodegenModelViaMocks, EmberInvokeTest)

const uint32_t kDispatchCountPre = chip::Test::DispatchCount();

ASSERT_EQ(model.Invoke(kInvokeRequest, tlvReader, nullptr /* handler, NOT used by impl*/), CHIP_NO_ERROR);
// Using a handler set to nullpotr as it is not used by the impl
ASSERT_EQ(model.Invoke(kInvokeRequest, tlvReader, /* handler = */ nullptr), CHIP_NO_ERROR);

EXPECT_EQ(chip::Test::DispatchCount(), kDispatchCountPre + 1); // single dispatch
EXPECT_EQ(chip::Test::GetLastDispatchPath(), kCommandPath); // for the right path
Expand Down
Loading