Skip to content

Commit 8c2c64e

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

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,19 @@ 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() { ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR); }
160160
static void TearDownTestSuite()
161161
{
162162
DiscoveryImplPlatform::GetInstance().Shutdown();
163163
chip::Platform::MemoryShutdown();
164164
}
165+
void SetUp() override
166+
{
167+
test::Reset();
168+
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
169+
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
170+
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
171+
}
165172
};
166173

167174
TEST_F(TestDnssdPlatform, TestStub)
@@ -171,19 +178,14 @@ TEST_F(TestDnssdPlatform, TestStub)
171178
// without an expected event.
172179
ChipLogError(Discovery, "Test platform returns error correctly");
173180
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
174-
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
175-
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
176181
OperationalAdvertisingParameters params;
177182
EXPECT_EQ(mdnsPlatform.Advertise(params), CHIP_ERROR_UNEXPECTED_EVENT);
178183
}
179184

180185
TEST_F(TestDnssdPlatform, TestOperational)
181186
{
182187
ChipLogError(Discovery, "Test operational");
183-
test::Reset();
184188
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
185-
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
186-
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
187189

188190
operationalCall1.callType = test::CallType::kStart;
189191
EXPECT_EQ(test::AddExpectedCall(operationalCall1), CHIP_NO_ERROR);
@@ -201,10 +203,7 @@ TEST_F(TestDnssdPlatform, TestOperational)
201203
TEST_F(TestDnssdPlatform, TestCommissionableNode)
202204
{
203205
ChipLogError(Discovery, "Test commissionable");
204-
test::Reset();
205206
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
206-
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
207-
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
208207

209208
commissionableSmall.callType = test::CallType::kStart;
210209
EXPECT_EQ(

0 commit comments

Comments
 (0)