fix code check

Signed-off-by: woohoa <wanghuan36@huawei.com>
This commit is contained in:
15950533375 2024-05-30 18:41:44 +08:00
parent 88e96ba4e9
commit 19a417bf7a
12 changed files with 100 additions and 98 deletions

View File

@ -1,28 +1,29 @@
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef APP_DOMAIN_VERIFY_WHITE_LIST_CHECKER_H
#define APP_DOMAIN_VERIFY_WHITE_LIST_CHECKER_H
#include <string>
#include "white_list_config_mgr.h"
namespace OHOS::AppDomainVerify{
namespace OHOS::AppDomainVerify {
class WhiteListChecker : public WhiteListConfigMgr{
class WhiteListChecker : public WhiteListConfigMgr {
public:
WhiteListChecker();
~WhiteListChecker() override = default;
bool IsInWhiteList(const std::string& url);
private:
std::shared_ptr<NativePreferences::PreferencesObserver> observer_;
};

View File

@ -26,8 +26,8 @@ void WhiteListUpdater::UpdateWhiteList(std::unordered_set<std::string>& whiteLis
Load();
}
std::unordered_set<std::string> filtedWhiteList;
std::for_each(whiteList.begin(), whiteList.end(), [&filtedWhiteList](const std::string& element){
if(UrlUtil::IsValidUrl(element)){
std::for_each(whiteList.begin(), whiteList.end(), [&filtedWhiteList](const std::string& element) {
if (UrlUtil::IsValidUrl(element)) {
filtedWhiteList.insert(element);
}
});

View File

@ -26,7 +26,7 @@ std::shared_ptr<AppDomainVerifyTaskMgr> AppDomainVerifyTaskMgr::instance_ = null
std::mutex AppDomainVerifyTaskMgr::mutex_;
using namespace OHOS::NetStack::HttpClient;
constexpr int MAX_CONCURRENCY = 10;
std::shared_ptr<AppDomainVerifyTaskMgr> AppDomainVerifyTaskMgr::GetInstance()
{
if (instance_ == nullptr) {
@ -62,7 +62,7 @@ bool AppDomainVerifyTaskMgr::Init()
{
APP_DOMAIN_VERIFY_HILOGI(APP_DOMAIN_VERIFY_MODULE_COMMON, "Init.");
ffrt::queue_attr queueAttr{};
queueAttr.max_concurrency(10);
queueAttr.max_concurrency(MAX_CONCURRENCY);
queueAttr.qos(ffrt_qos_default);
ffrtTaskQueue_ = std::make_shared<ffrt::queue>("ffrt-queue", queueAttr);
return false;

View File

@ -22,15 +22,15 @@
namespace OHOS {
namespace AppDomainVerify {
class IVerifyTask: public std::enable_shared_from_this<IVerifyTask>{
class IVerifyTask : public std::enable_shared_from_this<IVerifyTask> {
public:
IVerifyTask() = default;
virtual ~IVerifyTask() = default;
virtual void OnPostVerify(const std::string &uri,
const OHOS::NetStack::HttpClient::HttpClientResponse &response) = 0;
virtual void OnPostVerify(
const std::string& uri, const OHOS::NetStack::HttpClient::HttpClientResponse& response) = 0;
virtual void OnSaveVerifyResult() = 0;
virtual bool OnPreRequest(OHOS::NetStack::HttpClient::HttpClientRequest &request, const std::string &uri) = 0;
virtual const std::unordered_map<std::string, InnerVerifyStatus> &GetUriVerifyMap() = 0;
virtual bool OnPreRequest(OHOS::NetStack::HttpClient::HttpClientRequest& request, const std::string& uri) = 0;
virtual const std::unordered_map<std::string, InnerVerifyStatus>& GetUriVerifyMap() = 0;
virtual OHOS::AppDomainVerify::TaskType GetType() = 0;
};
}

View File

@ -53,8 +53,10 @@ void AppDomainVerifyTaskMgrTest::TearDown(void)
{
}
void Sleep(){
std::this_thread::sleep_for(std::chrono::milliseconds(10));
#define SLEEP_TIME (10)
void Sleep()
{
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
}
/**
* @tc.name: AppDomainVerifyTaskMgrTest001

View File

@ -1,20 +1,19 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef COMMUNICATIONNETSTACK_HTTP_CLIENT_H
#define COMMUNICATIONNETSTACK_HTTP_CLIENT_H
#endif // COMMUNICATIONNETSTACK_HTTP_CLIENT_H

View File

@ -1,17 +1,17 @@
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef COMMUNICATIONNETSTACK_HTTP_CLIENT_ERROR_H
#define COMMUNICATIONNETSTACK_HTTP_CLIENT_ERROR_H
@ -24,11 +24,13 @@ public:
{
}
int GetErrorCode() const{
int GetErrorCode() const
{
return errorCode_;
};
const std::string& GetErrorMessage() const{
const std::string& GetErrorMessage() const
{
return errorMsg_;
};

View File

@ -1,17 +1,17 @@
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef COMMUNICATIONNETSTACK_HTTP_CLIENT_REQUEST_H
#define COMMUNICATIONNETSTACK_HTTP_CLIENT_REQUEST_H
@ -19,9 +19,8 @@
namespace OHOS::NetStack::HttpClient {
class HttpClientRequest {
public:
HttpClientRequest()= default;
HttpClientRequest() = default;
};
}
#endif // COMMUNICATIONNETSTACK_HTTP_CLIENT_REQUEST_H

View File

@ -1,16 +1,16 @@
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef COMMUNICATIONNETSTACK_HTTP_CLIENT_RESPONSE_H
@ -23,12 +23,14 @@ namespace HttpClient {
using ResponseCode = int;
class HttpClientResponse {
public:
HttpClientResponse() : responseCode_(0) {};
ResponseCode GetResponseCode() const{
HttpClientResponse() : responseCode_(0){};
ResponseCode GetResponseCode() const
{
GTEST_LOG_(INFO) << "MOCK GetResponseCode";
return responseCode_;
}
const std::string &GetResult() const{
const std::string& GetResult() const
{
GTEST_LOG_(INFO) << "MOCK GetResult";
return result_;
}

View File

@ -23,6 +23,7 @@
#include "http_client_response.h"
namespace OHOS::NetStack::HttpClient {
#define DATA_BLOCK (10 * 1024)
class HttpClientTask : public std::enable_shared_from_this<HttpClientTask> {
public:
explicit HttpClientTask(const HttpClientRequest& request)
@ -46,14 +47,14 @@ public:
if (receive_) {
if (onDataReceive_) {
uint8_t* fake;
onDataReceive_(request_, fake, 10 * 1024);
onDataReceive_(request_, fake, 10 * 1024);
onDataReceive_(request_, fake, 10 * 1024);
onDataReceive_(request_, fake, DATA_BLOCK);
onDataReceive_(request_, fake, DATA_BLOCK);
onDataReceive_(request_, fake, DATA_BLOCK);
}
}
if(cancel_){
if(onCanceled_){
onCanceled_(request_,response_);
if (cancel_) {
if (onCanceled_) {
onCanceled_(request_, response_);
}
}
return true;
@ -96,7 +97,7 @@ public:
{
response_ = response;
};
static void MockStatus(bool success = true, bool failed = false, bool receive = false, bool cancel = false)
static void MockStatus(bool success = true, bool failed = false, bool receive = false, bool cancel = false)
{
success_ = success;
failed_ = failed;
@ -104,7 +105,8 @@ public:
cancel_ = cancel;
}
static void MockResponse(HttpClientResponse& response){
static void MockResponse(HttpClientResponse& response)
{
response_ = response;
}

View File

@ -56,7 +56,6 @@ public:
}
double GetDouble(const std::string& key, const double& defValue = {}) override
{
return 0;
}
int64_t GetLong(const std::string& key, const int64_t& defValue = {}) override

View File

@ -34,10 +34,6 @@ public:
const uint8_t* data, size_t length),
(override));
};
class MocHttpClientTask:public HttpClientTask{
};
}
}
#endif // APP_DOMAIN_VERIFY_MOCK_VERIFY_HTTP_TASK_H