Skip to content

Commit

Permalink
Clean up initialization code
Browse files Browse the repository at this point in the history
  • Loading branch information
mbknust committed Apr 23, 2024
1 parent 8fe265d commit e471a0e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/lib/dnssd/platform/tests/TestPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,21 @@ test::ExpectedCall commissionableLargeEnhanced = test::ExpectedCall()
class TestDnssdPlatform : public ::testing::Test
{
public:
static void SetUpTestSuite() { VerifyOrDie(chip::Platform::MemoryInit() == CHIP_NO_ERROR); }
static void SetUpTestSuite()
{
ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR);
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
}

static void TearDownTestSuite()
{
DiscoveryImplPlatform::GetInstance().Shutdown();
chip::Platform::MemoryShutdown();
}

void TearDown() override { test::Reset(); }
};

TEST_F(TestDnssdPlatform, TestStub)
Expand All @@ -171,19 +180,14 @@ TEST_F(TestDnssdPlatform, TestStub)
// without an expected event.
ChipLogError(Discovery, "Test platform returns error correctly");
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);
OperationalAdvertisingParameters params;
EXPECT_EQ(mdnsPlatform.Advertise(params), CHIP_ERROR_UNEXPECTED_EVENT);
}

TEST_F(TestDnssdPlatform, TestOperational)
{
ChipLogError(Discovery, "Test operational");
test::Reset();
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);

operationalCall1.callType = test::CallType::kStart;
EXPECT_EQ(test::AddExpectedCall(operationalCall1), CHIP_NO_ERROR);
Expand All @@ -201,10 +205,7 @@ TEST_F(TestDnssdPlatform, TestOperational)
TEST_F(TestDnssdPlatform, TestCommissionableNode)
{
ChipLogError(Discovery, "Test commissionable");
test::Reset();
DiscoveryImplPlatform & mdnsPlatform = DiscoveryImplPlatform::GetInstance();
EXPECT_EQ(mdnsPlatform.Init(DeviceLayer::UDPEndPointManager()), CHIP_NO_ERROR);
EXPECT_EQ(mdnsPlatform.RemoveServices(), CHIP_NO_ERROR);

commissionableSmall.callType = test::CallType::kStart;
EXPECT_EQ(
Expand Down

0 comments on commit e471a0e

Please sign in to comment.