mirror of
https://github.com/openharmony/arkui_ui_appearance.git
synced 2026-07-19 18:53:32 -04:00
!123 修复无法抛出错误码问题
Merge pull request !123 from zhangzezhong/fix_lose_err_code_d_0901_0728
This commit is contained in:
@@ -544,7 +544,7 @@ ErrCode UiAppearanceAbility::SetDarkMode(int32_t mode, int32_t& funcResult)
|
||||
if (!isCallingPerm) {
|
||||
LOGE("permission verification failed");
|
||||
funcResult = PERMISSION_ERR;
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
auto userId = GetCallingUserId();
|
||||
@@ -558,11 +558,11 @@ ErrCode UiAppearanceAbility::SetDarkMode(int32_t mode, int32_t& funcResult)
|
||||
}
|
||||
if (darkMode != currentDarkMode) {
|
||||
funcResult = OnSetDarkMode(userId, darkMode);
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
} else {
|
||||
LOGW("current color mode is %{public}d, no need to change", darkMode);
|
||||
funcResult = SYS_ERR;
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,16 +635,16 @@ ErrCode UiAppearanceAbility::SetFontScale(const std::string& fontScale, int32_t&
|
||||
if (!isCallingPerm) {
|
||||
LOGE("permission verification failed");
|
||||
funcResult = PERMISSION_ERR;
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
}
|
||||
if (!fontScale.empty()) {
|
||||
funcResult = OnSetFontScale(GetCallingUserId(), fontScale);
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
} else {
|
||||
LOGE("current fontScale is empty!");
|
||||
}
|
||||
funcResult = SYS_ERR;
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
ErrCode UiAppearanceAbility::GetFontScale(std::string& fontScale, int32_t& funcResult)
|
||||
@@ -660,7 +660,7 @@ ErrCode UiAppearanceAbility::GetFontScale(std::string& fontScale, int32_t& funcR
|
||||
}
|
||||
LOGD("get font scale :%{public}s", fontScale.c_str());
|
||||
funcResult = SUCCEEDED;
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
int32_t UiAppearanceAbility::OnSetFontWeightScale(const int32_t userId, const std::string& fontWeightScale)
|
||||
@@ -700,16 +700,16 @@ ErrCode UiAppearanceAbility::SetFontWeightScale(const std::string& fontWeightSca
|
||||
if (!isCallingPerm) {
|
||||
LOGE("permission verification failed");
|
||||
funcResult = PERMISSION_ERR;
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
}
|
||||
if (!fontWeightScale.empty()) {
|
||||
funcResult = OnSetFontWeightScale(GetCallingUserId(), fontWeightScale);
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
} else {
|
||||
LOGE("current fontWeightScale is empty!");
|
||||
}
|
||||
funcResult = SYS_ERR;
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
ErrCode UiAppearanceAbility::GetFontWeightScale(std::string& fontWeightScale, int32_t& funcResult)
|
||||
@@ -726,7 +726,7 @@ ErrCode UiAppearanceAbility::GetFontWeightScale(std::string& fontWeightScale, in
|
||||
|
||||
LOGD("get font weight scale :%{public}s", fontWeightScale.c_str());
|
||||
funcResult = SUCCEEDED;
|
||||
return funcResult;
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
void UiAppearanceAbility::UpdateSmartGestureModeCallback(bool isAutoMode, int32_t userId)
|
||||
|
||||
@@ -101,13 +101,13 @@ HWTEST_F(DarkModeTest, ui_appearance_test_001, TestSize.Level0)
|
||||
auto test = DarkModeTest::GetUiAppearanceAbilityTest();
|
||||
int32_t result = -1;
|
||||
test->SetDarkMode(DarkMode::ALWAYS_DARK, result);
|
||||
EXPECT_EQ(result, 0);
|
||||
EXPECT_EQ(result, UiAppearanceAbilityErrCode::SUCCEEDED);
|
||||
int32_t mode = -1;
|
||||
test->GetDarkMode(mode);
|
||||
EXPECT_EQ(mode, DarkMode::ALWAYS_DARK);
|
||||
|
||||
test->SetDarkMode(DarkMode::ALWAYS_LIGHT, result);
|
||||
EXPECT_EQ(result, 0);
|
||||
EXPECT_EQ(result, UiAppearanceAbilityErrCode::SUCCEEDED);
|
||||
test->GetDarkMode(mode);
|
||||
EXPECT_EQ(mode, DarkMode::ALWAYS_LIGHT);
|
||||
}
|
||||
@@ -269,5 +269,49 @@ HWTEST_F(DarkModeTest, ui_appearance_test_008, TestSize.Level0)
|
||||
test->OnRemoveSystemAbility(APP_MGR_SERVICE_ID, "");
|
||||
EXPECT_EQ(0, test->userSwitchUpdateConfigurationOnceFlag_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ui_appearance_test_010
|
||||
* @tc.desc: Test SetFontScale and GetFontScale APIs when repeatedly setting font scale.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DarkModeTest, ui_appearance_test_010, TestSize.Level0)
|
||||
{
|
||||
LOGI("Test SetFontScale and GetFontScale APIs when repeatedly setting font scale.");
|
||||
|
||||
auto test = DarkModeTest::GetUiAppearanceAbilityTest();
|
||||
int32_t result = -1;
|
||||
test->SetFontScale("", result);
|
||||
EXPECT_EQ(result, UiAppearanceAbilityErrCode::SYS_ERR);
|
||||
std::string scale = "1";
|
||||
test->SetFontScale(scale, result);
|
||||
EXPECT_EQ(result, UiAppearanceAbilityErrCode::SUCCEEDED);
|
||||
std::string scaleGet;
|
||||
test->GetFontScale(scaleGet, result);
|
||||
ASSERT_EQ(result, UiAppearanceAbilityErrCode::SUCCEEDED);
|
||||
EXPECT_EQ(scale, scaleGet);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ui_appearance_test_011
|
||||
* @tc.desc: Test SetFontWeightScale and GetFontWeightScale APIs when repeatedly setting font weight scale.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DarkModeTest, ui_appearance_test_011, TestSize.Level0)
|
||||
{
|
||||
LOGI("Test SetFontWeightScale and GetFontWeightScale APIs when repeatedly setting font weight scale.");
|
||||
|
||||
auto test = DarkModeTest::GetUiAppearanceAbilityTest();
|
||||
int32_t result = -1;
|
||||
test->SetFontWeightScale("", result);
|
||||
EXPECT_EQ(result, UiAppearanceAbilityErrCode::SYS_ERR);
|
||||
std::string scale = "1";
|
||||
test->SetFontWeightScale(scale, result);
|
||||
EXPECT_EQ(result, UiAppearanceAbilityErrCode::SUCCEEDED);
|
||||
std::string scaleGet;
|
||||
test->GetFontWeightScale(scaleGet, result);
|
||||
ASSERT_EQ(result, UiAppearanceAbilityErrCode::SUCCEEDED);
|
||||
EXPECT_EQ(scale, scaleGet);
|
||||
}
|
||||
} // namespace ArkUi::UiAppearance
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user