Skip to content

Commit bb8668d

Browse files
committed
adding *TestAccess.h sources to build.gn
1 parent d2336f3 commit bb8668d

13 files changed

+87
-79
lines changed

src/app/tests/BUILD.gn

+13
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,19 @@ chip_test_suite("tests") {
175175

176176
cflags = [ "-Wconversion" ]
177177

178+
sources = [
179+
"CommandHandlerTestAccess.h",
180+
"CommandSenderTestAccess.h",
181+
"EngineTestAccess.h",
182+
"InteractionModelEngineTestAccess.h",
183+
"ReadClientTestAccess.h",
184+
"ReadHandlerTestAccess.h",
185+
"ReportSchedulerImplTestAccess.h",
186+
"SynchronizedReportSchedulerImplTestAccess.h",
187+
"WriteClientTestAccess.h",
188+
"WriteHandlerTestAccess.h",
189+
]
190+
178191
public_deps = [
179192
":app-test-stubs",
180193
":binding-test-srcs",

src/app/tests/CommandHandlerTestAccess.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
namespace chip {
2323
namespace Test {
2424

25-
using namespace app;
26-
2725
/**
2826
* @brief Class acts as an accessor to private methods of the CommandHandler class without needing to give friend access to
2927
* each individual test.
@@ -33,9 +31,9 @@ class CommandHandlerTestAccess
3331
{
3432

3533
public:
36-
CommandHandlerTestAccess(CommandHandler * apCommandHandler) : mpCommandHandler(apCommandHandler) {}
37-
InvokeResponseMessage::Builder & GetInvokeResponseBuilder() { return mpCommandHandler->mInvokeResponseBuilder; }
38-
CommandHandlerExchangeInterface * GetmpResponder() { return mpCommandHandler->mpResponder; }
34+
CommandHandlerTestAccess(app::CommandHandler * apCommandHandler) : mpCommandHandler(apCommandHandler) {}
35+
app::InvokeResponseMessage::Builder & GetInvokeResponseBuilder() { return mpCommandHandler->mInvokeResponseBuilder; }
36+
app::CommandHandlerExchangeInterface * GetmpResponder() { return mpCommandHandler->mpResponder; }
3937

4038
void SetReserveSpaceForMoreChunkMessages(bool aReserveSpaceForMoreChunkMessages)
4139
{
@@ -50,7 +48,7 @@ class CommandHandlerTestAccess
5048
}
5149

5250
private:
53-
CommandHandler * mpCommandHandler = nullptr;
51+
app::CommandHandler * mpCommandHandler = nullptr;
5452
};
5553

5654
} // namespace Test

src/app/tests/CommandSenderTestAccess.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
namespace chip {
2323
namespace Test {
2424

25-
using namespace app;
26-
2725
/**
2826
* @brief Class acts as an accessor to private methods of the CommandSender class without needing to give friend access to
2927
* each individual test.
@@ -33,13 +31,13 @@ class CommandSenderTestAccess
3331
{
3432

3533
public:
36-
CommandSenderTestAccess(CommandSender * aCommandSender) : mpCommandSender(aCommandSender) {}
34+
CommandSenderTestAccess(app::CommandSender * aCommandSender) : mpCommandSender(aCommandSender) {}
3735

3836
Messaging::ExchangeHolder & GetExchangeCtx() { return mpCommandSender->mExchangeCtx; }
3937

4038
void FlushNoCommandResponse() { mpCommandSender->FlushNoCommandResponse(); }
4139
void SetFinishedCommandCount(uint16_t aFinishedCommandCount) { mpCommandSender->mFinishedCommandCount = aFinishedCommandCount; }
42-
void MoveToStateAddedCommand() { mpCommandSender->MoveToState(CommandSender::State::AddedCommand); }
40+
void MoveToStateAddedCommand() { mpCommandSender->MoveToState(app::CommandSender::State::AddedCommand); }
4341

4442
CHIP_ERROR Finalize(System::PacketBufferHandle & commandPacket) { return mpCommandSender->Finalize(commandPacket); }
4543
CHIP_ERROR ProcessInvokeResponse(System::PacketBufferHandle && payload, bool & moreChunkedMessages)
@@ -54,7 +52,7 @@ class CommandSenderTestAccess
5452
}
5553

5654
private:
57-
CommandSender * mpCommandSender = nullptr;
55+
app::CommandSender * mpCommandSender = nullptr;
5856
};
5957

6058
} // namespace Test

src/app/tests/EngineTestAccess.h

+8-9
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
namespace chip {
2323
namespace Test {
2424

25-
using namespace app;
26-
2725
/**
2826
* @brief Class acts as an accessor to private methods of the Engine class without needing to give friend access to
2927
* each individual test.
@@ -33,35 +31,36 @@ class EngineTestAccess
3331
{
3432

3533
public:
36-
EngineTestAccess(reporting::Engine * apEngine) : mpEngine(apEngine) {}
34+
EngineTestAccess(app::reporting::Engine * apEngine) : mpEngine(apEngine) {}
3735

38-
reporting::Engine * GetEngine() { return mpEngine; }
36+
app::reporting::Engine * GetEngine() { return mpEngine; }
3937
inline void BumpDirtySetGeneration() { mpEngine->BumpDirtySetGeneration(); }
4038
bool IsRunScheduled() const { return mpEngine->IsRunScheduled(); }
4139

42-
CHIP_ERROR BuildAndSendSingleReportData(ReadHandler * apReadHandler)
40+
CHIP_ERROR BuildAndSendSingleReportData(app::ReadHandler * apReadHandler)
4341
{
4442
return mpEngine->BuildAndSendSingleReportData(apReadHandler);
4543
}
4644

47-
bool MergeOverlappedAttributePath(const AttributePathParams & aAttributePath)
45+
bool MergeOverlappedAttributePath(const app::AttributePathParams & aAttributePath)
4846
{
4947
return mpEngine->MergeOverlappedAttributePath(aAttributePath);
5048
}
5149

52-
CHIP_ERROR InsertPathIntoDirtySet(const AttributePathParams & aAttributePath)
50+
CHIP_ERROR InsertPathIntoDirtySet(const app::AttributePathParams & aAttributePath)
5351
{
5452
return mpEngine->InsertPathIntoDirtySet(aAttributePath);
5553
}
5654

57-
ObjectPool<reporting::Engine::AttributePathParamsWithGeneration, CHIP_IM_SERVER_MAX_NUM_DIRTY_SET, ObjectPoolMem::kInline> &
55+
ObjectPool<app::reporting::Engine::AttributePathParamsWithGeneration, CHIP_IM_SERVER_MAX_NUM_DIRTY_SET,
56+
ObjectPoolMem::kInline> &
5857
GetGlobalDirtySet()
5958
{
6059
return mpEngine->mGlobalDirtySet;
6160
}
6261

6362
private:
64-
reporting::Engine * mpEngine = nullptr;
63+
app::reporting::Engine * mpEngine = nullptr;
6564
};
6665

6766
} // namespace Test

src/app/tests/InteractionModelEngineTestAccess.h

+16-10
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
#pragma once
1919

20+
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
21+
2022
#include <app/InteractionModelEngine.h>
2123

2224
namespace chip {
2325
namespace Test {
2426

25-
using namespace app;
2627
/**
2728
* @brief Class acts as an accessor to private methods of the InteractionModelEngine class without needing to give friend access to
2829
* each individual test.
@@ -32,31 +33,36 @@ class InteractionModelEngineTestAccess
3233
{
3334

3435
public:
35-
InteractionModelEngineTestAccess(InteractionModelEngine * apInteractionModelEngine) :
36+
InteractionModelEngineTestAccess(app::InteractionModelEngine * apInteractionModelEngine) :
3637
mpInteractionModelEngine(apInteractionModelEngine)
3738
{}
38-
uint32_t GetNumOfSubscriptionsToResume() { return mpInteractionModelEngine->mNumOfSubscriptionsToResume; }
39-
uint32_t GetNumSubscriptionResumptionRetries() { return mpInteractionModelEngine->mNumSubscriptionResumptionRetries; }
40-
InteractionModelEngine * GetInstance() { return InteractionModelEngine::GetInstance(); }
4139

42-
void SetNumSubscriptionResumptionRetries(uint32_t aNumSubscriptionResumptionRetries)
40+
int8_t GetNumOfSubscriptionsToResume() { return mpInteractionModelEngine->mNumOfSubscriptionsToResume; }
41+
void SetNumOfSubscriptionsToResume(int8_t aNumOfSubscriptionsToResume)
4342
{
44-
mpInteractionModelEngine->mNumSubscriptionResumptionRetries = aNumSubscriptionResumptionRetries;
43+
mpInteractionModelEngine->mNumOfSubscriptionsToResume = aNumOfSubscriptionsToResume;
4544
}
4645

47-
void SetNumOfSubscriptionsToResume(int8_t aNumOfSubscriptionsToResume)
46+
#if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
47+
48+
uint32_t GetNumSubscriptionResumptionRetries() { return mpInteractionModelEngine->mNumSubscriptionResumptionRetries; }
49+
void SetNumSubscriptionResumptionRetries(uint32_t aNumSubscriptionResumptionRetries)
4850
{
49-
mpInteractionModelEngine->mNumOfSubscriptionsToResume = aNumOfSubscriptionsToResume;
51+
mpInteractionModelEngine->mNumSubscriptionResumptionRetries = aNumSubscriptionResumptionRetries;
5052
}
5153

5254
uint32_t ComputeTimeSecondsTillNextSubscriptionResumption()
5355
{
5456
return mpInteractionModelEngine->ComputeTimeSecondsTillNextSubscriptionResumption();
5557
}
5658

59+
#endif // CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
60+
5761
private:
58-
InteractionModelEngine * mpInteractionModelEngine = nullptr;
62+
app::InteractionModelEngine * mpInteractionModelEngine = nullptr;
5963
};
6064

6165
} // namespace Test
6266
} // namespace chip
67+
68+
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS

src/app/tests/ReadClientTestAccess.h

+8-10
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,17 @@ namespace Test {
2828
* This is not a Global API and should only be used for (Unit) Testing.
2929
*/
3030

31-
using namespace app;
32-
3331
class ReadClientTestAccess
3432
{
3533

3634
public:
37-
ReadClientTestAccess(ReadClient * aReadClient) : mpReadClient(aReadClient) {}
35+
ReadClientTestAccess(app::ReadClient * aReadClient) : mpReadClient(aReadClient) {}
3836

3937
Messaging::ExchangeHolder & GetExchange() { return mpReadClient->mExchange; }
4038
Messaging::ExchangeManager * GetExchangeMgr() { return mpReadClient->mpExchangeMgr; }
4139
SubscriptionId GetSubscriptionId() { return mpReadClient->mSubscriptionId; }
4240

43-
void MoveToState(const ReadClient::ClientState aTargetState) { mpReadClient->MoveToState(aTargetState); }
41+
void MoveToState(const app::ReadClient::ClientState aTargetState) { mpReadClient->MoveToState(aTargetState); }
4442
bool IsIdle() const { return mpReadClient->IsIdle(); }
4543

4644
CHIP_ERROR OnMessageReceived(Messaging::ExchangeContext * apExchangeContext, const PayloadHeader & aPayloadHeader,
@@ -49,29 +47,29 @@ class ReadClientTestAccess
4947
return mpReadClient->OnMessageReceived(apExchangeContext, aPayloadHeader, std::move(aPayload));
5048
}
5149

52-
CHIP_ERROR ProcessReportData(System::PacketBufferHandle && aPayload, ReadClient::ReportType aReportType)
50+
CHIP_ERROR ProcessReportData(System::PacketBufferHandle && aPayload, app::ReadClient::ReportType aReportType)
5351
{
5452
return mpReadClient->ProcessReportData(std::move(aPayload), aReportType);
5553
}
5654

57-
CHIP_ERROR GenerateAttributePaths(AttributePathIBs::Builder & aAttributePathIBsBuilder,
58-
const Span<AttributePathParams> & aAttributePaths)
55+
CHIP_ERROR GenerateAttributePaths(app::AttributePathIBs::Builder & aAttributePathIBsBuilder,
56+
const Span<app::AttributePathParams> & aAttributePaths)
5957
{
6058
return mpReadClient->GenerateAttributePaths(aAttributePathIBsBuilder, aAttributePaths);
6159
}
6260

63-
CHIP_ERROR GenerateEventPaths(EventPathIBs::Builder & aEventPathsBuilder, const Span<EventPathParams> & aEventPaths)
61+
CHIP_ERROR GenerateEventPaths(app::EventPathIBs::Builder & aEventPathsBuilder, const Span<app::EventPathParams> & aEventPaths)
6462
{
6563
return mpReadClient->GenerateEventPaths(aEventPathsBuilder, aEventPaths);
6664
}
6765

68-
CHIP_ERROR SendSubscribeRequest(const ReadPrepareParams & aSubscribePrepareParams)
66+
CHIP_ERROR SendSubscribeRequest(const app::ReadPrepareParams & aSubscribePrepareParams)
6967
{
7068
return mpReadClient->SendSubscribeRequest(aSubscribePrepareParams);
7169
}
7270

7371
private:
74-
ReadClient * mpReadClient = nullptr;
72+
app::ReadClient * mpReadClient = nullptr;
7573
};
7674

7775
} // namespace Test

src/app/tests/ReadHandlerTestAccess.h

+10-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
namespace chip {
2323
namespace Test {
2424

25-
using namespace app;
2625
/**
2726
* @brief Class acts as an accessor to private methods of the ReadHandler class without needing to give friend access to
2827
* each individual test.
@@ -32,24 +31,28 @@ class ReadHandlerTestAccess
3231
{
3332

3433
public:
35-
ReadHandlerTestAccess(ReadHandler * apReadHandler) : mpReadHandler(apReadHandler) {}
34+
ReadHandlerTestAccess(app::ReadHandler * apReadHandler) : mpReadHandler(apReadHandler) {}
3635

3736
Messaging::ExchangeHolder & GetExchangeCtx() { return mpReadHandler->mExchangeCtx; }
38-
ReadHandler * GetReadHandler() { return mpReadHandler; }
37+
app::ReadHandler * GetReadHandler() { return mpReadHandler; }
3938
SessionHolder & GetSessionHandle() { return mpReadHandler->mSessionHandle; }
4039
Transport::SecureSession * GetSession() { return mpReadHandler->GetSession(); }
41-
ReadHandler::Observer * GetObserver() { return mpReadHandler->mObserver; }
40+
app::ReadHandler::Observer * GetObserver() { return mpReadHandler->mObserver; }
41+
42+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
43+
uint16_t GetPublisherSelectedIntervalLimit() { return mpReadHandler->GetPublisherSelectedIntervalLimit(); }
44+
#endif
4245

4346
bool IsDirty() const { return mpReadHandler->IsDirty(); }
4447
bool ShouldStartReporting() const { return mpReadHandler->ShouldStartReporting(); }
4548

4649
void ForceDirtyState() { mpReadHandler->ForceDirtyState(); }
4750
void ClearForceDirtyFlag() { mpReadHandler->ClearForceDirtyFlag(); }
48-
void MoveHandlerToIdleState() { mpReadHandler->MoveToState(ReadHandler::HandlerState::Idle); }
51+
void MoveHandlerToIdleState() { mpReadHandler->MoveToState(app::ReadHandler::HandlerState::Idle); }
4952

5053
void SetStateFlagToActiveSubscription(bool aValue)
5154
{
52-
mpReadHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::ActiveSubscription, aValue);
55+
mpReadHandler->SetStateFlag(app::ReadHandler::ReadHandlerFlags::ActiveSubscription, aValue);
5356
}
5457

5558
void OnInitialRequest(System::PacketBufferHandle && aPayload)
@@ -76,7 +79,7 @@ class ReadHandlerTestAccess
7679
}
7780

7881
private:
79-
ReadHandler * mpReadHandler = nullptr;
82+
app::ReadHandler * mpReadHandler = nullptr;
8083
};
8184

8285
} // namespace Test

src/app/tests/ReportSchedulerImplTestAccess.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,29 @@
2222
namespace chip {
2323
namespace Test {
2424

25-
using namespace app::reporting;
26-
using namespace app;
27-
2825
/**
2926
* @brief Class acts as an accessor to private methods of the ReportSchedulerImpl class without needing to give friend access to
3027
* each individual test.
3128
* This is not a Global API and should only be used for (Unit) Testing.
3229
*/
3330
class ReportSchedulerImplTestAccess
3431
{
32+
3533
public:
36-
ReportSchedulerImplTestAccess(ReportSchedulerImpl * apReportSchedulerImpl) : mpReportSchedulerImpl(apReportSchedulerImpl) {}
34+
ReportSchedulerImplTestAccess(app::reporting::ReportSchedulerImpl * apReportSchedulerImpl) :
35+
mpReportSchedulerImpl(apReportSchedulerImpl)
36+
{}
3737

38-
void CancelReport(ReadHandler * aReadHandler) { mpReportSchedulerImpl->CancelReport(aReadHandler); }
38+
void CancelReport(app::ReadHandler * aReadHandler) { mpReportSchedulerImpl->CancelReport(aReadHandler); }
3939
void UnregisterAllHandlers() { mpReportSchedulerImpl->UnregisterAllHandlers(); }
4040

41-
ReadHandlerNode * FindReadHandlerNode(const ReadHandler * aReadHandler)
41+
app::reporting::ReadHandlerNode * FindReadHandlerNode(const app::ReadHandler * aReadHandler)
4242
{
4343
return mpReportSchedulerImpl->FindReadHandlerNode(aReadHandler);
4444
}
4545

4646
private:
47-
ReportSchedulerImpl * mpReportSchedulerImpl = nullptr;
47+
app::reporting::ReportSchedulerImpl * mpReportSchedulerImpl = nullptr;
4848
};
4949

5050
} // namespace Test

src/app/tests/SynchronizedReportSchedulerImplTestAccess.h

+6-8
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
namespace chip {
2323
namespace Test {
2424

25-
using namespace app::reporting;
26-
using Timestamp = System::Clock::Timestamp;
2725
/**
2826
* @brief Class acts as an accessor to private methods of the SynchronizedReportSchedulerImpl class without needing to give
2927
* friend access to each individual test. This is not a Global API and should only be used for (Unit) Testing.
@@ -32,23 +30,23 @@ class SynchronizedReportSchedulerImplTestAccess
3230
{
3331

3432
public:
35-
SynchronizedReportSchedulerImplTestAccess(SynchronizedReportSchedulerImpl * apSynchronizedReportSchedulerImpl) :
33+
SynchronizedReportSchedulerImplTestAccess(app::reporting::SynchronizedReportSchedulerImpl * apSynchronizedReportSchedulerImpl) :
3634
mpSynchronizedReportSchedulerImpl(apSynchronizedReportSchedulerImpl)
3735
{}
3836

39-
Timestamp & GetNextMinTimestamp() { return mpSynchronizedReportSchedulerImpl->mNextMinTimestamp; }
40-
Timestamp & GetNextMaxTimestamp() { return mpSynchronizedReportSchedulerImpl->mNextMaxTimestamp; }
41-
Timestamp & GetNextReportTimestamp() { return mpSynchronizedReportSchedulerImpl->mNextReportTimestamp; }
37+
System::Clock::Timestamp & GetNextMinTimestamp() { return mpSynchronizedReportSchedulerImpl->mNextMinTimestamp; }
38+
System::Clock::Timestamp & GetNextMaxTimestamp() { return mpSynchronizedReportSchedulerImpl->mNextMaxTimestamp; }
39+
System::Clock::Timestamp & GetNextReportTimestamp() { return mpSynchronizedReportSchedulerImpl->mNextReportTimestamp; }
4240

4341
void UnregisterAllHandlers() { mpSynchronizedReportSchedulerImpl->UnregisterAllHandlers(); }
4442

45-
ReadHandlerNode * FindReadHandlerNode(const ReadHandler * aReadHandler)
43+
app::reporting::ReadHandlerNode * FindReadHandlerNode(const app::ReadHandler * aReadHandler)
4644
{
4745
return mpSynchronizedReportSchedulerImpl->FindReadHandlerNode(aReadHandler);
4846
}
4947

5048
private:
51-
SynchronizedReportSchedulerImpl * mpSynchronizedReportSchedulerImpl = nullptr;
49+
app::reporting::SynchronizedReportSchedulerImpl * mpSynchronizedReportSchedulerImpl = nullptr;
5250
};
5351

5452
} // namespace Test

0 commit comments

Comments
 (0)