Skip to content

Commit

Permalink
integrating comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alami-Amine committed May 31, 2024
1 parent 88e479d commit 8c72840
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 75 deletions.
3 changes: 2 additions & 1 deletion src/app/tests/TestAttributePathExpandIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
#include <app/EventManagement.h>
#include <app/util/mock/Constants.h>
#include <lib/core/CHIPCore.h>
#include <lib/core/StringBuilderAdapters.h>
#include <lib/core/TLVDebug.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/DLLUtil.h>
#include <lib/support/LinkedList.h>
#include <lib/support/logging/CHIPLogging.h>

#include <lib/core/StringBuilderAdapters.h>
#include <pw_unit_test/framework.h>

using namespace chip;
Expand Down
6 changes: 0 additions & 6 deletions src/app/tests/TestAttributePersistenceProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
* limitations under the License.
*/

/**
* @file
* This file implements unit tests for AttributePersistenceProvider
*
*/

#include <app-common/zap-generated/cluster-objects.h>
#include <app/DefaultAttributePersistenceProvider.h>
#include <lib/core/StringBuilderAdapters.h>
Expand Down
6 changes: 0 additions & 6 deletions src/app/tests/TestAttributeValueDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
* limitations under the License.
*/

/**
* @file
* This file implements unit tests for AttributeValueDecoder
*
*/

#include <lib/core/StringBuilderAdapters.h>
#include <pw_unit_test/framework.h>

Expand Down
6 changes: 0 additions & 6 deletions src/app/tests/TestAttributeValueEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
* limitations under the License.
*/

/**
* @file
* This file implements unit tests for AttributeValueEncoder
*
*/

#include <optional>

#include <lib/core/StringBuilderAdapters.h>
Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/TestBindingTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

#include <lib/core/StringBuilderAdapters.h>
#include <pw_unit_test/framework.h>

