增加 C++ 接口测试覆盖率

Signed-off-by: hu-kai45 <hukai45@huawei.com>
This commit is contained in:
hu-kai45 2024-02-06 20:26:55 +08:00
parent a33fee30d3
commit 6c2a800300
4 changed files with 44 additions and 12 deletions

View File

@ -55,18 +55,38 @@ void BackgroundNotificationTest::TearDown(void)
/**
* @tc.name: BackGroundNotifyTest_001
* @tc.desc: Test RequestBackgroundNotify interface base function
* @tc.desc: Test RequestBackgroundNotify interface base function - download
* @tc.type: FUNC
* @tc.require: Issue Number
*/
HWTEST_F(BackgroundNotificationTest, BackGroundNotifyTest_001, TestSize.Level1)
{
RequestTaskMsg msg = RequestTaskMsg{
RequestTaskMsg msg = RequestTaskMsg {
123, // uint32_t taskId
123456, // pid_t uid
static_cast<uint8_t>(Action::DOWNLOAD) // uint8_t action
};
CStringWrapper wrappedPath = WrapperCString("../BUILD.gn");
CStringWrapper wrappedFileName = WrapperCString("BUILD.gn");
uint32_t percent = 50;
RequestBackgroundNotify(msg, wrappedPath, wrappedFileName, percent);
}
/**
* @tc.name: BackGroundNotifyTest_002
* @tc.desc: Test RequestBackgroundNotify interface base function - upload
* @tc.type: FUNC
* @tc.require: Issue Number
*/
HWTEST_F(BackgroundNotificationTest, BackGroundNotifyTest_002, TestSize.Level1)
{
RequestTaskMsg msg = RequestTaskMsg {
123, // uint32_t taskId
123456, // pid_t uid
static_cast<uint8_t>(Action::UPLOAD) // uint8_t action
};
CStringWrapper wrappedPath = WrapperCString("../BUILD.gn");
CStringWrapper wrappedFileName = WrapperCString("BUILD.gn");
uint32_t percent = 50;

View File

@ -62,16 +62,8 @@ int32_t ParamFunc()
*/
HWTEST_F(EventHandlerTest, InitServiceHandlerTest_001, TestSize.Level1)
{
RequestPostTask(ParamFunc);
RequestInitServiceHandler();
RequestInitServiceHandler();
}
/**
* @tc.name: PostTaskTest_001
* @tc.desc: Test RequestPostTask interface base function
* @tc.type: FUNC
* @tc.require: Issue Number
*/
HWTEST_F(EventHandlerTest, PostTaskTest_001, TestSize.Level1)
{
RequestPostTask(ParamFunc);
}

View File

@ -58,4 +58,7 @@ HWTEST_F(StringWrapperTest, WrapperCStringTest_001, TestSize.Level1)
CStringWrapper ret = WrapperCString(str);
EXPECT_EQ(ret.len, str.length());
EXPECT_EQ(strcmp(ret.cStr, str.c_str()), 0);
char *str1 = new char[10];
DeleteChar(str1);
}

View File

@ -17,7 +17,9 @@
#define private public
#define protected public
#include "network_adapter.h"
#include "net_all_capabilities.h"
using namespace testing::ext;
using namespace OHOS::Request;
@ -95,3 +97,18 @@ HWTEST_F(NetworkAdapterTest, NetworkAdapterCoverTest_001, TestSize.Level1)
NetworkAdapter::GetInstance().UpdateNetworkInfo();
NetworkAdapter::GetInstance().UpdateRoaming();
}
/**
* @tc.name: NetworkAdapterIsOnlineTest_001
* @tc.desc: Cover some functions return void
* @tc.type: FUNC
* @tc.require: Issue Number
*/
HWTEST_F(NetworkAdapterTest, NetworkAdapterIsOnlineTest_001, TestSize.Level1)
{
IsOnline();
NetworkAdapter::GetInstance().IsOnline();
OHOS::NetManagerStandard::NetAllCapabilities capabilities;
NetworkAdapter::GetInstance().UpdateNetworkInfoInner(capabilities);
}