Skip to content

Commit e471a0e

Browse files
committed
Clean up initialization code
1 parent 8fe265d commit e471a0e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/lib/dnssd/platform/tests/TestPlatform.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,21 @@ test::ExpectedCall commissionableLargeEnhanced = test::ExpectedCall()
156156
class TestDnssdPlatform : public ::testing::Test
157157
{
158158
public:
159-
static void SetUpTestSuite() { VerifyOrDie(chip::Platform::MemoryInit() == CHIP_NO_ERROR); }
159+
static void SetUpTestSuite()
160+
{
161+
ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR);
162+
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
163+
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
164+
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
165+
}
166+
160167
static void TearDownTestSuite()
161168
{
162169
DiscoveryImplPlatform::GetInstance().Shutdown();
163170
chip::Platform::MemoryShutdown();
164171
}
172+
173+
void TearDown() override { test::Reset(); }
165174
};
166175

167176
TEST_F(TestDnssdPlatform, TestStub)
@@ -171,19 +180,14 @@ TEST_F(TestDnssdPlatform, TestStub)
171180
// without an expected event.
172181
ChipLogError(Discovery, "Test platform returns error correctly");
173182
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
174-
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
175-
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
176183
OperationalAdvertisingParameters params;
177184
EXPECT_EQ(mdnsPlatform.Advertise(params), CHIP_ERROR_UNEXPECTED_EVENT);
178185
}
179186

180187
TEST_F(TestDnssdPlatform, TestOperational)
181188
{
182189
ChipLogError(Discovery, "Test operational");
183-
test::Reset();
184190
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
185-
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
186-
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
187191

188192
operationalCall1.callType = test::CallType::kStart;
189193
EXPECT_EQ(test::AddExpectedCall(operationalCall1), CHIP_NO_ERROR);
@@ -201,10 +205,7 @@ TEST_F(TestDnssdPlatform, TestOperational)
201205
TEST_F(TestDnssdPlatform, TestCommissionableNode)
202206
{
203207
ChipLogError(Discovery, "Test commissionable");
204-
test::Reset();
205208
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
206-
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
207-
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
208209

209210
commissionableSmall.callType = test::CallType::kStart;
210211
EXPECT_EQ(

0 commit comments

Comments
 (0)