@@ -109,50 +109,31 @@ class MockInteractionModelApp : public chip::app::ReadClient::Callback
109
109
namespace chip {
110
110
namespace app {
111
111
112
- class TestAclAttribute : public ::testing::Test
112
+ class TestAclAttribute : public Test ::AppContext
113
113
{
114
114
public:
115
- static void SetUpTestSuite ()
116
- {
117
-
118
- mpTestContext = new chip::Test::AppContext;
119
- mpTestContext->SetUpTestSuite ();
120
- }
121
- static void TearDownTestSuite ()
122
- {
123
- mpTestContext->TearDownTestSuite ();
124
- delete mpTestContext;
125
- }
126
-
127
115
void SetUp () override
128
116
{
129
- mpTestContext-> SetUp ();
117
+ AppContext:: SetUp ();
130
118
131
119
Access::GetAccessControl ().Finish ();
132
120
Access::GetAccessControl ().Init (GetTestAccessControlDelegate (), gDeviceTypeResolver );
133
121
}
134
- void TearDown () override { mpTestContext->TearDown (); }
135
-
136
- static chip::Test::AppContext * mpTestContext;
137
122
};
138
123
139
- chip::Test::AppContext * TestAclAttribute::mpTestContext = nullptr ;
140
-
141
124
// Read Client sends a malformed subscribe request, interaction model engine fails to parse the request and generates a status
142
125
// report to client, and client is closed.
143
126
TEST_F (TestAclAttribute, TestACLDeniedAttribute)
144
127
{
145
- Messaging::ReliableMessageMgr * rm = mpTestContext-> GetExchangeManager ().GetReliableMessageMgr ();
128
+ Messaging::ReliableMessageMgr * rm = GetExchangeManager ().GetReliableMessageMgr ();
146
129
EXPECT_EQ (rm->TestGetCountRetransTable (), 0 );
147
130
148
131
MockInteractionModelApp delegate;
149
132
auto * engine = chip::app::InteractionModelEngine::GetInstance ();
150
- EXPECT_EQ (engine->Init (&mpTestContext->GetExchangeManager (), &mpTestContext->GetFabricTable (),
151
- app::reporting::GetDefaultReportScheduler ()),
152
- CHIP_NO_ERROR);
133
+ EXPECT_EQ (engine->Init (&GetExchangeManager (), &GetFabricTable (), app::reporting::GetDefaultReportScheduler ()), CHIP_NO_ERROR);
153
134
154
135
{
155
- app::ReadClient readClient (chip::app::InteractionModelEngine::GetInstance (), &mpTestContext-> GetExchangeManager (), delegate,
136
+ app::ReadClient readClient (chip::app::InteractionModelEngine::GetInstance (), &GetExchangeManager (), delegate,
156
137
chip::app::ReadClient::InteractionType::Subscribe);
157
138
158
139
chip::app::AttributePathParams attributePathParams[2 ];
@@ -164,21 +145,21 @@ TEST_F(TestAclAttribute, TestACLDeniedAttribute)
164
145
attributePathParams[1 ].mClusterId = chip::Test::kTestDeniedClusterId1 ;
165
146
attributePathParams[1 ].mAttributeId = 2 ;
166
147
167
- ReadPrepareParams readPrepareParams (mpTestContext-> GetSessionBobToAlice ());
148
+ ReadPrepareParams readPrepareParams (GetSessionBobToAlice ());
168
149
readPrepareParams.mpAttributePathParamsList = attributePathParams;
169
150
readPrepareParams.mAttributePathParamsListSize = 2 ;
170
151
171
152
EXPECT_EQ (readClient.SendRequest (readPrepareParams), CHIP_NO_ERROR);
172
153
173
- mpTestContext-> DrainAndServiceIO ();
154
+ DrainAndServiceIO ();
174
155
EXPECT_EQ (delegate.mError , CHIP_IM_GLOBAL_STATUS (InvalidAction));
175
156
EXPECT_FALSE (delegate.mGotReport );
176
157
delegate.mError = CHIP_NO_ERROR;
177
158
delegate.mGotReport = false ;
178
159
}
179
160
180
161
{
181
- app::ReadClient readClient (chip::app::InteractionModelEngine::GetInstance (), &mpTestContext-> GetExchangeManager (), delegate,
162
+ app::ReadClient readClient (chip::app::InteractionModelEngine::GetInstance (), &GetExchangeManager (), delegate,
182
163
chip::app::ReadClient::InteractionType::Subscribe);
183
164
184
165
chip::app::AttributePathParams attributePathParams[2 ];
@@ -189,21 +170,21 @@ TEST_F(TestAclAttribute, TestACLDeniedAttribute)
189
170
attributePathParams[1 ].mClusterId = chip::Test::kTestDeniedClusterId2 ;
190
171
attributePathParams[1 ].mAttributeId = 2 ;
191
172
192
- ReadPrepareParams readPrepareParams (mpTestContext-> GetSessionBobToAlice ());
173
+ ReadPrepareParams readPrepareParams (GetSessionBobToAlice ());
193
174
readPrepareParams.mpAttributePathParamsList = attributePathParams;
194
175
readPrepareParams.mAttributePathParamsListSize = 2 ;
195
176
196
177
EXPECT_EQ (readClient.SendRequest (readPrepareParams), CHIP_NO_ERROR);
197
178
198
- mpTestContext-> DrainAndServiceIO ();
179
+ DrainAndServiceIO ();
199
180
EXPECT_EQ (delegate.mError , CHIP_IM_GLOBAL_STATUS (InvalidAction));
200
181
EXPECT_FALSE (delegate.mGotReport );
201
182
delegate.mError = CHIP_NO_ERROR;
202
183
delegate.mGotReport = false ;
203
184
}
204
185
205
186
{
206
- app::ReadClient readClient (chip::app::InteractionModelEngine::GetInstance (), &mpTestContext-> GetExchangeManager (), delegate,
187
+ app::ReadClient readClient (chip::app::InteractionModelEngine::GetInstance (), &GetExchangeManager (), delegate,
207
188
chip::app::ReadClient::InteractionType::Subscribe);
208
189
209
190
chip::app::AttributePathParams attributePathParams[2 ];
@@ -215,13 +196,13 @@ TEST_F(TestAclAttribute, TestACLDeniedAttribute)
215
196
attributePathParams[1 ].mClusterId = chip::Test::kTestClusterId ;
216
197
attributePathParams[1 ].mAttributeId = 2 ;
217
198
218
- ReadPrepareParams readPrepareParams (mpTestContext-> GetSessionBobToAlice ());
199
+ ReadPrepareParams readPrepareParams (GetSessionBobToAlice ());
219
200
readPrepareParams.mpAttributePathParamsList = attributePathParams;
220
201
readPrepareParams.mAttributePathParamsListSize = 2 ;
221
202
222
203
EXPECT_EQ (readClient.SendRequest (readPrepareParams), CHIP_NO_ERROR);
223
204
224
- mpTestContext-> DrainAndServiceIO ();
205
+ DrainAndServiceIO ();
225
206
EXPECT_EQ (delegate.mError , CHIP_NO_ERROR);
226
207
EXPECT_TRUE (delegate.mGotReport );
227
208
EXPECT_EQ (engine->GetNumActiveReadHandlers (ReadHandler::InteractionType::Subscribe), 1u );
@@ -231,7 +212,7 @@ TEST_F(TestAclAttribute, TestACLDeniedAttribute)
231
212
232
213
EXPECT_EQ (engine->GetNumActiveReadClients (), 0u );
233
214
engine->Shutdown ();
234
- EXPECT_EQ (mpTestContext-> GetExchangeManager ().GetNumActiveExchanges (), 0u );
215
+ EXPECT_EQ (GetExchangeManager ().GetNumActiveExchanges (), 0u );
235
216
}
236
217
} // namespace app
237
218
} // namespace chip
0 commit comments