mirror of
https://github.com/openharmony/security_security_component_manager.git
synced 2026-08-24 22:51:27 -04:00
Description:remove redundance code
Match-id-3334926a7adb5abf8a193b95d14b8512efcc5006
This commit is contained in:
@@ -41,10 +41,7 @@ SecCompClient::~SecCompClient()
|
||||
return;
|
||||
}
|
||||
auto remoteObj = proxy_->AsObject();
|
||||
if (remoteObj == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (serviceDeathObserver_ != nullptr) {
|
||||
if ((remoteObj != nullptr) && (serviceDeathObserver_ != nullptr)) {
|
||||
remoteObj->RemoveDeathRecipient(serviceDeathObserver_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,16 +36,16 @@ int32_t SecCompProxy::RegisterSecurityComponent(SecCompType type,
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) {
|
||||
SC_LOG_ERROR(LABEL, "Write descriptor fail");
|
||||
SC_LOG_ERROR(LABEL, "Register write descriptor fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(type)) {
|
||||
SC_LOG_ERROR(LABEL, "Write Uint32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Register write Uint32 fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
if (!data.WriteString(componentInfo)) {
|
||||
SC_LOG_ERROR(LABEL, "Write string fail");
|
||||
SC_LOG_ERROR(LABEL, "Register write string fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
@@ -53,24 +53,24 @@ int32_t SecCompProxy::RegisterSecurityComponent(SecCompType type,
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
SC_LOG_ERROR(LABEL, "Remote service is null");
|
||||
SC_LOG_ERROR(LABEL, "Register remote service is null");
|
||||
return SC_SERVICE_ERROR_IPC_REQUEST_FAIL;
|
||||
}
|
||||
int32_t requestResult = remote->SendRequest(
|
||||
static_cast<uint32_t>(SecurityComponentServiceInterfaceCode::REGISTER_SECURITY_COMPONENT),
|
||||
data, reply, option);
|
||||
if (requestResult != SC_OK) {
|
||||
SC_LOG_ERROR(LABEL, "Request fail, result: %{public}d", requestResult);
|
||||
SC_LOG_ERROR(LABEL, "Register request fail, result: %{public}d", requestResult);
|
||||
return requestResult;
|
||||
}
|
||||
int32_t res;
|
||||
if (!reply.ReadInt32(res)) {
|
||||
SC_LOG_ERROR(LABEL, "Read result int32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Register read result int32 fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(scId)) {
|
||||
SC_LOG_ERROR(LABEL, "Read scId int32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Register read scId int32 fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
return res;
|
||||
@@ -80,16 +80,16 @@ int32_t SecCompProxy::UpdateSecurityComponent(int32_t scId, const std::string& c
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) {
|
||||
SC_LOG_ERROR(LABEL, "Write descriptor fail");
|
||||
SC_LOG_ERROR(LABEL, "Update write descriptor fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(scId)) {
|
||||
SC_LOG_ERROR(LABEL, "Write Int32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Update write Int32 fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
if (!data.WriteString(componentInfo)) {
|
||||
SC_LOG_ERROR(LABEL, "Write string fail");
|
||||
SC_LOG_ERROR(LABEL, "Update write string fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
@@ -97,18 +97,18 @@ int32_t SecCompProxy::UpdateSecurityComponent(int32_t scId, const std::string& c
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
SC_LOG_ERROR(LABEL, "Remote service is null");
|
||||
SC_LOG_ERROR(LABEL, "Update remote update service is null");
|
||||
return SC_SERVICE_ERROR_IPC_REQUEST_FAIL;
|
||||
}
|
||||
int32_t requestResult = remote->SendRequest(
|
||||
static_cast<uint32_t>(SecurityComponentServiceInterfaceCode::UPDATE_SECURITY_COMPONENT), data, reply, option);
|
||||
if (requestResult != SC_OK) {
|
||||
SC_LOG_ERROR(LABEL, "Request fail, result: %{public}d", requestResult);
|
||||
SC_LOG_ERROR(LABEL, "Update request fail, result: %{public}d", requestResult);
|
||||
return requestResult;
|
||||
}
|
||||
int32_t res;
|
||||
if (!reply.ReadInt32(res)) {
|
||||
SC_LOG_ERROR(LABEL, "Read result int32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Update read result int32 fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
return res;
|
||||
@@ -118,12 +118,12 @@ int32_t SecCompProxy::UnregisterSecurityComponent(int32_t scId)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) {
|
||||
SC_LOG_ERROR(LABEL, "Write descriptor fail");
|
||||
SC_LOG_ERROR(LABEL, "Unregister write descriptor fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(scId)) {
|
||||
SC_LOG_ERROR(LABEL, "Write Int32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Unregister write Int32 fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
@@ -131,19 +131,19 @@ int32_t SecCompProxy::UnregisterSecurityComponent(int32_t scId)
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
SC_LOG_ERROR(LABEL, "Remote service is null");
|
||||
SC_LOG_ERROR(LABEL, "Unregister remote service is null");
|
||||
return SC_SERVICE_ERROR_IPC_REQUEST_FAIL;
|
||||
}
|
||||
int32_t requestResult = remote->SendRequest(
|
||||
static_cast<uint32_t>(SecurityComponentServiceInterfaceCode::UNREGISTER_SECURITY_COMPONENT),
|
||||
data, reply, option);
|
||||
if (requestResult != SC_OK) {
|
||||
SC_LOG_ERROR(LABEL, "Request fail, result: %{public}d", requestResult);
|
||||
SC_LOG_ERROR(LABEL, "Unregister request fail, result: %{public}d", requestResult);
|
||||
return requestResult;
|
||||
}
|
||||
int32_t res;
|
||||
if (!reply.ReadInt32(res)) {
|
||||
SC_LOG_ERROR(LABEL, "Read int32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Unregister read int32 fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
return res;
|
||||
@@ -154,33 +154,33 @@ int32_t SecCompProxy::ReportSecurityComponentClickEvent(int32_t scId,
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) {
|
||||
SC_LOG_ERROR(LABEL, "Write descriptor fail");
|
||||
SC_LOG_ERROR(LABEL, "Report write descriptor fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(scId)) {
|
||||
SC_LOG_ERROR(LABEL, "Write Uint32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Report write Uint32 fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteString(componentInfo)) {
|
||||
SC_LOG_ERROR(LABEL, "Write string fail");
|
||||
SC_LOG_ERROR(LABEL, "Report write string fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
sptr<SecCompClickEventParcel> parcel = new (std::nothrow) SecCompClickEventParcel();
|
||||
if (parcel == nullptr) {
|
||||
SC_LOG_ERROR(LABEL, "New click event parcel failed");
|
||||
SC_LOG_ERROR(LABEL, "Report new click event parcel failed");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
parcel->touchInfoParams_ = touchInfo;
|
||||
if (!data.WriteParcelable(parcel)) {
|
||||
SC_LOG_ERROR(LABEL, "Write touchInfo fail");
|
||||
SC_LOG_ERROR(LABEL, "Report write touchInfo fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if ((callerToken != nullptr) && !data.WriteRemoteObject(callerToken)) {
|
||||
SC_LOG_ERROR(LABEL, "Write caller token fail");
|
||||
SC_LOG_ERROR(LABEL, "Report write caller token fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
@@ -188,19 +188,19 @@ int32_t SecCompProxy::ReportSecurityComponentClickEvent(int32_t scId,
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
SC_LOG_ERROR(LABEL, "Remote service is null");
|
||||
SC_LOG_ERROR(LABEL, "Report remote service is null");
|
||||
return SC_SERVICE_ERROR_IPC_REQUEST_FAIL;
|
||||
}
|
||||
int32_t requestResult = remote->SendRequest(
|
||||
static_cast<uint32_t>(SecurityComponentServiceInterfaceCode::REPORT_SECURITY_COMPONENT_CLICK_EVENT),
|
||||
data, reply, option);
|
||||
if (requestResult != SC_OK) {
|
||||
SC_LOG_ERROR(LABEL, "Request fail, result: %{public}d", requestResult);
|
||||
SC_LOG_ERROR(LABEL, "Report request fail, result: %{public}d", requestResult);
|
||||
return requestResult;
|
||||
}
|
||||
int32_t res;
|
||||
if (!reply.ReadInt32(res)) {
|
||||
SC_LOG_ERROR(LABEL, "Read int32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Report read int32 fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
return res;
|
||||
@@ -210,12 +210,12 @@ bool SecCompProxy::ReduceAfterVerifySavePermission(AccessToken::AccessTokenID to
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) {
|
||||
SC_LOG_ERROR(LABEL, "Write descriptor fail");
|
||||
SC_LOG_ERROR(LABEL, "Verify write descriptor fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(tokenId)) {
|
||||
SC_LOG_ERROR(LABEL, "Write Uint32 fail");
|
||||
SC_LOG_ERROR(LABEL, "Verify write Uint32 fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -223,19 +223,19 @@ bool SecCompProxy::ReduceAfterVerifySavePermission(AccessToken::AccessTokenID to
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
SC_LOG_ERROR(LABEL, "Remote service is null");
|
||||
SC_LOG_ERROR(LABEL, "Verify remote service is null");
|
||||
return false;
|
||||
}
|
||||
int32_t requestResult = remote->SendRequest(
|
||||
static_cast<uint32_t>(SecurityComponentServiceInterfaceCode::VERIFY_TEMP_SAVE_PERMISSION),
|
||||
data, reply, option);
|
||||
if (requestResult != SC_OK) {
|
||||
SC_LOG_ERROR(LABEL, "Request fail, result: %{public}d", requestResult);
|
||||
SC_LOG_ERROR(LABEL, "Verify request fail, result: %{public}d", requestResult);
|
||||
return false;
|
||||
}
|
||||
bool res;
|
||||
if (!reply.ReadBool(res)) {
|
||||
SC_LOG_ERROR(LABEL, "Read bool fail");
|
||||
SC_LOG_ERROR(LABEL, "Verify read bool fail");
|
||||
return false;
|
||||
}
|
||||
return res;
|
||||
@@ -245,7 +245,7 @@ sptr<IRemoteObject> SecCompProxy::GetEnhanceRemoteObject()
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) {
|
||||
SC_LOG_ERROR(LABEL, "Write descriptor fail");
|
||||
SC_LOG_ERROR(LABEL, "Get enhance write descriptor fail");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -253,19 +253,19 @@ sptr<IRemoteObject> SecCompProxy::GetEnhanceRemoteObject()
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
SC_LOG_ERROR(LABEL, "Remote service is null");
|
||||
SC_LOG_ERROR(LABEL, "Get enhance remote service is null");
|
||||
return nullptr;
|
||||
}
|
||||
int32_t requestResult = remote->SendRequest(
|
||||
static_cast<uint32_t>(SecurityComponentServiceInterfaceCode::GET_SECURITY_COMPONENT_ENHANCE_OBJECT),
|
||||
data, reply, option);
|
||||
if (requestResult != SC_OK) {
|
||||
SC_LOG_ERROR(LABEL, "Request fail, result: %{public}d", requestResult);
|
||||
SC_LOG_ERROR(LABEL, "Get enhance request fail, result: %{public}d", requestResult);
|
||||
return nullptr;
|
||||
}
|
||||
sptr<IRemoteObject> callback = reply.ReadRemoteObject();
|
||||
if (callback == nullptr) {
|
||||
SC_LOG_ERROR(LABEL, "Read remote object fail");
|
||||
SC_LOG_ERROR(LABEL, "Get enhance read remote object fail");
|
||||
}
|
||||
return callback;
|
||||
}
|
||||
|
||||
+48
-157
@@ -108,36 +108,20 @@ HWTEST_F(LocationButtonTest, FromJson004, TestSize.Level1)
|
||||
TestCommon::BuildLocationComponentInfo(jsonComponent);
|
||||
ASSERT_TRUE(comp.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
|
||||
{JsonTagConstants::JSON_RECT_X, WRONG_TYPE},
|
||||
{JsonTagConstants::JSON_RECT_Y, TestCommon::TEST_COORDINATE},
|
||||
{JsonTagConstants::JSON_RECT_WIDTH, TestCommon::TEST_COORDINATE},
|
||||
{JsonTagConstants::JSON_RECT_HEIGHT, TestCommon::TEST_COORDINATE}
|
||||
};
|
||||
auto& rectJson = jsonComponent[JsonTagConstants::JSON_RECT];
|
||||
rectJson[JsonTagConstants::JSON_RECT_X] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
|
||||
{JsonTagConstants::JSON_RECT_X, TestCommon::TEST_COORDINATE},
|
||||
{JsonTagConstants::JSON_RECT_Y, WRONG_TYPE},
|
||||
{JsonTagConstants::JSON_RECT_WIDTH, TestCommon::TEST_COORDINATE},
|
||||
{JsonTagConstants::JSON_RECT_HEIGHT, TestCommon::TEST_COORDINATE}
|
||||
};
|
||||
rectJson[JsonTagConstants::JSON_RECT_X] = TestCommon::TEST_COORDINATE;
|
||||
rectJson[JsonTagConstants::JSON_RECT_Y] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
|
||||
{JsonTagConstants::JSON_RECT_X, TestCommon::TEST_COORDINATE},
|
||||
{JsonTagConstants::JSON_RECT_Y, TestCommon::TEST_COORDINATE},
|
||||
{JsonTagConstants::JSON_RECT_WIDTH, WRONG_TYPE},
|
||||
{JsonTagConstants::JSON_RECT_HEIGHT, TestCommon::TEST_COORDINATE}
|
||||
};
|
||||
rectJson[JsonTagConstants::JSON_RECT_Y] = TestCommon::TEST_COORDINATE;
|
||||
rectJson[JsonTagConstants::JSON_RECT_WIDTH] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_RECT] = nlohmann::json {
|
||||
{JsonTagConstants::JSON_RECT_X, TestCommon::TEST_COORDINATE},
|
||||
{JsonTagConstants::JSON_RECT_Y, TestCommon::TEST_COORDINATE},
|
||||
{JsonTagConstants::JSON_RECT_WIDTH, TestCommon::TEST_COORDINATE},
|
||||
{JsonTagConstants::JSON_RECT_HEIGHT, WRONG_TYPE}
|
||||
};
|
||||
rectJson[JsonTagConstants::JSON_RECT_WIDTH] = TestCommon::TEST_COORDINATE;
|
||||
rectJson[JsonTagConstants::JSON_RECT_HEIGHT] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
}
|
||||
|
||||
@@ -154,35 +138,16 @@ HWTEST_F(LocationButtonTest, FromJson005, TestSize.Level1)
|
||||
TestCommon::BuildLocationComponentInfo(jsonComponent);
|
||||
ASSERT_TRUE(comp.FromJson(jsonComponent));
|
||||
|
||||
nlohmann::json jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, TestCommon::TEST_DIMENSION },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
auto& sizeJson = jsonComponent[JsonTagConstants::JSON_SIZE_TAG];
|
||||
sizeJson[JsonTagConstants::JSON_FONT_SIZE_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
sizeJson[JsonTagConstants::JSON_FONT_SIZE_TAG] = TestCommon::TEST_SIZE;
|
||||
sizeJson[JsonTagConstants::JSON_ICON_SIZE_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
sizeJson[JsonTagConstants::JSON_ICON_SIZE_TAG] = TestCommon::TEST_SIZE;
|
||||
sizeJson[JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
}
|
||||
|
||||
@@ -199,32 +164,13 @@ HWTEST_F(LocationButtonTest, FromJson006, TestSize.Level1)
|
||||
TestCommon::BuildLocationComponentInfo(jsonComponent);
|
||||
ASSERT_TRUE(comp.FromJson(jsonComponent));
|
||||
|
||||
nlohmann::json jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, TestCommon::TEST_DIMENSION },
|
||||
};
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
auto& sizeJson = jsonComponent[JsonTagConstants::JSON_SIZE_TAG];
|
||||
auto& paddingJson = sizeJson[JsonTagConstants::JSON_PADDING_SIZE_TAG];
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_TOP_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
|
||||
jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, TestCommon::TEST_DIMENSION },
|
||||
};
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_TOP_TAG] = TestCommon::TEST_DIMENSION;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_RIGHT_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
}
|
||||
|
||||
@@ -241,32 +187,13 @@ HWTEST_F(LocationButtonTest, FromJson007, TestSize.Level1)
|
||||
TestCommon::BuildLocationComponentInfo(jsonComponent);
|
||||
ASSERT_TRUE(comp.FromJson(jsonComponent));
|
||||
|
||||
nlohmann::json jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, TestCommon::TEST_DIMENSION },
|
||||
};
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
auto& sizeJson = jsonComponent[JsonTagConstants::JSON_SIZE_TAG];
|
||||
auto& paddingJson = sizeJson[JsonTagConstants::JSON_PADDING_SIZE_TAG];
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_BOTTOM_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
|
||||
jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, TestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, WRONG_TYPE },
|
||||
};
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, TestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_BOTTOM_TAG] = TestCommon::TEST_DIMENSION;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_LEFT_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(comp.FromJson(jsonComponent));
|
||||
}
|
||||
|
||||
@@ -308,25 +235,16 @@ HWTEST_F(LocationButtonTest, FromJson009, TestSize.Level1)
|
||||
LocationButton button;
|
||||
ASSERT_TRUE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
auto& styleJson = jsonComponent[JsonTagConstants::JSON_STYLE_TAG];
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = LocationDesc::SELECT_LOCATION;
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, WRONG_TYPE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = LocationIcon::LINE_ICON;
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
}
|
||||
|
||||
@@ -343,25 +261,16 @@ HWTEST_F(LocationButtonTest, FromJson010, TestSize.Level1)
|
||||
LocationButton button;
|
||||
ASSERT_TRUE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_COLOR_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_ICON_COLOR_TAG, TestCommon::TEST_COLOR_BLUE },
|
||||
{ JsonTagConstants::JSON_BG_COLOR_TAG, TestCommon::TEST_COLOR_YELLOW }
|
||||
};
|
||||
auto& colorJson = jsonComponent[JsonTagConstants::JSON_COLORS_TAG];
|
||||
colorJson[JsonTagConstants::JSON_FONT_COLOR_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_COLOR_TAG, TestCommon::TEST_COLOR_RED },
|
||||
{ JsonTagConstants::JSON_ICON_COLOR_TAG, WRONG_TYPE },
|
||||
{ JsonTagConstants::JSON_BG_COLOR_TAG, TestCommon::TEST_COLOR_YELLOW }
|
||||
};
|
||||
colorJson[JsonTagConstants::JSON_FONT_COLOR_TAG] = TestCommon::TEST_COLOR_RED;
|
||||
colorJson[JsonTagConstants::JSON_ICON_COLOR_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_COLOR_TAG, TestCommon::TEST_COLOR_RED },
|
||||
{ JsonTagConstants::JSON_ICON_COLOR_TAG, TestCommon::TEST_COLOR_BLUE },
|
||||
{ JsonTagConstants::JSON_BG_COLOR_TAG, WRONG_TYPE }
|
||||
};
|
||||
colorJson[JsonTagConstants::JSON_ICON_COLOR_TAG] = TestCommon::TEST_COLOR_BLUE;
|
||||
colorJson[JsonTagConstants::JSON_BG_COLOR_TAG] = WRONG_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
}
|
||||
|
||||
@@ -379,46 +288,28 @@ HWTEST_F(LocationButtonTest, FromJson011, TestSize.Level1)
|
||||
|
||||
ASSERT_TRUE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, UNKNOWN_TEXT },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
auto& styleJson = jsonComponent[JsonTagConstants::JSON_STYLE_TAG];
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = UNKNOWN_TEXT;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, UNKNOWN_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = LocationDesc::SELECT_LOCATION;
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = UNKNOWN_ICON;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::UNKNOWN_BG },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = LocationIcon::LINE_ICON;
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::UNKNOWN_BG;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::MAX_LABEL_TYPE },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::CIRCLE;
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = LocationDesc::MAX_LABEL_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::MAX_ICON_TYPE },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = LocationDesc::SELECT_LOCATION;
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = LocationIcon::MAX_ICON_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::MAX_BG_TYPE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = LocationIcon::LINE_ICON;
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::MAX_BG_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void PasteButtonTest::TearDown()
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000HO9JB
|
||||
*/
|
||||
HWTEST_F(PasteButtonTest, FromJson010, TestSize.Level1)
|
||||
HWTEST_F(PasteButtonTest, IsParamValid001, TestSize.Level1)
|
||||
{
|
||||
nlohmann::json jsonComponent;
|
||||
TestCommon::BuildPasteComponentInfo(jsonComponent);
|
||||
@@ -56,46 +56,28 @@ HWTEST_F(PasteButtonTest, FromJson010, TestSize.Level1)
|
||||
|
||||
ASSERT_TRUE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, UNKNOWN_TEXT },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, PasteIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
auto& styleJson = jsonComponent[JsonTagConstants::JSON_STYLE_TAG];
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = UNKNOWN_TEXT;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, PasteDesc::PASTE},
|
||||
{ JsonTagConstants::JSON_ICON_TAG, UNKNOWN_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = PasteDesc::PASTE;
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = UNKNOWN_ICON;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, PasteDesc::PASTE },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, PasteIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::UNKNOWN_BG },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = PasteIcon::LINE_ICON;
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::UNKNOWN_BG;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, PasteDesc::MAX_LABEL_TYPE },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, PasteIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::CIRCLE;
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = PasteDesc::MAX_LABEL_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, PasteDesc::PASTE },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, PasteIcon::MAX_ICON_TYPE },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_TEXT_TAG] = PasteDesc::PASTE;
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = PasteIcon::MAX_ICON_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, PasteDesc::PASTE },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, PasteIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::MAX_BG_TYPE },
|
||||
};
|
||||
styleJson[JsonTagConstants::JSON_ICON_TAG] = PasteIcon::LINE_ICON;
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::MAX_BG_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
}
|
||||
|
||||
@@ -146,53 +128,21 @@ HWTEST_F(PasteButtonTest, ComparePasteButton002, TestSize.Level1)
|
||||
ASSERT_TRUE(comp1.FromJson(jsonComponent));
|
||||
PasteButton comp2 = comp1;
|
||||
|
||||
comp1.type_ = LOCATION_COMPONENT;
|
||||
comp1.type_ = SAVE_COMPONENT;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.type_ = PASTE_COMPONENT;
|
||||
|
||||
comp1.fontSize_ = DEFAULT_DIMENSION;
|
||||
comp1.icon_ = static_cast<int32_t>(PasteIcon::FILLED_ICON);
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.fontSize_ = TestCommon::TEST_SIZE;
|
||||
comp1.icon_ = static_cast<int32_t>(PasteIcon::LINE_ICON);
|
||||
|
||||
comp1.iconSize_ = DEFAULT_DIMENSION;
|
||||
comp1.text_ = static_cast<int32_t>(PasteDesc::MAX_LABEL_TYPE);
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.iconSize_ = TestCommon::TEST_SIZE;
|
||||
comp1.text_ = static_cast<int32_t>(PasteDesc::PASTE);
|
||||
|
||||
comp1.padding_.top = DEFAULT_DIMENSION;
|
||||
comp1.bg_ = SecCompBackground::NORMAL;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.padding_.top = TestCommon::TEST_DIMENSION;
|
||||
|
||||
comp1.padding_.right = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.padding_.right = TestCommon::TEST_DIMENSION;
|
||||
|
||||
comp1.padding_.bottom = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.padding_.bottom = TestCommon::TEST_DIMENSION;
|
||||
|
||||
comp1.padding_.left = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.padding_.left = TestCommon::TEST_DIMENSION;
|
||||
|
||||
comp1.textIconSpace_ = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.textIconSpace_ = TestCommon::TEST_SIZE;
|
||||
|
||||
comp1.borderWidth_ = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.borderWidth_ = TestCommon::TEST_SIZE;
|
||||
|
||||
comp1.fontColor_.value = TestCommon::TEST_DIFF_COLOR;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.fontColor_.value = TestCommon::TEST_COLOR_RED;
|
||||
|
||||
comp1.bgColor_.value = TestCommon::TEST_DIFF_COLOR;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.bgColor_.value = TestCommon::TEST_COLOR_YELLOW;
|
||||
|
||||
comp1.iconColor_.value = TestCommon::TEST_DIFF_COLOR;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.iconColor_.value = TestCommon::TEST_COLOR_BLUE;
|
||||
comp1.bg_ = SecCompBackground::CIRCLE;
|
||||
|
||||
ASSERT_TRUE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void SaveButtonTest::TearDown()
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000HO9J7
|
||||
*/
|
||||
HWTEST_F(SaveButtonTest, FromJson010, TestSize.Level1)
|
||||
HWTEST_F(SaveButtonTest, IsParamValid001, TestSize.Level1)
|
||||
{
|
||||
nlohmann::json jsonComponent;
|
||||
TestCommon::BuildSaveComponentInfo(jsonComponent);
|
||||
@@ -56,46 +56,28 @@ HWTEST_F(SaveButtonTest, FromJson010, TestSize.Level1)
|
||||
|
||||
ASSERT_TRUE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, UNKNOWN_TEXT },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, SaveIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
auto& stylesJson = jsonComponent[JsonTagConstants::JSON_STYLE_TAG];
|
||||
stylesJson[JsonTagConstants::JSON_TEXT_TAG] = UNKNOWN_TEXT;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, SaveDesc::DOWNLOAD},
|
||||
{ JsonTagConstants::JSON_ICON_TAG, UNKNOWN_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
stylesJson[JsonTagConstants::JSON_TEXT_TAG] = SaveDesc::DOWNLOAD;
|
||||
stylesJson[JsonTagConstants::JSON_ICON_TAG] = UNKNOWN_ICON;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, SaveDesc::DOWNLOAD },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, SaveIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::UNKNOWN_BG },
|
||||
};
|
||||
stylesJson[JsonTagConstants::JSON_ICON_TAG] = SaveIcon::LINE_ICON;
|
||||
stylesJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::UNKNOWN_BG;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, SaveDesc::MAX_LABEL_TYPE },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, SaveIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
stylesJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::CIRCLE;
|
||||
stylesJson[JsonTagConstants::JSON_TEXT_TAG] = SaveDesc::MAX_LABEL_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, SaveDesc::DOWNLOAD },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, SaveIcon::MAX_ICON_TYPE },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
stylesJson[JsonTagConstants::JSON_TEXT_TAG] = SaveDesc::DOWNLOAD;
|
||||
stylesJson[JsonTagConstants::JSON_ICON_TAG] = SaveIcon::MAX_ICON_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, SaveDesc::DOWNLOAD },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, SaveIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::MAX_BG_TYPE },
|
||||
};
|
||||
stylesJson[JsonTagConstants::JSON_ICON_TAG] = SaveIcon::LINE_ICON;
|
||||
stylesJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::MAX_BG_TYPE;
|
||||
ASSERT_FALSE(button.FromJson(jsonComponent));
|
||||
}
|
||||
|
||||
@@ -150,49 +132,17 @@ HWTEST_F(SaveButtonTest, CompareSaveButton002, TestSize.Level1)
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.type_ = SAVE_COMPONENT;
|
||||
|
||||
comp1.fontSize_ = DEFAULT_DIMENSION;
|
||||
comp1.icon_ = static_cast<int32_t>(SaveIcon::FILLED_ICON);
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.fontSize_ = TestCommon::TEST_SIZE;
|
||||
comp1.icon_ = static_cast<int32_t>(SaveIcon::LINE_ICON);
|
||||
|
||||
comp1.iconSize_ = DEFAULT_DIMENSION;
|
||||
comp1.text_ = static_cast<int32_t>(SaveDesc::DOWNLOAD_AND_SHARE);
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.iconSize_ = TestCommon::TEST_SIZE;
|
||||
comp1.text_ = static_cast<int32_t>(SaveDesc::DOWNLOAD);
|
||||
|
||||
comp1.padding_.top = DEFAULT_DIMENSION;
|
||||
comp1.bg_ = SecCompBackground::CAPSULE;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.padding_.top = TestCommon::TEST_DIMENSION;
|
||||
|
||||
comp1.padding_.right = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.padding_.right = TestCommon::TEST_DIMENSION;
|
||||
|
||||
comp1.padding_.bottom = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.padding_.bottom = TestCommon::TEST_DIMENSION;
|
||||
|
||||
comp1.padding_.left = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.padding_.left = TestCommon::TEST_DIMENSION;
|
||||
|
||||
comp1.textIconSpace_ = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.textIconSpace_ = TestCommon::TEST_SIZE;
|
||||
|
||||
comp1.borderWidth_ = DEFAULT_DIMENSION;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.borderWidth_ = TestCommon::TEST_SIZE;
|
||||
|
||||
comp1.fontColor_.value = TestCommon::TEST_DIFF_COLOR;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.fontColor_.value = TestCommon::TEST_COLOR_RED;
|
||||
|
||||
comp1.bgColor_.value = TestCommon::TEST_DIFF_COLOR;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.bgColor_.value = TestCommon::TEST_COLOR_YELLOW;
|
||||
|
||||
comp1.iconColor_.value = TestCommon::TEST_DIFF_COLOR;
|
||||
ASSERT_FALSE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
comp1.iconColor_.value = TestCommon::TEST_COLOR_BLUE;
|
||||
comp1.bg_ = SecCompBackground::CIRCLE;
|
||||
|
||||
ASSERT_TRUE(comp1.CompareComponentBasicInfo(&comp2, true));
|
||||
}
|
||||
|
||||
@@ -14,13 +14,8 @@
|
||||
*/
|
||||
#include "sec_comp_perm_manager.h"
|
||||
|
||||
#include "location_button.h"
|
||||
#include "paste_button.h"
|
||||
#include "save_button.h"
|
||||
#include "sec_comp_err.h"
|
||||
#include "sec_comp_log.h"
|
||||
#include "sec_comp_service.h"
|
||||
#include "sec_comp_tool.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Security {
|
||||
|
||||
@@ -167,20 +167,29 @@ bool SecCompService::GetCallerInfo(SecCompCallerInfo& caller)
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t SecCompService::ParseParams(const std::string& componentInfo,
|
||||
SecCompCallerInfo& caller, nlohmann::json& jsonRes)
|
||||
{
|
||||
if (!GetCallerInfo(caller)) {
|
||||
SC_LOG_ERROR(LABEL, "Check caller failed");
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
jsonRes = nlohmann::json::parse(componentInfo, nullptr, false);
|
||||
if (jsonRes.is_discarded()) {
|
||||
SC_LOG_ERROR(LABEL, "component info invalid %{public}s", componentInfo.c_str());
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
return SC_OK;
|
||||
}
|
||||
|
||||
int32_t SecCompService::RegisterSecurityComponent(SecCompType type,
|
||||
const std::string& componentInfo, int32_t& scId)
|
||||
{
|
||||
StartTrace(HITRACE_TAG_ACCESS_CONTROL, "SecurityComponentRegister");
|
||||
SecCompCallerInfo caller;
|
||||
if (!GetCallerInfo(caller)) {
|
||||
SC_LOG_ERROR(LABEL, "Check caller failed");
|
||||
FinishTrace(HITRACE_TAG_ACCESS_CONTROL);
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
nlohmann::json jsonRes = nlohmann::json::parse(componentInfo, nullptr, false);
|
||||
if (jsonRes.is_discarded()) {
|
||||
SC_LOG_ERROR(LABEL, "component info invalid %{public}s", componentInfo.c_str());
|
||||
nlohmann::json jsonRes;
|
||||
if (ParseParams(componentInfo, caller, jsonRes) != SC_OK) {
|
||||
FinishTrace(HITRACE_TAG_ACCESS_CONTROL);
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
@@ -193,14 +202,8 @@ int32_t SecCompService::RegisterSecurityComponent(SecCompType type,
|
||||
int32_t SecCompService::UpdateSecurityComponent(int32_t scId, const std::string& componentInfo)
|
||||
{
|
||||
SecCompCallerInfo caller;
|
||||
if (!GetCallerInfo(caller)) {
|
||||
SC_LOG_ERROR(LABEL, "Check caller failed");
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
nlohmann::json jsonRes = nlohmann::json::parse(componentInfo, nullptr, false);
|
||||
if (jsonRes.is_discarded()) {
|
||||
SC_LOG_ERROR(LABEL, "component info invalid %{public}s", componentInfo.c_str());
|
||||
nlohmann::json jsonRes;
|
||||
if (ParseParams(componentInfo, caller, jsonRes) != SC_OK) {
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
return SecCompManager::GetInstance().UpdateSecurityComponent(scId, jsonRes, caller);
|
||||
@@ -222,15 +225,8 @@ int32_t SecCompService::ReportSecurityComponentClickEvent(int32_t scId,
|
||||
{
|
||||
StartTrace(HITRACE_TAG_ACCESS_CONTROL, "SecurityComponentClick");
|
||||
SecCompCallerInfo caller;
|
||||
if (!GetCallerInfo(caller)) {
|
||||
SC_LOG_ERROR(LABEL, "Check caller failed");
|
||||
FinishTrace(HITRACE_TAG_ACCESS_CONTROL);
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
nlohmann::json jsonRes = nlohmann::json::parse(componentInfo, nullptr, false);
|
||||
if (jsonRes.is_discarded()) {
|
||||
SC_LOG_ERROR(LABEL, "component info invalid %{public}s", componentInfo.c_str());
|
||||
nlohmann::json jsonRes;
|
||||
if (ParseParams(componentInfo, caller, jsonRes) != SC_OK) {
|
||||
FinishTrace(HITRACE_TAG_ACCESS_CONTROL);
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <vector>
|
||||
#include "app_state_observer.h"
|
||||
#include "iremote_object.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "nocopyable.h"
|
||||
#include "sec_comp_manager.h"
|
||||
#include "sec_comp_stub.h"
|
||||
@@ -50,6 +51,7 @@ public:
|
||||
int Dump(int fd, const std::vector<std::u16string>& args) override;
|
||||
|
||||
private:
|
||||
int32_t ParseParams(const std::string& componentInfo, SecCompCallerInfo& caller, nlohmann::json& jsonRes);
|
||||
bool Initialize() const;
|
||||
bool RegisterAppStateObserver();
|
||||
void UnregisterAppStateObserver();
|
||||
|
||||
@@ -39,11 +39,11 @@ int32_t SecCompStub::OnRemoteRequest(
|
||||
return SC_SERVICE_ERROR_IPC_REQUEST_FAIL;
|
||||
}
|
||||
|
||||
auto itFunc = requestFuncMap_.find(code);
|
||||
if (itFunc != requestFuncMap_.end()) {
|
||||
auto requestFunc = itFunc->second;
|
||||
if (requestFunc != nullptr) {
|
||||
return (this->*requestFunc)(data, reply);
|
||||
auto funcIter = requestFuncMap_.find(code);
|
||||
if (funcIter != requestFuncMap_.end()) {
|
||||
auto func = funcIter->second;
|
||||
if (func != nullptr) {
|
||||
return (this->*func)(data, reply);
|
||||
}
|
||||
}
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
@@ -53,18 +53,18 @@ int32_t SecCompStub::RegisterSecurityComponentInner(MessageParcel& data, Message
|
||||
{
|
||||
uint32_t type;
|
||||
if (!data.ReadUint32(type)) {
|
||||
SC_LOG_ERROR(LABEL, "Read component type fail");
|
||||
SC_LOG_ERROR(LABEL, "Register read component type fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (type <= UNKNOWN_SC_TYPE || type >= MAX_SC_TYPE) {
|
||||
SC_LOG_ERROR(LABEL, "Security component type invalid");
|
||||
SC_LOG_ERROR(LABEL, "Register security component type invalid");
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
std::string componentInfo;
|
||||
if (!data.ReadString(componentInfo)) {
|
||||
SC_LOG_ERROR(LABEL, "Read component info fail");
|
||||
SC_LOG_ERROR(LABEL, "Register read component info fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
@@ -87,18 +87,18 @@ int32_t SecCompStub::UpdateSecurityComponentInner(MessageParcel& data, MessagePa
|
||||
{
|
||||
int32_t scId;
|
||||
if (!data.ReadInt32(scId)) {
|
||||
SC_LOG_ERROR(LABEL, "Read component id fail");
|
||||
SC_LOG_ERROR(LABEL, "Update read component id fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (scId < 0) {
|
||||
SC_LOG_ERROR(LABEL, "Security component id invalid");
|
||||
SC_LOG_ERROR(LABEL, "Update security component id invalid");
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
std::string componentInfo;
|
||||
if (!data.ReadString(componentInfo)) {
|
||||
SC_LOG_ERROR(LABEL, "Read component info fail");
|
||||
SC_LOG_ERROR(LABEL, "Update read component info fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
@@ -115,12 +115,12 @@ int32_t SecCompStub::UnregisterSecurityComponentInner(MessageParcel& data, Messa
|
||||
{
|
||||
int32_t scId;
|
||||
if (!data.ReadInt32(scId)) {
|
||||
SC_LOG_ERROR(LABEL, "Read component id fail");
|
||||
SC_LOG_ERROR(LABEL, "Unreigster read component id fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (scId < 0) {
|
||||
SC_LOG_ERROR(LABEL, "Security component id invalid");
|
||||
SC_LOG_ERROR(LABEL, "Unreigster security component id invalid");
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
@@ -136,23 +136,23 @@ int32_t SecCompStub::ReportSecurityComponentClickEventInner(MessageParcel& data,
|
||||
{
|
||||
int32_t scId;
|
||||
if (!data.ReadInt32(scId)) {
|
||||
SC_LOG_ERROR(LABEL, "Read component id fail");
|
||||
SC_LOG_ERROR(LABEL, "Report read component id fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (scId < 0) {
|
||||
SC_LOG_ERROR(LABEL, "Security component id invalid");
|
||||
SC_LOG_ERROR(LABEL, "Report security component id invalid");
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
std::string componentInfo;
|
||||
if (!data.ReadString(componentInfo)) {
|
||||
SC_LOG_ERROR(LABEL, "Read component info fail");
|
||||
SC_LOG_ERROR(LABEL, "Report read component info fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
sptr<SecCompClickEventParcel> touchInfoParcel = data.ReadParcelable<SecCompClickEventParcel>();
|
||||
if (touchInfoParcel == nullptr) {
|
||||
SC_LOG_ERROR(LABEL, "Read touchInfo info fail");
|
||||
SC_LOG_ERROR(LABEL, "Report read touchInfo info fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ int32_t SecCompStub::ReportSecurityComponentClickEventInner(MessageParcel& data,
|
||||
int32_t res =
|
||||
this->ReportSecurityComponentClickEvent(scId, componentInfo, touchInfoParcel->touchInfoParams_, callerToken);
|
||||
if (!reply.WriteInt32(res)) {
|
||||
SC_LOG_ERROR(LABEL, "Register security component result fail");
|
||||
SC_LOG_ERROR(LABEL, "Report security component result fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
return SC_OK;
|
||||
@@ -174,18 +174,18 @@ int32_t SecCompStub::ReduceAfterVerifySavePermissionInner(MessageParcel& data, M
|
||||
}
|
||||
uint32_t tokenId;
|
||||
if (!data.ReadUint32(tokenId)) {
|
||||
SC_LOG_ERROR(LABEL, "Read component id fail");
|
||||
SC_LOG_ERROR(LABEL, "Verify read component id fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
|
||||
if (tokenId == 0) {
|
||||
SC_LOG_ERROR(LABEL, "AccessTokenId invalid");
|
||||
SC_LOG_ERROR(LABEL, "Verify AccessTokenId invalid");
|
||||
return SC_SERVICE_ERROR_VALUE_INVALID;
|
||||
}
|
||||
|
||||
bool res = this->ReduceAfterVerifySavePermission(tokenId);
|
||||
if (!reply.WriteBool(res)) {
|
||||
SC_LOG_ERROR(LABEL, "verify temp save permission result fail");
|
||||
SC_LOG_ERROR(LABEL, "Verify temp save permission result fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
return SC_OK;
|
||||
@@ -195,7 +195,7 @@ int32_t SecCompStub::GetEnhanceRemoteObjectInner(MessageParcel& data, MessagePar
|
||||
{
|
||||
auto res = this->GetEnhanceRemoteObject();
|
||||
if (!reply.WriteRemoteObject(res)) {
|
||||
SC_LOG_ERROR(LABEL, "Register security component enhance remote object fail");
|
||||
SC_LOG_ERROR(LABEL, "Security component enhance remote object fail");
|
||||
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
|
||||
}
|
||||
return SC_OK;
|
||||
|
||||
+65
-222
@@ -124,6 +124,17 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent003, TestSize.Level1)
|
||||
ASSERT_EQ(nullptr, comp);
|
||||
}
|
||||
|
||||
static SecCompRect GetDefaultRect(void)
|
||||
{
|
||||
SecCompRect rect = {
|
||||
.x_ = g_testWidth,
|
||||
.y_ = g_testHeight,
|
||||
.width_ = g_testWidth,
|
||||
.height_ = g_testHeight
|
||||
};
|
||||
return rect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ParseComponent004
|
||||
* @tc.desc: Test parse component info with invalid rect
|
||||
@@ -132,18 +143,8 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(SecCompInfoHelperTest, ParseComponent004, TestSize.Level1)
|
||||
{
|
||||
SecCompRect rect = {
|
||||
.x_ = g_testWidth,
|
||||
.y_ = g_testHeight,
|
||||
.width_ = g_testWidth,
|
||||
.height_ = g_testHeight
|
||||
};
|
||||
SecCompRect windowRect = {
|
||||
.x_ = g_testWidth,
|
||||
.y_ = g_testHeight,
|
||||
.width_ = g_testWidth,
|
||||
.height_ = g_testHeight
|
||||
};
|
||||
SecCompRect rect = GetDefaultRect();
|
||||
SecCompRect windowRect = GetDefaultRect();
|
||||
ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect));
|
||||
|
||||
rect.x_ = ServiceTestCommon::TEST_INVALID_DIMENSION;
|
||||
@@ -172,18 +173,8 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(SecCompInfoHelperTest, ParseComponent005, TestSize.Level1)
|
||||
{
|
||||
SecCompRect rect = {
|
||||
.x_ = g_testWidth,
|
||||
.y_ = g_testHeight,
|
||||
.width_ = g_testWidth,
|
||||
.height_ = g_testHeight
|
||||
};
|
||||
SecCompRect windowRect = {
|
||||
.x_ = g_testWidth,
|
||||
.y_ = g_testHeight,
|
||||
.width_ = g_testWidth,
|
||||
.height_ = g_testHeight
|
||||
};
|
||||
SecCompRect rect = GetDefaultRect();
|
||||
SecCompRect windowRect = GetDefaultRect();
|
||||
ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect));
|
||||
|
||||
windowRect.x_ = g_testWidth + 1;
|
||||
@@ -235,51 +226,18 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent007, TestSize.Level1)
|
||||
SecCompBase* comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_TRUE(comp->GetValid());
|
||||
|
||||
nlohmann::json jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_INVALID_DIMENSION },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
auto& sizeJson = jsonComponent[JsonTagConstants::JSON_SIZE_TAG];
|
||||
sizeJson[JsonTagConstants::JSON_FONT_SIZE_TAG] = ServiceTestCommon::TEST_INVALID_DIMENSION;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_INVALID_DIMENSION },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
sizeJson[JsonTagConstants::JSON_FONT_SIZE_TAG] = ServiceTestCommon::TEST_DIMENSION;
|
||||
sizeJson[JsonTagConstants::JSON_ICON_SIZE_TAG] = ServiceTestCommon::TEST_INVALID_DIMENSION;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_INVALID_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
sizeJson[JsonTagConstants::JSON_ICON_SIZE_TAG] = ServiceTestCommon::TEST_DIMENSION;
|
||||
sizeJson[JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG] = ServiceTestCommon::TEST_INVALID_DIMENSION;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
}
|
||||
@@ -297,35 +255,14 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent008, TestSize.Level1)
|
||||
SecCompBase* comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_TRUE(comp->GetValid());
|
||||
|
||||
nlohmann::json jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_INVALID_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
auto& sizeJson = jsonComponent[JsonTagConstants::JSON_SIZE_TAG];
|
||||
auto& paddingJson = sizeJson[JsonTagConstants::JSON_PADDING_SIZE_TAG];
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_TOP_TAG] = ServiceTestCommon::TEST_INVALID_DIMENSION;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_INVALID_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_TOP_TAG] = ServiceTestCommon::TEST_DIMENSION;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_RIGHT_TAG] = ServiceTestCommon::TEST_INVALID_DIMENSION;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
}
|
||||
@@ -343,35 +280,14 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent009, TestSize.Level1)
|
||||
SecCompBase* comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_TRUE(comp->GetValid());
|
||||
|
||||
nlohmann::json jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_INVALID_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
auto& sizesJson = jsonComponent[JsonTagConstants::JSON_SIZE_TAG];
|
||||
auto& paddingsJson = sizesJson[JsonTagConstants::JSON_PADDING_SIZE_TAG];
|
||||
paddingsJson[JsonTagConstants::JSON_PADDING_BOTTOM_TAG] = ServiceTestCommon::TEST_INVALID_DIMENSION;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_INVALID_DIMENSION },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
paddingsJson[JsonTagConstants::JSON_PADDING_BOTTOM_TAG] = ServiceTestCommon::TEST_DIMENSION;
|
||||
paddingsJson[JsonTagConstants::JSON_PADDING_LEFT_TAG] = ServiceTestCommon::TEST_INVALID_DIMENSION;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
}
|
||||
@@ -389,27 +305,18 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent010, TestSize.Level1)
|
||||
SecCompBase* comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_TRUE(comp->GetValid());
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_INVALID },
|
||||
{ JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_BLUE },
|
||||
{ JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
|
||||
};
|
||||
auto& colorJson = jsonComponent[JsonTagConstants::JSON_COLORS_TAG];
|
||||
colorJson[JsonTagConstants::JSON_FONT_COLOR_TAG] = ServiceTestCommon::TEST_COLOR_INVALID;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_RED },
|
||||
{ JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_INVALID },
|
||||
{ JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
|
||||
};
|
||||
colorJson[JsonTagConstants::JSON_FONT_COLOR_TAG] = ServiceTestCommon::TEST_COLOR_RED;
|
||||
colorJson[JsonTagConstants::JSON_ICON_COLOR_TAG] = ServiceTestCommon::TEST_COLOR_INVALID;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_RED },
|
||||
{ JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_BLUE },
|
||||
{ JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_INVALID }
|
||||
};
|
||||
colorJson[JsonTagConstants::JSON_ICON_COLOR_TAG] = ServiceTestCommon::TEST_COLOR_BLUE;
|
||||
colorJson[JsonTagConstants::JSON_BG_COLOR_TAG] = ServiceTestCommon::TEST_COLOR_INVALID;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
}
|
||||
@@ -449,42 +356,18 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent012, TestSize.Level1)
|
||||
SecCompBase* comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_TRUE(comp->GetValid());
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW },
|
||||
{ JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_BLUE },
|
||||
{ JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
|
||||
};
|
||||
auto& colorsJson = jsonComponent[JsonTagConstants::JSON_COLORS_TAG];
|
||||
colorsJson[JsonTagConstants::JSON_FONT_COLOR_TAG] = ServiceTestCommon::TEST_COLOR_YELLOW;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE },
|
||||
};
|
||||
jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_RED },
|
||||
{ JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW },
|
||||
{ JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
|
||||
};
|
||||
colorsJson[JsonTagConstants::JSON_FONT_COLOR_TAG] = ServiceTestCommon::TEST_COLOR_RED;
|
||||
colorsJson[JsonTagConstants::JSON_ICON_COLOR_TAG] = ServiceTestCommon::TEST_COLOR_YELLOW;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::NO_BG_TYPE },
|
||||
};
|
||||
jsonComponent[JsonTagConstants::JSON_COLORS_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_COLOR_TAG, ServiceTestCommon::TEST_COLOR_RED },
|
||||
{ JsonTagConstants::JSON_ICON_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW },
|
||||
{ JsonTagConstants::JSON_BG_COLOR_TAG, ServiceTestCommon::TEST_COLOR_YELLOW }
|
||||
};
|
||||
auto& styleJson = jsonComponent[JsonTagConstants::JSON_STYLE_TAG];
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::NO_BG_TYPE;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
}
|
||||
@@ -502,40 +385,20 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent013, TestSize.Level1)
|
||||
SecCompBase* comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_TRUE(comp->GetValid());
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::NO_BG_TYPE },
|
||||
};
|
||||
nlohmann::json jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
auto& styleJson = jsonComponent[JsonTagConstants::JSON_STYLE_TAG];
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::NO_BG_TYPE;
|
||||
auto& sizeJson = jsonComponent[JsonTagConstants::JSON_SIZE_TAG];
|
||||
auto& paddingJson = sizeJson[JsonTagConstants::JSON_PADDING_SIZE_TAG];
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_RIGHT_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_BOTTOM_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_LEFT_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_TOP_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_RIGHT_TAG] = ServiceTestCommon::TEST_DIMENSION;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_BOTTOM_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_LEFT_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
}
|
||||
@@ -553,41 +416,21 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent014, TestSize.Level1)
|
||||
SecCompBase* comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_TRUE(comp->GetValid());
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_TEXT_TAG, LocationDesc::SELECT_LOCATION },
|
||||
{ JsonTagConstants::JSON_ICON_TAG, LocationIcon::LINE_ICON },
|
||||
{ JsonTagConstants::JSON_BG_TAG, SecCompBackground::NO_BG_TYPE },
|
||||
};
|
||||
auto& styleJson = jsonComponent[JsonTagConstants::JSON_STYLE_TAG];
|
||||
styleJson[JsonTagConstants::JSON_BG_TAG] = SecCompBackground::NO_BG_TYPE;
|
||||
|
||||
nlohmann::json jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
auto& sizeJson = jsonComponent[JsonTagConstants::JSON_SIZE_TAG];
|
||||
auto& paddingJson = sizeJson[JsonTagConstants::JSON_PADDING_SIZE_TAG];
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_TOP_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_RIGHT_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_LEFT_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
|
||||
jsonPadding = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_PADDING_TOP_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
{ JsonTagConstants::JSON_PADDING_RIGHT_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
{ JsonTagConstants::JSON_PADDING_BOTTOM_TAG, MIN_PADDING_WITHOUT_BG },
|
||||
{ JsonTagConstants::JSON_PADDING_LEFT_TAG, ServiceTestCommon::TEST_DIMENSION },
|
||||
};
|
||||
|
||||
jsonComponent[JsonTagConstants::JSON_SIZE_TAG] = nlohmann::json {
|
||||
{ JsonTagConstants::JSON_FONT_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_ICON_SIZE_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_TEXT_ICON_PADDING_TAG, ServiceTestCommon::TEST_SIZE },
|
||||
{ JsonTagConstants::JSON_PADDING_SIZE_TAG, jsonPadding },
|
||||
};
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_TOP_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_RIGHT_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_BOTTOM_TAG] = MIN_PADDING_WITHOUT_BG;
|
||||
paddingJson[JsonTagConstants::JSON_PADDING_LEFT_TAG] = ServiceTestCommon::TEST_DIMENSION;
|
||||
comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent);
|
||||
ASSERT_FALSE(comp->GetValid());
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,6 @@ using namespace OHOS::Security::AccessToken;
|
||||
namespace OHOS {
|
||||
static void GetEnhanceRemoteObjectInnerFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t code = SecurityComponentServiceInterfaceCode::GET_SECURITY_COMPONENT_ENHANCE_OBJECT;
|
||||
MessageParcel datas;
|
||||
datas.WriteInterfaceToken(u"ohos.security.ISecCompService");
|
||||
datas.WriteBuffer(data, size);
|
||||
@@ -36,6 +35,7 @@ static void GetEnhanceRemoteObjectInnerFuzzTest(const uint8_t *data, size_t size
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto service = std::make_shared<SecCompService>(SA_ID_SECURITY_COMPONENT_SERVICE, true);
|
||||
uint32_t code = SecurityComponentServiceInterfaceCode::GET_SECURITY_COMPONENT_ENHANCE_OBJECT;
|
||||
service->OnRemoteRequest(code, datas, reply, option);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
+1
-1
@@ -27,7 +27,6 @@ using namespace OHOS::Security::AccessToken;
|
||||
namespace OHOS {
|
||||
static void ReduceAfterVerifySavePermissionInnerFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t code = SecurityComponentServiceInterfaceCode::VERIFY_TEMP_SAVE_PERMISSION;
|
||||
MessageParcel datas;
|
||||
datas.WriteInterfaceToken(u"ohos.security.ISecCompService");
|
||||
datas.WriteBuffer(data, size);
|
||||
@@ -35,6 +34,7 @@ static void ReduceAfterVerifySavePermissionInnerFuzzTest(const uint8_t *data, si
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto service = std::make_shared<SecCompService>(SA_ID_SECURITY_COMPONENT_SERVICE, true);
|
||||
uint32_t code = SecurityComponentServiceInterfaceCode::VERIFY_TEMP_SAVE_PERMISSION;
|
||||
service->OnRemoteRequest(code, datas, reply, option);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
+1
-1
@@ -28,7 +28,6 @@ using namespace OHOS::Security::AccessToken;
|
||||
namespace OHOS {
|
||||
static void UnregisterSecurityComponentInnerFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t code = SecurityComponentServiceInterfaceCode::UNREGISTER_SECURITY_COMPONENT;
|
||||
MessageParcel datas;
|
||||
datas.WriteInterfaceToken(u"ohos.security.ISecCompService");
|
||||
datas.WriteBuffer(data, size);
|
||||
@@ -36,6 +35,7 @@ static void UnregisterSecurityComponentInnerFuzzTest(const uint8_t *data, size_t
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto service = std::make_shared<SecCompService>(SA_ID_SECURITY_COMPONENT_SERVICE, true);
|
||||
uint32_t code = SecurityComponentServiceInterfaceCode::UNREGISTER_SECURITY_COMPONENT;
|
||||
service->OnRemoteRequest(code, datas, reply, option);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
+1
-1
@@ -28,7 +28,6 @@ using namespace OHOS::Security::AccessToken;
|
||||
namespace OHOS {
|
||||
static void UpdateSecurityComponentInnerFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t code = SecurityComponentServiceInterfaceCode::UPDATE_SECURITY_COMPONENT;
|
||||
MessageParcel datas;
|
||||
datas.WriteInterfaceToken(u"ohos.security.ISecCompService");
|
||||
datas.WriteBuffer(data, size);
|
||||
@@ -36,6 +35,7 @@ static void UpdateSecurityComponentInnerFuzzTest(const uint8_t *data, size_t siz
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto service = std::make_shared<SecCompService>(SA_ID_SECURITY_COMPONENT_SERVICE, true);
|
||||
uint32_t code = SecurityComponentServiceInterfaceCode::UPDATE_SECURITY_COMPONENT;
|
||||
service->OnRemoteRequest(code, datas, reply, option);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user