15
15
* See the License for the specific language governing permissions and
16
16
* limitations under the License.
17
17
*/
18
- #include < app/EventManagement.h>
19
18
#include < app/SubscriptionsInfoProvider.h>
20
19
#include < app/TestEventTriggerDelegate.h>
21
20
#include < app/icd/server/ICDConfigurationData.h>
22
21
#include < app/icd/server/ICDManager.h>
22
+ #include < app/icd/server/ICDMonitoringTable.h>
23
23
#include < app/icd/server/ICDNotifier.h>
24
24
#include < app/icd/server/ICDStateObserver.h>
25
- #include < app/tests/AppTestContext .h>
25
+ #include < crypto/DefaultSessionKeystore .h>
26
26
#include < lib/core/DataModelTypes.h>
27
27
#include < lib/core/NodeId.h>
28
28
#include < lib/support/TestPersistentStorageDelegate.h>
29
29
#include < lib/support/TimeUtils.h>
30
30
#include < lib/support/UnitTestContext.h>
31
31
#include < lib/support/UnitTestExtendedAssertions.h>
32
32
#include < lib/support/UnitTestRegistration.h>
33
+ #include < messaging/tests/MessagingContext.h>
33
34
#include < nlunit-test.h>
34
35
#include < system/SystemLayerImpl.h>
35
36
36
- #include < crypto/DefaultSessionKeystore.h>
37
-
38
37
using namespace chip ;
39
38
using namespace chip ::app;
40
39
using namespace chip ::System;
@@ -119,16 +118,19 @@ class TestSubscriptionsInfoProvider : public SubscriptionsInfoProvider
119
118
bool mHasPersistedSubscription = false ;
120
119
};
121
120
122
- class TestContext : public chip ::Test::AppContext
121
+ class TestContext : public chip ::Test::LoopbackMessagingContext
123
122
{
124
123
public:
125
124
// Performs shared setup for all tests in the test suite
126
125
CHIP_ERROR SetUpTestSuite () override
127
126
{
128
- ReturnErrorOnFailure (chip::Test::AppContext::SetUpTestSuite ());
127
+ ReturnErrorOnFailure (LoopbackMessagingContext::SetUpTestSuite ());
128
+ ReturnErrorOnFailure (chip::DeviceLayer::PlatformMgr ().InitChipStack ());
129
+
129
130
DeviceLayer::SetSystemLayerForTesting (&GetSystemLayer ());
130
131
mRealClock = &chip::System::SystemClock ();
131
132
System::Clock::Internal::SetSystemClockForTesting (&mMockClock );
133
+
132
134
return CHIP_NO_ERROR;
133
135
}
134
136
@@ -137,24 +139,28 @@ class TestContext : public chip::Test::AppContext
137
139
{
138
140
System::Clock::Internal::SetSystemClockForTesting (mRealClock );
139
141
DeviceLayer::SetSystemLayerForTesting (nullptr );
140
- chip::Test::AppContext::TearDownTestSuite ();
142
+
143
+ chip::DeviceLayer::PlatformMgr ().Shutdown ();
144
+ LoopbackMessagingContext::TearDownTestSuite ();
141
145
}
142
146
143
147
// Performs setup for each individual test in the test suite
144
148
CHIP_ERROR SetUp () override
145
149
{
146
- ReturnErrorOnFailure (chip::Test::AppContext::SetUp ());
150
+ ReturnErrorOnFailure (LoopbackMessagingContext::SetUp ());
151
+
147
152
mICDStateObserver .ResetAll ();
148
153
mICDManager .RegisterObserver (&mICDStateObserver );
149
154
mICDManager .Init (&testStorage, &GetFabricTable (), &mKeystore , &GetExchangeManager (), &mSubInfoProvider );
155
+
150
156
return CHIP_NO_ERROR;
151
157
}
152
158
153
159
// Performs teardown for each individual test in the test suite
154
160
void TearDown () override
155
161
{
156
162
mICDManager .Shutdown ();
157
- chip::Test::AppContext ::TearDown ();
163
+ LoopbackMessagingContext ::TearDown ();
158
164
}
159
165
160
166
System::Clock::Internal::MockClock mMockClock ;
@@ -653,6 +659,7 @@ class TestICDManager
653
659
NL_TEST_ASSERT (aSuite, stayActivePromisedMs == 20000 );
654
660
}
655
661
662
+ #if CHIP_CONFIG_ENABLE_ICD_CIP
656
663
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
657
664
#if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
658
665
static void TestShouldCheckInMsgsBeSentAtActiveModeFunction (nlTestSuite * aSuite, void * aContext)
@@ -723,6 +730,7 @@ class TestICDManager
723
730
NL_TEST_ASSERT (aSuite, ctx->mICDManager .ShouldCheckInMsgsBeSentAtActiveModeFunction (kTestFabricIndex1 , kClientNodeId11 ));
724
731
}
725
732
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
733
+ #endif // CHIP_CONFIG_ENABLE_ICD_CIP
726
734
727
735
static void TestHandleTestEventTriggerActiveModeReq (nlTestSuite * aSuite, void * aContext)
728
736
{
@@ -1117,27 +1125,29 @@ namespace {
1117
1125
static const nlTest sTests [] = {
1118
1126
NL_TEST_DEF (" TestICDModeDurations" , TestICDManager::TestICDModeDurations),
1119
1127
NL_TEST_DEF (" TestOnSubscriptionReport" , TestICDManager::TestOnSubscriptionReport),
1120
- NL_TEST_DEF (" TestICDModeDurationsWith0ActiveModeDurationWithoutActiveSub" ,
1121
- TestICDManager::TestICDModeDurationsWith0ActiveModeDurationWithoutActiveSub),
1122
- NL_TEST_DEF (" TestICDModeDurationsWith0ActiveModeDurationWithActiveSub" ,
1123
- TestICDManager::TestICDModeDurationsWith0ActiveModeDurationWithActiveSub),
1124
1128
NL_TEST_DEF (" TestKeepActivemodeRequests" , TestICDManager::TestKeepActivemodeRequests),
1125
- NL_TEST_DEF (" TestICDMRegisterUnregisterEvents" , TestICDManager::TestICDMRegisterUnregisterEvents),
1126
- NL_TEST_DEF (" TestICDCounter" , TestICDManager::TestICDCounter),
1127
1129
NL_TEST_DEF (" TestICDStayActive" , TestICDManager::TestICDMStayActive),
1130
+ #if CHIP_CONFIG_ENABLE_ICD_CIP
1131
+ NL_TEST_DEF (" TestICDCounter" , TestICDManager::TestICDCounter),
1132
+ NL_TEST_DEF (" TestICDMRegisterUnregisterEvents" , TestICDManager::TestICDMRegisterUnregisterEvents),
1133
+ NL_TEST_DEF (" TestICDModeDurationsWith0ActiveModeDurationWithActiveSub" ,
1134
+ TestICDManager::TestICDModeDurationsWith0ActiveModeDurationWithActiveSub),
1135
+ NL_TEST_DEF (" TestICDModeDurationsWith0ActiveModeDurationWithoutActiveSub" ,
1136
+ TestICDManager::TestICDModeDurationsWith0ActiveModeDurationWithoutActiveSub),
1128
1137
NL_TEST_DEF (" TestShouldCheckInMsgsBeSentAtActiveModeFunction" , TestICDManager::TestShouldCheckInMsgsBeSentAtActiveModeFunction),
1129
- NL_TEST_DEF (" TestHandleTestEventTriggerActiveModeReq" , TestICDManager::TestHandleTestEventTriggerActiveModeReq),
1130
1138
NL_TEST_DEF (" TestHandleTestEventTriggerInvalidateHalfCounterValues" ,
1131
1139
TestICDManager::TestHandleTestEventTriggerInvalidateHalfCounterValues),
1132
1140
NL_TEST_DEF (" TestHandleTestEventTriggerInvalidateAllCounterValues" ,
1133
1141
TestICDManager::TestHandleTestEventTriggerInvalidateAllCounterValues),
1142
+ NL_TEST_DEF (" TestICDStateObserverOnICDModeChange" , TestICDManager::TestICDStateObserverOnICDModeChange),
1143
+ NL_TEST_DEF (" TestICDStateObserverOnICDModeChangeOnInit" , TestICDManager::TestICDStateObserverOnICDModeChangeOnInit),
1144
+ #endif // CHIP_CONFIG_ENABLE_ICD_CIP
1145
+ NL_TEST_DEF (" TestHandleTestEventTriggerActiveModeReq" , TestICDManager::TestHandleTestEventTriggerActiveModeReq),
1134
1146
NL_TEST_DEF (" TestICDStateObserverOnEnterIdleModeActiveModeDuration" ,
1135
1147
TestICDManager::TestICDStateObserverOnEnterIdleModeActiveModeDuration),
1136
1148
NL_TEST_DEF (" TestICDStateObserverOnEnterIdleModeActiveModeThreshold" ,
1137
1149
TestICDManager::TestICDStateObserverOnEnterIdleModeActiveModeThreshold),
1138
1150
NL_TEST_DEF (" TestICDStateObserverOnEnterActiveMode" , TestICDManager::TestICDStateObserverOnEnterActiveMode),
1139
- NL_TEST_DEF (" TestICDStateObserverOnICDModeChange" , TestICDManager::TestICDStateObserverOnICDModeChange),
1140
- NL_TEST_DEF (" TestICDStateObserverOnICDModeChangeOnInit" , TestICDManager::TestICDStateObserverOnICDModeChangeOnInit),
1141
1151
NL_TEST_DEF (" TestICDStateObserverOnTransitionToIdleModeGreaterActiveModeDuration" ,
1142
1152
TestICDManager::TestICDStateObserverOnTransitionToIdleModeGreaterActiveModeDuration),
1143
1153
NL_TEST_DEF (" TestICDStateObserverOnTransitionToIdleModeEqualActiveModeDuration" ,
0 commit comments