!50 补齐taskmgr 接口测试率

Merge pull request !50 from WoHoo/master
This commit is contained in:
openharmony_ci 2024-06-07 09:44:12 +00:00 committed by Gitee
commit 9333075c70
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 55 additions and 0 deletions

View File

@ -171,4 +171,29 @@ HWTEST_F(AppDomainVerifyTaskMgrTest, AppDomainVerifyTaskMgrTest006, TestSize.Lev
Sleep();
ASSERT_TRUE(appDomainVerifyTaskMgr->IsIdle());
}
class BaseHttpTask : public IHttpTask {
public:
std::shared_ptr<OHOS::NetStack::HttpClient::HttpClientTask> CreateHttpClientTask() override
{
return nullptr;
}
};
/**
* @tc.name: AppDomainVerifyTaskMgrTest007
* @tc.desc: on date cancle
* @tc.type: FUNC
*/
HWTEST_F(AppDomainVerifyTaskMgrTest, AppDomainVerifyTaskMgrTest007, TestSize.Level0)
{
std::shared_ptr<BaseHttpTask> baseHttpTask = std::make_shared<BaseHttpTask>();
HttpClientRequest request;
HttpClientResponse response;
HttpClientError error;
uint8_t* data;
baseHttpTask->OnSuccess(request, response);
baseHttpTask->OnFail(request, response, error);
baseHttpTask->OnCancel(request, response);
baseHttpTask->OnDataReceive(nullptr, request, data, 0);
ASSERT_TRUE(baseHttpTask->CreateHttpClientTask() == nullptr);
}
}

View File

@ -48,6 +48,7 @@ ohos_unittest("app_domain_verify_agent_verifier_test") {
sources = [
"${app_domain_verify_verifier_path}/src/domain_json_util.cpp",
"${app_domain_verify_verifier_path}/src/domain_verifier.cpp",
"${app_domain_verify_verifier_path}/src/verify_http_task.cpp",
"${app_domain_verify_verifier_path}/src/verify_task.cpp",
"domain_json_util_test.cpp",
"domain_verifier_test.cpp",

View File

@ -20,6 +20,7 @@
#undef private
#undef protected
#include "moc_verify_task.h"
#include "verify_http_task.h"
namespace OHOS::AppDomainVerify {
using namespace testing;
using namespace testing::ext;
@ -217,4 +218,32 @@ HWTEST_F(DomainVerifierTaskTest, DomainVerifierTaskSaveResultTest002, TestSize.L
task.OnSaveVerifyResult();
}
/**
* @tc.name: DomainVerifierHttpTaskTest001
* @tc.desc:
* @tc.type: FUNC
*/
HWTEST_F(DomainVerifierTaskTest, DomainVerifierHttpTaskTest001, TestSize.Level0)
{
AppVerifyBaseInfo appVerifyBaseInfo;
appVerifyBaseInfo.bundleName = "";
appVerifyBaseInfo.fingerprint = "";
appVerifyBaseInfo.appIdentifier = "";
SkillUri uri1;
uri1.scheme = "https";
uri1.host = "e";
const std::vector<SkillUri> skillUris;
std::shared_ptr<MocVerifyTask> task = std::make_shared<MocVerifyTask>(
TaskType::IMMEDIATE_TASK, appVerifyBaseInfo, skillUris);
std::shared_ptr<VerifyHttpTask> verifyHttpTask = std::make_shared<VerifyHttpTask>("", task);
OHOS::NetStack::HttpClient::HttpClientRequest request;
OHOS::NetStack::HttpClient::HttpClientResponse response;
OHOS::NetStack::HttpClient::HttpClientError error;
uint8_t* data;
verifyHttpTask->OnSuccess(request, response);
verifyHttpTask->OnFail(request, response, error);
verifyHttpTask->OnCancel(request, response);
verifyHttpTask->OnDataReceive(nullptr, request, data, 0);
ASSERT_TRUE(verifyHttpTask->CreateHttpClientTask() != nullptr);
}
}