Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced nlunit-test with pw_unit_test in src/lib/dnssd/platform/ #33072

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Clean up initialization code
mbknust committed Apr 23, 2024
commit e471a0e2cba69841ea1cd40ad160b5dbd48b6359
19 changes: 10 additions & 9 deletions src/lib/dnssd/platform/tests/TestPlatform.cpp
Original file line number Diff line number Diff line change
@@ -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)
@@ -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);
@@ -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(