Skip to content

Commit 1cd8207

Browse files
committed
Moved initialization code into TestDnssdPlatform::SetUp()
1 parent 8fe265d commit 1cd8207

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

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

+11-9
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,22 @@ 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+
}
160163
static void TearDownTestSuite()
161164
{
162165
DiscoveryImplPlatform::GetInstance().Shutdown();
163166
chip::Platform::MemoryShutdown();
164167
}
168+
void SetUp() override
169+
{
170+
test::Reset();
171+
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
172+
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
173+
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
174+
}
165175
};
166176

167177
TEST_F(TestDnssdPlatform, TestStub)
@@ -171,19 +181,14 @@ TEST_F(TestDnssdPlatform, TestStub)
171181
// without an expected event.
172182
ChipLogError(Discovery, "Test platform returns error correctly");
173183
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
174-
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
175-
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
176184
OperationalAdvertisingParameters params;
177185
EXPECT_EQ(mdnsPlatform.Advertise(params), CHIP_ERROR_UNEXPECTED_EVENT);
178186
}
179187

180188
TEST_F(TestDnssdPlatform, TestOperational)
181189
{
182190
ChipLogError(Discovery, "Test operational");
183-
test::Reset();
184191
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
185-
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
186-
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
187192

188193
operationalCall1.callType = test::CallType::kStart;
189194
EXPECT_EQ(test::AddExpectedCall(operationalCall1), CHIP_NO_ERROR);
@@ -201,10 +206,7 @@ TEST_F(TestDnssdPlatform, TestOperational)
201206
TEST_F(TestDnssdPlatform, TestCommissionableNode)
202207
{
203208
ChipLogError(Discovery, "Test commissionable");
204-
test::Reset();
205209
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
206-
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
207-
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
208210

209211
commissionableSmall.callType = test::CallType::kStart;
210212
EXPECT_EQ(

0 commit comments

Comments
 (0)