#include <app/util/binding-table.h>
Expand All @@ -29,12 +30,11 @@ namespace {

void VerifyTableSame(BindingTable & table, const std::vector<EmberBindingTableEntry> & expected)
{
EXPECT_EQ(table.Size(), expected.size());
ASSERT_EQ(table.Size(), expected.size());
auto iter1 = table.begin();
auto iter2 = expected.begin();
while (iter2 != expected.end())
{
EXPECT_NE(iter1, table.end());
EXPECT_EQ(*iter1, *iter2);
++iter1;
++iter2;
Expand Down
5 changes: 3 additions & 2 deletions src/app/tests/TestBuilderParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* limitations under the License.
*/

#include <gtest/gtest.h>

#include <app/AppConfig.h>
#include <app/MessageDef/ArrayBuilder.h>
#include <app/MessageDef/ArrayParser.h>
Expand All @@ -29,6 +27,9 @@
#include <lib/support/CHIPMem.h>
#include <system/TLVPacketBufferBackingStore.h>

#include <lib/core/StringBuilderAdapters.h>
#include <pw_unit_test/framework.h>

namespace {

using namespace chip::app;
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestDefaultICDClientStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
*/

#include <lib/core/StringBuilderAdapters.h>
#include <lib/support/Span.h>
#include <lib/support/UnitTestRegistration.h>
#include <pw_unit_test/framework.h>
#include <system/SystemPacketBuffer.h>

Expand Down
11 changes: 3 additions & 8 deletions src/app/tests/TestMessageDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
* limitations under the License.
*/

/**
* @file
* This file implements a test for CHIP Interaction Model Message Def
*
*/

#include <gtest/gtest.h>

#include <app/AppConfig.h>
#include <app/MessageDef/EventFilterIBs.h>
#include <app/MessageDef/EventStatusIB.h>
Expand All @@ -43,6 +35,9 @@
#include <lib/support/logging/Constants.h>
#include <system/TLVPacketBufferBackingStore.h>

#include <lib/core/StringBuilderAdapters.h>
#include <pw_unit_test/framework.h>

namespace {

using namespace chip::app;
Expand Down
3 changes: 2 additions & 1 deletion src/app/tests/TestNullable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include <stdint.h>
#include <string.h>

#include <gtest/gtest.h>
#include <lib/core/StringBuilderAdapters.h>
#include <pw_unit_test/framework.h>

#include <app/data-model/Nullable.h>
#include <lib/support/Span.h>
Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/TestPendingNotificationMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

#include <pw_unit_test/framework.h>

#include <app/clusters/bindings/PendingNotificationMap.h>
#include <app/util/binding-table.h>
#include <app/util/config.h>
#include <lib/core/StringBuilderAdapters.h>
#include <lib/support/TestPersistentStorageDelegate.h>
#include <pw_unit_test/framework.h>

using chip::BindingTable;
using chip::ClusterId;
Expand Down
3 changes: 2 additions & 1 deletion src/app/tests/TestPendingResponseTrackerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <vector>

#include <app/PendingResponseTrackerImpl.h>
#include <lib/core/StringBuilderAdapters.h>
#include <pw_unit_test/framework.h>

namespace {
Expand All @@ -41,7 +42,7 @@ TEST(TestPendingResponseTrackerImpl, TestPendingResponseTracker_FillEntireTracke
for (uint16_t commandRef = 0; commandRef < std::numeric_limits<uint16_t>::max(); commandRef++)
{
EXPECT_EQ(CHIP_NO_ERROR, pendingResponseTracker.Remove(commandRef));
EXPECT_EQ(false, pendingResponseTracker.IsTracked(commandRef));
EXPECT_FALSE(pendingResponseTracker.IsTracked(commandRef));
}
EXPECT_EQ(0u, pendingResponseTracker.Count());
}
Expand Down
18 changes: 8 additions & 10 deletions src/app/tests/TestReadInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ uint8_t gDebugEventBuffer[128];
uint8_t gInfoEventBuffer[128];
uint8_t gCritEventBuffer[128];
chip::app::CircularEventBuffer gCircularEventBuffer[3];
chip::ClusterId kTestClusterId = 6;
chip::ClusterId kTestEventClusterId = chip::Test::MockClusterId(1);
chip::ClusterId kInvalidTestClusterId = 7;
chip::EndpointId kTestEndpointId = 1;
chip::EndpointId kTestEventEndpointId = chip::Test::kMockEndpoint1;
chip::EventId kTestEventIdDebug = chip::Test::MockEventId(1);
chip::EventId kTestEventIdCritical = chip::Test::MockEventId(2);
// uint8_t kTestFieldValue1 = 1;
chip::ClusterId kTestClusterId = 6;
chip::ClusterId kTestEventClusterId = chip::Test::MockClusterId(1);
chip::ClusterId kInvalidTestClusterId = 7;
chip::EndpointId kTestEndpointId = 1;
chip::EndpointId kTestEventEndpointId = chip::Test::kMockEndpoint1;
chip::EventId kTestEventIdDebug = chip::Test::MockEventId(1);
chip::EventId kTestEventIdCritical = chip::Test::MockEventId(2);
chip::TLV::Tag kTestEventTag = chip::TLV::ContextTag(1);
chip::EndpointId kInvalidTestEndpointId = 3;
chip::DataVersion kTestDataVersion1 = 3;
Expand Down Expand Up @@ -1323,8 +1322,7 @@ void TestReadInteraction::TestSetDirtyBetweenChunks(nlTestSuite * apSuite, void
public:
DirtyingMockDelegate(AttributePathParams (&aReadPaths)[2], int & aNumAttributeResponsesWhenSetDirty,
int & aNumArrayItemsWhenSetDirty) :
mReadPaths(aReadPaths),
mNumAttributeResponsesWhenSetDirty(aNumAttributeResponsesWhenSetDirty),
mReadPaths(aReadPaths), mNumAttributeResponsesWhenSetDirty(aNumAttributeResponsesWhenSetDirty),
mNumArrayItemsWhenSetDirty(aNumArrayItemsWhenSetDirty)
{}

Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/TestStatusIB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* limitations under the License.
*/

#include <gtest/gtest.h>

#include <app/AppConfig.h>
#include <app/MessageDef/StatusIB.h>
#include <lib/core/CHIPConfig.h>
#include <lib/core/CHIPError.h>
#include <lib/core/ErrorStr.h>
#include <lib/core/StringBuilderAdapters.h>
#include <lib/support/CHIPMem.h>
#include <protocols/interaction_model/StatusCode.h>
#include <pw_unit_test/framework.h>

namespace {

Expand Down
10 changes: 2 additions & 8 deletions src/app/tests/TestStatusResponseMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,13 @@
* limitations under the License.
*/

/**
* @file
* This file implements a test for CHIP Interaction Model Message Def
*
*/

#include <gtest/gtest.h>
#include <lib/core/StringBuilderAdapters.h>
#include <pw_unit_test/framework.h>

#include <app/AppConfig.h>
#include <app/MessageDef/StatusResponseMessage.h>
#include <lib/core/CHIPError.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/UnitTestRegistration.h>
#include <system/TLVPacketBufferBackingStore.h>

namespace {
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestTimeSyncDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ TEST_F(TestTimeSyncDataProvider, TestDSTOffsetEmpty)
TimeSyncDataProvider::DSTOffsetObj dstObj;

EXPECT_EQ(CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND, timeSyncDataProv.LoadDSTOffset(dstObj));
EXPECT_FALSE(dstObj.dstOffsetList.begin());
EXPECT_TRUE(dstObj.dstOffsetList.empty());
EXPECT_EQ(dstObj.validSize, 0u);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/test-ember-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

chip::EndpointId chip::Test::numEndpoints = 0;

// was previously in TestPowerSourceCluster.cpp
// Used by the code in TestPowerSourceCluster.cpp (and generally things using mock ember functions may need this).
uint16_t emberAfGetClusterServerEndpointIndex(chip::EndpointId endpoint, chip::ClusterId cluster,
uint16_t fixedClusterServerEndpointCount)
{
Expand Down
5 changes: 2 additions & 3 deletions src/app/tests/test-ember-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
*/
#include <app/util/basic-types.h>

/// test-ember-api was created to consolidate and centralize stub functions that are related to ember and are run for unit-tests
/// These were previously defined in the unit test-scripts themselves.
/// test-ember-api was created to consolidate and centralize stub functions that are related to ember and are used by the unit-tests

namespace chip {
namespace Test {
extern chip::EndpointId numEndpoints;
}
} // namespace chip

// was previously in TestPowerSourceCluster.cpp
// Used by the code in TestPowerSourceCluster.cpp (and generally things using mock ember functions may need this).
uint16_t emberAfGetClusterServerEndpointIndex(chip::EndpointId endpoint, chip::ClusterId cluster,
uint16_t fixedClusterServerEndpointCount);
21 changes: 8 additions & 13 deletions src/app/tests/test-interaction-model-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ size_t Test::attributeDataTLVLen = 0;

namespace app {

// was previously in TestWriteInteraction.cpp
// Used by the code in TestWriteInteraction.cpp (and generally tests that interact with the WriteHandler may need this).
const EmberAfAttributeMetadata * GetAttributeMetadata(const ConcreteAttributePath & aConcreteClusterPath)
{
// Note: This test does not make use of the real attribute metadata.
static EmberAfAttributeMetadata stub = { .defaultValue = EmberAfDefaultOrMinMaxAttributeValue(uint32_t(0)) };
return &stub;
}

// was previously in TestWriteInteraction.cpp
// Used by the code in TestWriteInteraction.cpp (and generally tests that interact with the WriteHandler may need this).
CHIP_ERROR WriteSingleClusterData(const Access::SubjectDescriptor & aSubjectDescriptor, const ConcreteDataAttributePath & aPath,
TLV::TLVReader & aReader, WriteHandler * aWriteHandler)
{
Expand All @@ -56,13 +56,13 @@ CHIP_ERROR WriteSingleClusterData(const Access::SubjectDescriptor & aSubjectDesc
return aWriteHandler->AddStatus(aPath, Protocols::InteractionModel::Status::Success);
}

// was previously in TestAclAttribute.cpp
// Used by the code in TestAclAttribute.cpp (and generally tests that interact with the InteractionModelEngine may need this).
bool ConcreteAttributePathExists(const ConcreteAttributePath & aPath)
{
return aPath.mClusterId != Test::kTestDeniedClusterId1;
}

// was previously in TestAclAttribute.cpp
// Used by the code in TestAclAttribute.cpp (and generally tests that interact with the InteractionModelEngine may need this).
Protocols::InteractionModel::Status CheckEventSupportStatus(const ConcreteEventPath & aPath)
{
if (aPath.mClusterId == Test::kTestDeniedClusterId1)
Expand All @@ -88,24 +88,19 @@ __attribute__((weak)) void DispatchSingleClusterCommand(const ConcreteCommandPat
chip::TLV::TLVReader & aReader, CommandHandler * apCommandObj)
{}

// was previously in TestReadInteraction.cpp
// Used by the code in TestReadInteraction.cpp (and generally tests that interact with the Reporting Engine may need this).
bool IsClusterDataVersionEqual(const ConcreteClusterPath & aConcreteClusterPath, DataVersion aRequiredVersion)
{
if (Test::kTestDataVersion1 == aRequiredVersion)
{
return true;
}

return false;
return (Test::kTestDataVersion1 == aRequiredVersion);
}

// was previously in TestReadInteraction.cpp
// Used by the code in TestReadInteraction.cpp.
bool IsDeviceTypeOnEndpoint(DeviceTypeId deviceType, EndpointId endpoint)
{
return false;
}

// was previously in TestReadInteraction.cpp
// Used by the code in TestReadInteraction.cpp (and generally tests that interact with the Reporting Engine may need this).
CHIP_ERROR ReadSingleClusterData(const Access::SubjectDescriptor & aSubjectDescriptor, bool aIsFabricFiltered,
const ConcreteReadAttributePath & aPath, AttributeReportIBs::Builder & aAttributeReports,
AttributeEncodeState * apEncoderState)
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/test-interaction-model-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#pragma once

/// test-interaction-model-api was created to consolidate and centralize stub functions that are used by the Interaction Model
/// during unit-testing and that were previously defined in the unit test-scripts themselves.
/// during unit-testing.

#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
Expand Down

0 comments on commit 8c72840

Please sign in to comment.