Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pw_unit_test migration: apps-2 #33734

Closed
wants to merge 10 commits into from
8 changes: 8 additions & 0 deletions src/app/CommandHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
#include <app/MessageDef/InvokeResponseMessage.h>

namespace chip {

namespace Test {

// Forward declaration of CommandHandlerTestAccess class to allow it to be friend with the CommandHandler.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class CommandHandlerTestAccess;
} // namespace Test
namespace app {

class CommandHandler
Expand Down Expand Up @@ -478,6 +485,7 @@ class CommandHandler
private:
friend class TestCommandInteraction;
friend class CommandHandler::Handle;
friend class chip::Test::CommandHandlerTestAccess;

enum class State : uint8_t
{
Expand Down
8 changes: 8 additions & 0 deletions src/app/CommandSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
#define COMMON_STATUS_SUCCESS 0

namespace chip {
namespace Test {

// Forward declaration of CommandSenderTestAccess class to allow it to be friend with CommandSender.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class CommandSenderTestAccess;

} // namespace Test
namespace app {

class CommandSender final : public Messaging::ExchangeDelegate
Expand Down Expand Up @@ -491,6 +498,7 @@ class CommandSender final : public Messaging::ExchangeDelegate

private:
friend class TestCommandInteraction;
friend class chip::Test::CommandSenderTestAccess;

enum class State : uint8_t
{
Expand Down
7 changes: 7 additions & 0 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

namespace chip {
namespace Test {

// Forward declaration of InteractionModelEngineTestAccess class to allow it to be friend with InteractionModelEngine.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class InteractionModelEngineTestAccess;
} // namespace Test
namespace app {

/**
Expand Down Expand Up @@ -416,6 +422,7 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
friend class TestCommandInteraction;
friend class TestInteractionModelEngine;
friend class SubscriptionResumptionSessionEstablisher;
friend class chip::Test::InteractionModelEngineTestAccess;
using Status = Protocols::InteractionModel::Status;

void OnDone(CommandResponseSender & apResponderObj) override;
Expand Down
41 changes: 24 additions & 17 deletions src/app/ReadClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@

#if CHIP_CONFIG_ENABLE_READ_CLIENT
namespace chip {
namespace Test {

// Forward declaration of ReadClientTestAccess class to allow it to be friend with ReadClient.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class ReadClientTestAccess;
} // namespace Test
namespace app {

class InteractionModelEngine;
Expand Down Expand Up @@ -298,6 +304,23 @@ class ReadClient : public Messaging::ExchangeDelegate
kLITICD,
};

enum class ReportType
{
// kUnsolicited reports are the first message in an exchange.
kUnsolicited,
// kContinuingTransaction reports are responses to a message we sent.
kContinuingTransaction
};

enum class ClientState : uint8_t
{
Idle, ///< The client has been initialized and is ready for a SendRequest
AwaitingInitialReport, ///< The client is waiting for initial report
AwaitingSubscribeResponse, ///< The client is waiting for subscribe response
SubscriptionActive, ///< The client is maintaining subscription
InactiveICDSubscription, ///< The client is waiting to resubscribe for LIT device
};

/**
*
* Constructor.
Expand Down Expand Up @@ -503,23 +526,7 @@ class ReadClient : public Messaging::ExchangeDelegate
private:
friend class TestReadInteraction;
friend class InteractionModelEngine;

enum class ClientState : uint8_t
{
Idle, ///< The client has been initialized and is ready for a SendRequest
AwaitingInitialReport, ///< The client is waiting for initial report
AwaitingSubscribeResponse, ///< The client is waiting for subscribe response
SubscriptionActive, ///< The client is maintaining subscription
InactiveICDSubscription, ///< The client is waiting to resubscribe for LIT device
};

enum class ReportType
{
// kUnsolicited reports are the first message in an exchange.
kUnsolicited,
// kContinuingTransaction reports are responses to a message we sent.
kContinuingTransaction
};
friend class chip::Test::ReadClientTestAccess;

bool IsMatchingSubscriptionId(SubscriptionId aSubscriptionId)
{
Expand Down
8 changes: 8 additions & 0 deletions src/app/ReadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
inline constexpr uint16_t kSubscriptionMaxIntervalPublisherLimit = 3600; // seconds (60 minutes)

namespace chip {
namespace Test {

// Forward declaration of ReadHandlerTestAccess class to allow it to be friend with the ReadHandler.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class ReadHandlerTestAccess;

} // namespace Test
namespace app {

//
Expand Down Expand Up @@ -426,6 +433,7 @@ class ReadHandler : public Messaging::ExchangeDelegate
friend class TestReadInteraction;
friend class chip::app::reporting::TestReportingEngine;
friend class chip::app::reporting::TestReportScheduler;
friend class chip::Test::ReadHandlerTestAccess;

//
// The engine needs to be able to Abort/Close a ReadHandler instance upon completion of work for a given read/subscribe
Expand Down
8 changes: 8 additions & 0 deletions src/app/WriteClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
#include <system/TLVPacketBufferBackingStore.h>

namespace chip {
namespace Test {

// Forward declaration of WriteClientTestAccess class to allow it to be friend with the WriteClient.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class WriteClientTestAccess;

} // namespace Test
namespace app {

class InteractionModelEngine;
Expand Down Expand Up @@ -237,6 +244,7 @@ class WriteClient : public Messaging::ExchangeDelegate
private:
friend class TestWriteInteraction;
friend class InteractionModelEngine;
friend class chip::Test::WriteClientTestAccess;

enum class State
{
Expand Down
9 changes: 9 additions & 0 deletions src/app/WriteHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
#include <system/TLVPacketBufferBackingStore.h>

namespace chip {
namespace Test {

// Forward declaration of WriteHandlerTestAccess class to allow it to be friend with the WriteHandler class.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class WriteHandlerTestAccess;

} // namespace Test
namespace app {

class WriteHandler;
Expand Down Expand Up @@ -132,6 +139,8 @@ class WriteHandler : public Messaging::ExchangeDelegate

private:
friend class TestWriteInteraction;
friend class chip::Test::WriteHandlerTestAccess;

enum class State
{
Uninitialized = 0, // The handler has not been initialized
Expand Down
8 changes: 8 additions & 0 deletions src/app/reporting/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
#include <system/TLVPacketBufferBackingStore.h>

namespace chip {
namespace Test {

// Forward declaration of EngineTestAccess class to allow it to be friend with the Engine class.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class EngineTestAccess;

} // namespace Test
namespace app {

class InteractionModelEngine;
Expand Down Expand Up @@ -148,6 +155,7 @@ class Engine

friend class TestReportingEngine;
friend class ::chip::app::TestReadInteraction;
friend class ::chip::Test::EngineTestAccess;

bool IsRunScheduled() const { return mRunScheduled; }

Expand Down
8 changes: 8 additions & 0 deletions src/app/reporting/ReportSchedulerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
#include <app/reporting/ReportScheduler.h>

namespace chip {
namespace Test {

// Forward declaration of ReportSchedulerImplTestAccess class to allow it to be friend with the ReportSchedulerImpl class.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class ReportSchedulerImplTestAccess;

} // namespace Test
namespace app {
namespace reporting {

Expand Down Expand Up @@ -153,6 +160,7 @@ class ReportSchedulerImpl : public ReportScheduler

private:
friend class chip::app::reporting::TestReportScheduler;
friend class chip::Test::ReportSchedulerImplTestAccess;

/**
* @brief Find the next timestamp when a report should be scheduled for a ReadHandler.
Expand Down
9 changes: 9 additions & 0 deletions src/app/reporting/SynchronizedReportSchedulerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
#include <app/reporting/ReportSchedulerImpl.h>

namespace chip {
namespace Test {

// Forward declaration of SynchronizedReportSchedulerImplTestAccess class to allow it to be friend with the
// SynchronizedReportSchedulerImpl class.
// This is not for general API use. It is only to be used for (Unit) Tests to expose private Methods/Members.
class SynchronizedReportSchedulerImplTestAccess;

} // namespace Test
namespace app {
namespace reporting {

Expand Down Expand Up @@ -117,6 +125,7 @@ class SynchronizedReportSchedulerImpl : public ReportSchedulerImpl, public Timer

private:
friend class chip::app::reporting::TestReportScheduler;
friend class chip::Test::SynchronizedReportSchedulerImplTestAccess;

/**
* @brief Find the highest minimum timestamp possible that still respects the lowest max timestamp and sets it as the common
Expand Down
Loading
Loading