Skip to content

Commit

Permalink
Pull request project-chip#448: UIC-2765 enabling Cluster Transltor un…
Browse files Browse the repository at this point in the history
…it test

Merge in WMN_TOOLS/matter from bugfix/uic-2765_enabled_cluster_translator_test to silabs

Squashed commit of the following:

commit 0b5d18317d849302e90d83f2d31149c5c61a90be
Author: Dereje Wassie <[email protected]>
Date:   Thu Dec 15 11:01:09 2022 +0100

    UIC-2765 enabling Cluster Transltor unit test
  • Loading branch information
Dereje Wassie authored and jmartinez-silabs committed Jan 24, 2024
1 parent b0e2b5d commit f3f0cb0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ chip_test_suite("tests") {

test_sources = [
"TestClusterInteractor.cpp",
# "TestClusterTranslator.cpp",
"TestClusterTranslator.cpp",
"TestDeviceMapper.cpp",
"TestExample.cpp",
"TestLevelControl.cpp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@ using namespace unify::matter_bridge;
static UnifyEmberInterface ember_interface = UnifyEmberInterface();
static device_translator dev_translator = device_translator();

chip::app::AttributeValueEncoder setupEncoder(chip::EndpointId endpoint, chip::app::ConcreteAttributePath & path,
chip::DataVersion & dataVersion)
{
const chip::app::AttributeValueEncoder::AttributeEncodeState & aState =
chip::app::AttributeValueEncoder::AttributeEncodeState();
chip::app::AttributeReportIBs::Builder builder;
chip::FabricIndex fabricIndex = static_cast<uint8_t>(endpoint);
chip::app::AttributeValueEncoder encoder(builder, fabricIndex, path, dataVersion, true, aState);
uint8_t buf[1024];
chip::TLV::TLVWriter writer;
writer.Init(buf);
chip::TLV::TLVType ignored;
writer.StartContainer(chip::TLV::AnonymousTag(), chip::TLV::kTLVType_Structure, ignored);
builder.Init(&writer, 1);
return encoder;
}

static void TestClusterTranslatorRevision(nlTestSuite * inSuite, void * aContext)
{
Expand All @@ -48,9 +32,25 @@ static void TestClusterTranslatorRevision(nlTestSuite * inSuite, void * aContext
endpoint, chip::app::Clusters::Identify::Id, chip::app::Clusters::Identify::Attributes::ClusterRevision::Id);

chip::DataVersion dataVersion = 0;
chip::app::AttributeValueEncoder encoder = setupEncoder(endpoint, test_attr_path, dataVersion);
const chip::app::AttributeValueEncoder::AttributeEncodeState & aState =
chip::app::AttributeValueEncoder::AttributeEncodeState();
chip::app::AttributeReportIBs::Builder builder;
chip::FabricIndex fabricIndex = static_cast<uint8_t>(endpoint);
chip::app::AttributeValueEncoder encoder(builder, fabricIndex, test_attr_path, dataVersion, true, aState);
uint8_t buf[4096];
chip::TLV::TLVWriter writer;
writer.Init(buf);
chip::TLV::TLVType ignored;
writer.StartContainer(chip::TLV::AnonymousTag(), chip::TLV::kTLVType_Structure, ignored);
builder.Init(&writer, 1);

auto err = test_identify_attribute_handler.Read(test_attr_path, encoder);

NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

writer.Finalize();
writer.EndContainer(ignored);

}

class TestContext
Expand Down

0 comments on commit f3f0cb0

Please sign in to comment.