Add unit test for getFirewallType

Add the test to increase code line coverage.

Bug: N/A
Test: atest
Change-Id: Ic469da984dd5879acb229d1a147a670b1787e996
This commit is contained in:
Ken Chen
2022-06-06 12:46:36 +08:00
parent 2fb8636268
commit 77a6b71989

View File

@@ -718,6 +718,31 @@ TEST_F(TrafficControllerTest, TestDumpsys) {
EXPECT_TRUE(expectDumpsysContains(expectedLines)); EXPECT_TRUE(expectDumpsysContains(expectedLines));
} }
TEST_F(TrafficControllerTest, getFirewallType) {
static const struct TestConfig {
ChildChain childChain;
FirewallType firewallType;
} testConfigs[] = {
// clang-format off
{NONE, DENYLIST},
{DOZABLE, ALLOWLIST},
{STANDBY, DENYLIST},
{POWERSAVE, ALLOWLIST},
{RESTRICTED, ALLOWLIST},
{LOW_POWER_STANDBY, ALLOWLIST},
{LOCKDOWN, DENYLIST},
{OEM_DENY_1, DENYLIST},
{OEM_DENY_2, DENYLIST},
{INVALID_CHAIN, DENYLIST},
// clang-format on
};
for (const auto& config : testConfigs) {
SCOPED_TRACE(fmt::format("testConfig: [{}, {}]", config.childChain, config.firewallType));
EXPECT_EQ(config.firewallType, mTc.getFirewallType(config.childChain));
}
}
constexpr uint32_t SOCK_CLOSE_WAIT_US = 30 * 1000; constexpr uint32_t SOCK_CLOSE_WAIT_US = 30 * 1000;
constexpr uint32_t ENOBUFS_POLL_WAIT_US = 10 * 1000; constexpr uint32_t ENOBUFS_POLL_WAIT_US = 10 * 1000;