Skip to content

Commit

Permalink
Add unit test for EcosystemInformation cluster server implementation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tehampson authored and pull[bot] committed Dec 17, 2024
1 parent d0387e5 commit 1747236
Show file tree
Hide file tree
Showing 4 changed files with 414 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,11 @@ EcosystemLocationStruct::Builder::SetLocationDescriptorLastEdit(uint64_t aLocati
std::unique_ptr<EcosystemLocationStruct> EcosystemLocationStruct::Builder::Build()
{
VerifyOrReturnValue(!mIsAlreadyBuilt, nullptr, ChipLogError(Zcl, "Build() already called"));
VerifyOrReturnValue(!mLocationDescriptor.mLocationName.empty(), nullptr, ChipLogError(Zcl, "Must Provided Location Name"));
VerifyOrReturnValue(mLocationDescriptor.mLocationName.size() <= kLocationDescriptorNameMaxSize, nullptr,
ChipLogError(Zcl, "Must Location Name must be less than 64 bytes"));
VerifyOrReturnValue(!mLocationDescriptor.mLocationName.empty(), nullptr, ChipLogError(Zcl, "Must Provide Location Name"));
static_assert(kLocationDescriptorNameMaxSize <= std::numeric_limits<uint16_t>::max());
VerifyOrReturnValue(
mLocationDescriptor.mLocationName.size() <= kLocationDescriptorNameMaxSize, nullptr,
ChipLogError(Zcl, "Location Name must be less than %u bytes", static_cast<uint16_t>(kLocationDescriptorNameMaxSize)));

// std::make_unique does not have access to private constructor we workaround with using new
std::unique_ptr<EcosystemLocationStruct> ret{ new EcosystemLocationStruct(std::move(mLocationDescriptor),
Expand Down Expand Up @@ -271,6 +273,7 @@ CHIP_ERROR EcosystemInformationServer::AddLocationInfo(EndpointId aEndpoint, con
VerifyOrReturnError(aLocation, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError((aEndpoint != kRootEndpointId && aEndpoint != kInvalidEndpointId), CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(!aLocationId.empty(), CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(aLocationId.size() <= kUniqueLocationIdMaxSize, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(aFabricIndex >= kMinValidFabricIndex, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(aFabricIndex <= kMaxValidFabricIndex, CHIP_ERROR_INVALID_ARGUMENT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <vector>

#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Clusters.h>

#include <app/AttributeAccessInterface.h>

Expand Down
15 changes: 15 additions & 0 deletions src/app/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ source_set("thread-border-router-management-test-srcs") {
]
}

source_set("ecosystem-information-test-srcs") {
sources = [
"${chip_root}/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp",
"${chip_root}/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h",
]
public_deps = [
"${chip_root}/src/app:interaction-model",
"${chip_root}/src/app/common:cluster-objects",
"${chip_root}/src/lib/core",
]
}

source_set("app-test-stubs") {
sources = [
"test-ember-api.cpp",
Expand Down Expand Up @@ -201,6 +213,7 @@ chip_test_suite("tests") {
"TestDataModelSerialization.cpp",
"TestDefaultOTARequestorStorage.cpp",
"TestDefaultThreadNetworkDirectoryStorage.cpp",
"TestEcosystemInformationCluster.cpp",
"TestEventLoggingNoUTCTime.cpp",
"TestEventOverflow.cpp",
"TestEventPathParams.cpp",
Expand Down Expand Up @@ -228,6 +241,7 @@ chip_test_suite("tests") {
public_deps = [
":app-test-stubs",
":binding-test-srcs",
":ecosystem-information-test-srcs",
":operational-state-test-srcs",
":ota-requestor-test-srcs",
":power-cluster-test-srcs",
Expand All @@ -236,6 +250,7 @@ chip_test_suite("tests") {
"${chip_root}/src/app",
"${chip_root}/src/app/codegen-data-model-provider:instance-header",
"${chip_root}/src/app/common:cluster-objects",
"${chip_root}/src/app/data-model-provider/tests:encode-decode",
"${chip_root}/src/app/icd/client:manager",
"${chip_root}/src/app/tests:helpers",
"${chip_root}/src/app/util/mock:mock_codegen_data_model",
Expand Down
Loading

0 comments on commit 1747236

Please sign in to comment.