Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ if (chip_build_tests) {
"${chip_root}/src/crypto/tests",
"${chip_root}/src/data-model-providers/codedriven/endpoint/tests",
"${chip_root}/src/inet/tests",
"${chip_root}/src/include/platform/tests",
"${chip_root}/src/lib/address_resolve/tests",
"${chip_root}/src/app/server-cluster/tests",
"${chip_root}/src/lib/asn1/tests",
Expand Down
27 changes: 9 additions & 18 deletions src/app/clusters/user-label-server/user-label-cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <app/server/Server.h>
#include <clusters/UserLabel/Metadata.h>

#include <array>

namespace chip::app::Clusters {

using namespace UserLabel;
Expand Down Expand Up @@ -73,19 +75,6 @@ bool IsValidLabelEntry(const Structs::LabelStruct::Type & entry)
return (entry.label.size() <= kMaxLabelSize) && (entry.value.size() <= kMaxValueSize);
}

bool IsValidLabelEntryList(const LabelList::TypeInfo::DecodableType & list)
{
auto iter = list.begin();
while (iter.Next())
{
if (!IsValidLabelEntry(iter.GetValue()))
{
return false;
}
}
return true;
}

CHIP_ERROR WriteLabelList(const ConcreteDataAttributePath & path, AttributeValueDecoder & decoder)
{
DeviceLayer::DeviceInfoProvider * provider = DeviceLayer::GetDeviceInfoProvider();
Expand All @@ -96,20 +85,22 @@ CHIP_ERROR WriteLabelList(const ConcreteDataAttributePath & path, AttributeValue

if (!path.IsListItemOperation())
{
DeviceLayer::AttributeList<Structs::LabelStruct::Type, DeviceLayer::kMaxUserLabelListLength> labelList;
size_t numLabels = 0;
std::array<Structs::LabelStruct::Type, DeviceLayer::kMaxUserLabelListLength> labels;
LabelList::TypeInfo::DecodableType decodablelist;

ReturnErrorOnFailure(decoder.Decode(decodablelist));
VerifyOrReturnError(IsValidLabelEntryList(decodablelist), CHIP_IM_GLOBAL_STATUS(ConstraintError));

auto iter = decodablelist.begin();
while (iter.Next())
{
ReturnErrorOnFailure(labelList.add(iter.GetValue()));
auto & label = iter.GetValue();
VerifyOrReturnError(IsValidLabelEntry(label), CHIP_IM_GLOBAL_STATUS(ConstraintError));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User label cluster is a code driven clusters, so it has testing infrastructure for unit tests.

Could we test this? Codecov says 58.33333% line coverage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least these lines need test coverage:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it's showing those two lines at the top... that helper method is being removed entirely.
The second 4 lines should now be covered, but I'm not sure how/when codecov refreshes or which CI build it's looking at.

VerifyOrReturnError(numLabels < labels.size(), CHIP_ERROR_NO_MEMORY);
labels[numLabels++] = label;
}
ReturnErrorOnFailure(iter.GetStatus());

return provider->SetUserLabelList(endpoint, labelList);
return provider->SetUserLabelList(endpoint, Span(labels.data(), numLabels));
}

if (path.mListOp == ConcreteDataAttributePath::ListOperation::AppendItem)
Expand Down
142 changes: 0 additions & 142 deletions src/include/platform/AttributeList.h

This file was deleted.

4 changes: 2 additions & 2 deletions src/include/platform/DeviceInfoProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <app/util/basic-types.h>
#include <lib/core/CHIPError.h>
#include <lib/core/CHIPPersistentStorageDelegate.h>
#include <platform/AttributeList.h>
#include <lib/support/Span.h>

namespace chip {
namespace DeviceLayer {
Expand Down Expand Up @@ -101,7 +101,7 @@ class DeviceInfoProvider
* @return CHIP_NO_ERROR on success.
* @return CHIP_ERROR if an error occurs.
*/
CHIP_ERROR SetUserLabelList(EndpointId endpoint, const AttributeList<UserLabelType, kMaxUserLabelListLength> & labelList);
CHIP_ERROR SetUserLabelList(EndpointId endpoint, Span<const UserLabelType> labelList);

/**
* @brief Clears the user label list for a specified endpoint.
Expand Down
1 change: 0 additions & 1 deletion src/include/platform/PlatformManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#pragma once

#include <platform/AttributeList.h>
#include <platform/CHIPDeviceConfig.h>
#include <platform/CHIPDeviceEvent.h>
#include <system/PlatformEventSupport.h>
Expand Down
28 changes: 0 additions & 28 deletions src/include/platform/tests/BUILD.gn

This file was deleted.

132 changes: 0 additions & 132 deletions src/include/platform/tests/TestAttributeList.cpp

This file was deleted.

Loading
Loading