diff --git a/frameworks/acfwk/test/mock/include/mock_accessible_ability_manager_service_stub.h b/frameworks/acfwk/test/mock/include/mock_accessible_ability_manager_service_stub.h index 87ec5a7b..0c7b39b3 100644 --- a/frameworks/acfwk/test/mock/include/mock_accessible_ability_manager_service_stub.h +++ b/frameworks/acfwk/test/mock/include/mock_accessible_ability_manager_service_stub.h @@ -107,6 +107,23 @@ private: std::shared_ptr handler_; sptr observer_ = nullptr; sptr captionObserver_ = nullptr; + sptr abilityObserver_ = nullptr; + + bool shortkey_ = false; + bool highContrastText_ = false; + bool screenMagnifier_ = false; + bool invertColor_ = false; + bool captionState_ = false; + bool animationOff_ = false; + bool audioMono_ = false; + bool mouseKey_ = false; + int32_t mouseAutoClick_ = 0; + uint32_t contentTimeout_ = 0; + uint32_t daltonizationColorFilter_ = 0; + float audioBalance_ = 0.0; + float brightnessDiscount_ = 0.0; + std::string shortkeyTarget_ = ""; + AccessibilityConfig::CaptionProperty captionProperty_ = {}; }; } // namespace Accessibility } // namespace OHOS diff --git a/frameworks/acfwk/test/mock/src/mock_accessible_ability_manager_service_stub.cpp b/frameworks/acfwk/test/mock/src/mock_accessible_ability_manager_service_stub.cpp index 4ff70360..84b34def 100644 --- a/frameworks/acfwk/test/mock/src/mock_accessible_ability_manager_service_stub.cpp +++ b/frameworks/acfwk/test/mock/src/mock_accessible_ability_manager_service_stub.cpp @@ -61,12 +61,12 @@ void MockAccessibleAbilityManagerServiceStub::SendEvent(const AccessibilityEvent void MockAccessibleAbilityManagerServiceStub::SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) { - (void)caption; + captionProperty_ = caption; } void MockAccessibleAbilityManagerServiceStub::SetCaptionState(const bool state) { - (void)state; + captionState_ = state; } uint32_t MockAccessibleAbilityManagerServiceStub::RegisterStateObserver( @@ -99,8 +99,7 @@ void MockAccessibleAbilityManagerServiceStub::DeregisterElementOperator(const in AccessibilityConfig::CaptionProperty MockAccessibleAbilityManagerServiceStub::GetCaptionProperty() { - AccessibilityConfig::CaptionProperty property = {}; - return property; + return captionProperty_; } uint32_t MockAccessibleAbilityManagerServiceStub::RegisterCaptionObserver( @@ -117,7 +116,7 @@ bool MockAccessibleAbilityManagerServiceStub::GetEnabledState() bool MockAccessibleAbilityManagerServiceStub::GetCaptionState() { - return true; + return captionState_; } bool MockAccessibleAbilityManagerServiceStub::GetTouchGuideState() @@ -139,6 +138,11 @@ bool MockAccessibleAbilityManagerServiceStub::EnableAbility(const std::string &n { (void)name; (void)capabilities; + if (handler_) { + handler_->PostTask(std::bind([this]() { + abilityObserver_->OnAccessibilityEnableAbilityListsChanged(); + }), "NotifyEnableAbility"); + } return true; } @@ -179,76 +183,77 @@ bool MockAccessibleAbilityManagerServiceStub::DisableUITestAbility() void MockAccessibleAbilityManagerServiceStub::SetScreenMagnificationState(const bool state) { - (void)state; + screenMagnifier_ = state; } void MockAccessibleAbilityManagerServiceStub::SetShortKeyState(const bool state) { - (void)state; + shortkey_ = state; } void MockAccessibleAbilityManagerServiceStub::SetMouseKeyState(const bool state) { - (void)state; + mouseKey_ = state; } void MockAccessibleAbilityManagerServiceStub::SetMouseAutoClick(const int32_t time) { - (void)time; + mouseAutoClick_ = time; } void MockAccessibleAbilityManagerServiceStub::SetShortkeyTarget(const std::string &name) { - (void)name; + shortkeyTarget_ = name; } void MockAccessibleAbilityManagerServiceStub::SetHighContrastTextState(const bool state) { - (void)state; + highContrastText_ = state; } void MockAccessibleAbilityManagerServiceStub::SetInvertColorState(const bool state) { - (void)state; + invertColor_ = state; } void MockAccessibleAbilityManagerServiceStub::SetAnimationOffState(const bool state) { - (void)state; + animationOff_ = state; } void MockAccessibleAbilityManagerServiceStub::SetAudioMonoState(const bool state) { - (void)state; + audioMono_ = state; } void MockAccessibleAbilityManagerServiceStub::SetDaltonizationColorFilter(const uint32_t filter) { - (void)filter; + daltonizationColorFilter_ = filter; } void MockAccessibleAbilityManagerServiceStub::SetContentTimeout(const uint32_t time) { - (void)time; + contentTimeout_ = time; } void MockAccessibleAbilityManagerServiceStub::SetBrightnessDiscount(const float discount) { - (void)discount; + brightnessDiscount_ = discount; } void MockAccessibleAbilityManagerServiceStub::SetAudioBalance(const float balance) { - (void)balance; + audioBalance_ = balance; + if (handler_) { - handler_->PostTask(std::bind([this]() { - observer_->OnConfigStateChanged(0); - observer_->OnAudioBalanceChanged(0); - observer_->OnBrightnessDiscountChanged(0); - observer_->OnContentTimeoutChanged(0); - observer_->OnMouseAutoClickChanged(0); - observer_->OnDaltonizationColorFilterChanged(0); - observer_->OnShortkeyTargetChanged("test_target"); + handler_->PostTask(std::bind([this, balance]() { + observer_->OnConfigStateChanged(balance == 0 ? 0 : 0xFFFF); + observer_->OnAudioBalanceChanged(balance == 0 ? 0 : 1); + observer_->OnBrightnessDiscountChanged(balance == 0 ? 0 : 1); + observer_->OnContentTimeoutChanged(balance == 0 ? 0 : 1); + observer_->OnMouseAutoClickChanged(balance == 0 ? 0 : 1); + observer_->OnDaltonizationColorFilterChanged(balance == 0 ? 0 : 1); + observer_->OnShortkeyTargetChanged(balance == 0 ? "test_target1" : "test_target2"); AccessibilityConfig::CaptionProperty testProperty; captionObserver_->OnPropertyChanged(testProperty); }), "NotifyAll"); @@ -257,67 +262,67 @@ void MockAccessibleAbilityManagerServiceStub::SetAudioBalance(const float balanc bool MockAccessibleAbilityManagerServiceStub::GetScreenMagnificationState() { - return true; + return screenMagnifier_; } bool MockAccessibleAbilityManagerServiceStub::GetShortKeyState() { - return true; + return shortkey_; } bool MockAccessibleAbilityManagerServiceStub::GetMouseKeyState() { - return true; + return mouseKey_; } int32_t MockAccessibleAbilityManagerServiceStub::GetMouseAutoClick() { - return MOUSE_AUTO_CLICK_VALUE; + return mouseAutoClick_; } std::string MockAccessibleAbilityManagerServiceStub::GetShortkeyTarget() { - return "test"; + return shortkeyTarget_; } bool MockAccessibleAbilityManagerServiceStub::GetHighContrastTextState() { - return true; + return highContrastText_; } bool MockAccessibleAbilityManagerServiceStub::GetInvertColorState() { - return true; + return invertColor_; } bool MockAccessibleAbilityManagerServiceStub::GetAnimationOffState() { - return true; + return animationOff_; } bool MockAccessibleAbilityManagerServiceStub::GetAudioMonoState() { - return true; + return audioMono_; } uint32_t MockAccessibleAbilityManagerServiceStub::GetDaltonizationColorFilter() { - return 1; + return daltonizationColorFilter_; } uint32_t MockAccessibleAbilityManagerServiceStub::GetContentTimeout() { - return CONTENT_TIMEOUT_VALUE; + return contentTimeout_; } float MockAccessibleAbilityManagerServiceStub::GetBrightnessDiscount() { - return BRIGHTNESS_DISCOUNT_VALUE; + return brightnessDiscount_; } float MockAccessibleAbilityManagerServiceStub::GetAudioBalance() { - return -1; + return audioBalance_; } void MockAccessibleAbilityManagerServiceStub::GetAllConfigs(AccessibilityConfigData &configData) @@ -341,7 +346,7 @@ void MockAccessibleAbilityManagerServiceStub::GetAllConfigs(AccessibilityConfigD void MockAccessibleAbilityManagerServiceStub::RegisterEnableAbilityListsObserver( const sptr &observer) { - (void)observer; + abilityObserver_ = observer; return; } diff --git a/frameworks/acfwk/test/unittest/accessibility_config_impl_test.cpp b/frameworks/acfwk/test/unittest/accessibility_config_impl_test.cpp index f3be3629..14f214aa 100644 --- a/frameworks/acfwk/test/unittest/accessibility_config_impl_test.cpp +++ b/frameworks/acfwk/test/unittest/accessibility_config_impl_test.cpp @@ -24,10 +24,9 @@ using namespace testing::ext; namespace OHOS { namespace AccessibilityConfig { namespace { - constexpr uint32_t CONTENT_TIMEOUT_VALUE = 10; - constexpr int32_t MOUSE_AUTO_CLICK_VALUE = 10; - constexpr float BRIGHTNESS_DISCOUNT_VALUE = 0.3f; -} + constexpr float BRIGHTNESS_DISCOUNT_VALUE = 0.2f; +} // namespace + class AccessibilityConfigImplTest : public ::testing::Test { public: AccessibilityConfigImplTest() @@ -61,42 +60,56 @@ public: {} }; +class MockAccessibilityEnableAbilityListsObserverImpl : + public OHOS::AccessibilityConfig::AccessibilityEnableAbilityListsObserver { +public: + MockAccessibilityEnableAbilityListsObserverImpl() = default; + virtual void OnEnableAbilityListsStateChanged() override + {} +}; + /** * @tc.number: SetCaptionProperty_002 * @tc.name: SetCaptionProperty_002 - * @tc.desc: Test function SetCaptionsProperty + * @tc.desc: Test function SetCaptionsProperty GetCaptionsProperty */ HWTEST_F(AccessibilityConfigImplTest, SetCaptionProperty_002, TestSize.Level1) { GTEST_LOG_(INFO) << "SetCaptionProperty_002 start"; CaptionProperty caption; + CaptionProperty value; caption.SetFontFamily("sansSerif"); auto &instance = Singleton::GetInstance(); instance.SetCaptionsProperty(caption); + instance.GetCaptionsProperty(value); + EXPECT_STREQ(value.GetFontFamily().c_str(), "default"); GTEST_LOG_(INFO) << "SetCaptionProperty_002 end"; } /** * @tc.number: SetScreenMagnificationState_002 * @tc.name: SetScreenMagnificationState_002 - * @tc.desc: Test function SetScreenMagnificationState + * @tc.desc: Test function SetScreenMagnificationState GetScreenMagnificationState */ HWTEST_F(AccessibilityConfigImplTest, SetScreenMagnificationState_002, TestSize.Level1) { GTEST_LOG_(INFO) << "SetScreenMagnificationState_002 start"; bool state = true; + bool value = false; auto &instance = Singleton::GetInstance(); instance.SetScreenMagnificationState(state); + instance.GetScreenMagnificationState(value); + EXPECT_FALSE(value); GTEST_LOG_(INFO) << "SetScreenMagnificationState_002 end"; } /** * @tc.number: SetShortKeyState_002 * @tc.name: SetShortKeyState_002 - * @tc.desc: Test function SetShortKeyState + * @tc.desc: Test function SetShortKeyState GetShortKeyState * @tc.require: issueI5NTXH */ HWTEST_F(AccessibilityConfigImplTest, SetShortKeyState_002, TestSize.Level1) @@ -104,45 +117,54 @@ HWTEST_F(AccessibilityConfigImplTest, SetShortKeyState_002, TestSize.Level1) GTEST_LOG_(INFO) << "SetShortKeyState_002 start"; bool state = true; + bool value = false; auto &instance = Singleton::GetInstance(); instance.SetShortKeyState(state); + instance.GetShortKeyState(value); + EXPECT_FALSE(value); GTEST_LOG_(INFO) << "SetShortKeyState_002 end"; } /** * @tc.number: SetMouseKeyState_002 * @tc.name: SetMouseKeyState_002 - * @tc.desc: Test function SetMouseKeyState + * @tc.desc: Test function SetMouseKeyState GetMouseKeyState * @tc.require: issueI5NTXA */ HWTEST_F(AccessibilityConfigImplTest, SetMouseKeyState_002, TestSize.Level1) { GTEST_LOG_(INFO) << "SetMouseKeyState_002 start"; bool state = true; + bool value = false; auto &instance = Singleton::GetInstance(); instance.SetMouseKeyState(state); + instance.GetMouseKeyState(value); + EXPECT_FALSE(value); GTEST_LOG_(INFO) << "SetMouseKeyState_002 end"; } /** * @tc.number: SetCaptionsState_002 * @tc.name: SetCaptionsState_002 - * @tc.desc: Test function SetCaptionsState + * @tc.desc: Test function SetCaptionsState GetCaptionsState */ HWTEST_F(AccessibilityConfigImplTest, SetCaptionsState_002, TestSize.Level1) { GTEST_LOG_(INFO) << "SetCaptionsState_002 start"; bool state = true; + bool value = false; auto &instance = Singleton::GetInstance(); instance.SetCaptionsState(state); + instance.GetCaptionsState(value); + EXPECT_FALSE(value); GTEST_LOG_(INFO) << "SetCaptionsState_002 end"; } /** * @tc.number: SetMouseAutoClick_002 * @tc.name: SetMouseAutoClick_002 - * @tc.desc: Test function SetMouseAutoClick + * @tc.desc: Test function SetMouseAutoClick GetMouseAutoClick * @tc.require: issueI5NTXC */ HWTEST_F(AccessibilityConfigImplTest, SetMouseAutoClick_002, TestSize.Level1) @@ -150,15 +172,18 @@ HWTEST_F(AccessibilityConfigImplTest, SetMouseAutoClick_002, TestSize.Level1) GTEST_LOG_(INFO) << "SetMouseAutoClick_002 start"; int32_t time = 10; + int32_t value = 0; auto &instance = Singleton::GetInstance(); instance.SetMouseAutoClick(time); + instance.GetMouseAutoClick(value); + EXPECT_EQ(0, value); GTEST_LOG_(INFO) << "SetMouseAutoClick_002 end"; } /** * @tc.number: SetShortkeyTarget_002 * @tc.name: SetShortkeyTarget_002 - * @tc.desc: Test function SetShortkeyTarget + * @tc.desc: Test function SetShortkeyTarget GetShortkeyTarget * @tc.require: issueI5NTXH */ HWTEST_F(AccessibilityConfigImplTest, SetShortkeyTarget_002, TestSize.Level1) @@ -166,15 +191,18 @@ HWTEST_F(AccessibilityConfigImplTest, SetShortkeyTarget_002, TestSize.Level1) GTEST_LOG_(INFO) << "SetShortkeyTarget_002 start"; std::string name = "test"; + std::string value = ""; auto &instance = Singleton::GetInstance(); instance.SetShortkeyTarget(name); + instance.GetShortkeyTarget(value); + EXPECT_STREQ(value.c_str(), ""); GTEST_LOG_(INFO) << "SetShortkeyTarget_002 end"; } /** * @tc.number: SetHighContrastTextState_002 * @tc.name: SetHighContrastTextState_002 - * @tc.desc: Test function SetHighContrastTextState + * @tc.desc: Test function SetHighContrastTextState GetHighContrastTextState * @tc.require: issueI5NTX9 */ HWTEST_F(AccessibilityConfigImplTest, SetHighContrastTextState_002, TestSize.Level1) @@ -182,15 +210,18 @@ HWTEST_F(AccessibilityConfigImplTest, SetHighContrastTextState_002, TestSize.Lev GTEST_LOG_(INFO) << "SetHighContrastTextState_002 start"; bool state = true; + bool value = false; auto &instance = Singleton::GetInstance(); instance.SetHighContrastTextState(state); + instance.GetHighContrastTextState(value); + EXPECT_FALSE(value); GTEST_LOG_(INFO) << "SetHighContrastTextState_002 end"; } /** * @tc.number: SetInvertColorState_002 * @tc.name: SetInvertColorState_002 - * @tc.desc: Test function SetInvertColorState + * @tc.desc: Test function SetInvertColorState GetInvertColorState * @tc.require: issueI5NTX7 */ HWTEST_F(AccessibilityConfigImplTest, SetInvertColorState_002, TestSize.Level1) @@ -198,15 +229,18 @@ HWTEST_F(AccessibilityConfigImplTest, SetInvertColorState_002, TestSize.Level1) GTEST_LOG_(INFO) << "SetInvertColorState_002 start"; bool state = true; + bool value = false; auto &instance = Singleton::GetInstance(); instance.SetInvertColorState(state); + instance.GetInvertColorState(value); + EXPECT_FALSE(value); GTEST_LOG_(INFO) << "SetInvertColorState_002 end"; } /** * @tc.number: SetDaltonizationColorFilter_002 * @tc.name: SetDaltonizationColorFilter_002 - * @tc.desc: Test function SetDaltonizationColorFilter + * @tc.desc: Test function SetDaltonizationColorFilter GetDaltonizationColorFilter * @tc.require: issueI5NTX8 */ HWTEST_F(AccessibilityConfigImplTest, SetDaltonizationColorFilter_002, TestSize.Level1) @@ -214,15 +248,18 @@ HWTEST_F(AccessibilityConfigImplTest, SetDaltonizationColorFilter_002, TestSize. GTEST_LOG_(INFO) << "SetDaltonizationColorFilter_002 start"; DALTONIZATION_TYPE type = Protanomaly; + DALTONIZATION_TYPE value = Normal; auto &instance = Singleton::GetInstance(); instance.SetDaltonizationColorFilter(type); + instance.GetDaltonizationColorFilter(value); + EXPECT_EQ(0, static_cast(value)); GTEST_LOG_(INFO) << "SetDaltonizationColorFilter_002 end"; } /** * @tc.number: SetContentTimeout_002 * @tc.name: SetContentTimeout_002 - * @tc.desc: Test function SetContentTimeout + * @tc.desc: Test function SetContentTimeout GetContentTimeout * @tc.require: issueI5NTXF */ HWTEST_F(AccessibilityConfigImplTest, SetContentTimeout_002, TestSize.Level1) @@ -230,15 +267,18 @@ HWTEST_F(AccessibilityConfigImplTest, SetContentTimeout_002, TestSize.Level1) GTEST_LOG_(INFO) << "SetContentTimeout_002 start"; uint32_t timer = 10; + uint32_t value = 0; auto &instance = Singleton::GetInstance(); instance.SetContentTimeout(timer); + instance.GetContentTimeout(value); + EXPECT_EQ(0, value); GTEST_LOG_(INFO) << "SetContentTimeout_002 end"; } /** * @tc.number: SetAnimationOffState_002 * @tc.name: SetAnimationOffState_002 - * @tc.desc: Test function SetAnimationOffState + * @tc.desc: Test function SetAnimationOffState GetAnimationOffState * @tc.require: issueI5NTXG */ HWTEST_F(AccessibilityConfigImplTest, SetAnimationOffState_002, TestSize.Level1) @@ -246,302 +286,66 @@ HWTEST_F(AccessibilityConfigImplTest, SetAnimationOffState_002, TestSize.Level1) GTEST_LOG_(INFO) << "SetAnimationOffState_002 start"; bool state = true; + bool value = false; auto &instance = Singleton::GetInstance(); instance.SetAnimationOffState(state); + instance.GetAnimationOffState(value); + EXPECT_FALSE(value); GTEST_LOG_(INFO) << "SetAnimationOffState_002 end"; } /** * @tc.number: SetBrightnessDiscount_002 * @tc.name: SetBrightnessDiscount_002 - * @tc.desc: Test function SetBrightnessDiscount + * @tc.desc: Test function SetBrightnessDiscount GetBrightnessDiscount * @tc.require: issueI5NTXE */ HWTEST_F(AccessibilityConfigImplTest, SetBrightnessDiscount_002, TestSize.Level1) { GTEST_LOG_(INFO) << "SetBrightnessDiscount_002 start"; - float brightness = 0.2; + float brightness = BRIGHTNESS_DISCOUNT_VALUE; + float value = 0; auto &instance = Singleton::GetInstance(); instance.SetBrightnessDiscount(brightness); + instance.GetBrightnessDiscount(value); + EXPECT_FLOAT_EQ(0, value); GTEST_LOG_(INFO) << "SetBrightnessDiscount_002 end"; } /** * @tc.number: SetAudioMonoState_002 * @tc.name: SetAudioMonoState_002 - * @tc.desc: Test function SetAudioMonoState + * @tc.desc: Test function SetAudioMonoState GetAudioMonoState */ HWTEST_F(AccessibilityConfigImplTest, SetAudioMonoState_002, TestSize.Level1) { GTEST_LOG_(INFO) << "SetAudioMonoState_002 start"; bool state = true; + bool value = false; auto &instance = Singleton::GetInstance(); instance.SetAudioMonoState(state); + instance.GetAudioMonoState(value); + EXPECT_FALSE(value); GTEST_LOG_(INFO) << "SetAudioMonoState_002 end"; } /** * @tc.number: SetAudioBalance_002 * @tc.name: SetAudioBalance_002 - * @tc.desc: Test function SetAudioBalance + * @tc.desc: Test function SetAudioBalance GetAudioBalance */ HWTEST_F(AccessibilityConfigImplTest, SetAudioBalance_002, TestSize.Level1) { GTEST_LOG_(INFO) << "SetAudioBalance_002 start"; float balance = -1.0; + float value = 0; auto &instance = Singleton::GetInstance(); instance.SetAudioBalance(balance); - GTEST_LOG_(INFO) << "SetAudioBalance_002 end"; -} - -/** - * @tc.number: GetScreenMagnificationState_002 - * @tc.name: GetScreenMagnificationState_002 - * @tc.desc: Test function GetScreenMagnificationState - */ -HWTEST_F(AccessibilityConfigImplTest, GetScreenMagnificationState_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetScreenMagnificationState_002 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.GetScreenMagnificationState(value); - EXPECT_FALSE(value); - GTEST_LOG_(INFO) << "GetScreenMagnificationState_002 end"; -} - -/** - * @tc.number: GetShortKeyState_002 - * @tc.name: GetShortKeyState_002 - * @tc.desc: Test function GetShortKeyState - * @tc.require: issueI5NTXH - */ -HWTEST_F(AccessibilityConfigImplTest, GetShortKeyState_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetShortKeyState_002 start"; - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.GetShortKeyState(value); - EXPECT_FALSE(value); - GTEST_LOG_(INFO) << "GetShortKeyState_002 end"; -} - -/** - * @tc.number: GetMouseKeyState_002 - * @tc.name: GetMouseKeyState_002 - * @tc.desc: Test function GetMouseKeyState - * @tc.require: issueI5NTXA - */ -HWTEST_F(AccessibilityConfigImplTest, GetMouseKeyState_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetMouseKeyState_002 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.GetMouseKeyState(value); - EXPECT_FALSE(value); - GTEST_LOG_(INFO) << "GetMouseKeyState_002 end"; -} - -/** - * @tc.number: GetCaptionsState_002 - * @tc.name: GetCaptionsState_002 - * @tc.desc: Test function GetCaptionsState - */ -HWTEST_F(AccessibilityConfigImplTest, GetCaptionsState_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetCaptionsState_002 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.GetCaptionsState(value); - EXPECT_FALSE(value); - GTEST_LOG_(INFO) << "GetCaptionsState_002 end"; -} - -/** - * @tc.number: GetCaptionsProperty_002 - * @tc.name: GetCaptionsProperty_002 - * @tc.desc: Test function GetCaptionsProperty - */ -HWTEST_F(AccessibilityConfigImplTest, GetCaptionsProperty_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetCaptionsProperty_002 start"; - - CaptionProperty value; - auto &instance = Singleton::GetInstance(); - instance.GetCaptionsProperty(value); - GTEST_LOG_(INFO) << "GetCaptionsProperty_002 end"; -} - -/** - * @tc.number: GetMouseAutoClick_002 - * @tc.name: GetMouseAutoClick_002 - * @tc.desc: Test function GetMouseAutoClick - * @tc.require: issueI5NTXC - */ -HWTEST_F(AccessibilityConfigImplTest, GetMouseAutoClick_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetMouseAutoClick_002 start"; - - int32_t value = 0; - auto &instance = Singleton::GetInstance(); - instance.GetMouseAutoClick(value); - EXPECT_EQ(0, value); - GTEST_LOG_(INFO) << "GetMouseAutoClick_002 end"; -} - -/** - * @tc.number: GetShortkeyTarget_002 - * @tc.name: GetShortkeyTarget_002 - * @tc.desc: Test function GetShortkeyTarget - * @tc.require: issueI5NTXH - */ -HWTEST_F(AccessibilityConfigImplTest, GetShortkeyTarget_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetShortkeyTarget_002 start"; - - std::string value = ""; - auto &instance = Singleton::GetInstance(); - instance.GetShortkeyTarget(value); - EXPECT_STREQ(value.c_str(), ""); - GTEST_LOG_(INFO) << "GetShortkeyTarget_002 end"; -} - -/** - * @tc.number: GetInvertColorState_002 - * @tc.name: GetInvertColorState_002 - * @tc.desc: Test function GetInvertColorState - * @tc.require: issueI5NTX7 - */ -HWTEST_F(AccessibilityConfigImplTest, GetInvertColorState_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetInvertColorState_002 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.GetInvertColorState(value); - EXPECT_FALSE(value); - GTEST_LOG_(INFO) << "GetInvertColorState_002 end"; -} - -/** - * @tc.number:GetHighContrastTextState_002 - * @tc.name: GetHighContrastTextState_002 - * @tc.desc: Test function GetHighContrastTextState - * @tc.require: issueI5NTX9 - */ -HWTEST_F(AccessibilityConfigImplTest, GetHighContrastTextState_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetHighContrastTextState_002 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.GetHighContrastTextState(value); - EXPECT_FALSE(value); - GTEST_LOG_(INFO) << "GetHighContrastTextState_002 end"; -} - -/** - * @tc.number: GetDaltonizationColorFilter_002 - * @tc.name: GetDaltonizationColorFilter_002 - * @tc.desc: Test function GetDaltonizationColorFilter - * @tc.require: issueI5NTX8 - */ -HWTEST_F(AccessibilityConfigImplTest, GetDaltonizationColorFilter_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetDaltonizationColorFilter_002 start"; - - DALTONIZATION_TYPE value = Normal; - auto &instance = Singleton::GetInstance(); - instance.GetDaltonizationColorFilter(value); - EXPECT_EQ(0, static_cast(value)); - GTEST_LOG_(INFO) << "GetDaltonizationColorFilter_002 end"; -} - -/** - * @tc.number: GetContentTimeout_002 - * @tc.name: GetContentTimeout_002 - * @tc.desc: Test function GetContentTimeout - * @tc.require: issueI5NTXF - */ -HWTEST_F(AccessibilityConfigImplTest, GetContentTimeout_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetContentTimeout_002 start"; - - uint32_t value = 0; - auto &instance = Singleton::GetInstance(); - instance.GetContentTimeout(value); - EXPECT_EQ(0, value); - GTEST_LOG_(INFO) << "GetContentTimeout_002 end"; -} - -/** - * @tc.number: GetAnimationOffState_002 - * @tc.name: GetAnimationOffState_002 - * @tc.desc: Test function GetAnimationOffState - * @tc.require: issueI5NTXG - */ -HWTEST_F(AccessibilityConfigImplTest, GetAnimationOffState_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetAnimationOffState_002 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.GetAnimationOffState(value); - EXPECT_FALSE(value); - GTEST_LOG_(INFO) << "GetAnimationOffState_002 end"; -} - -/** - * @tc.number: GetBrightnessDiscount_002 - * @tc.name: GetBrightnessDiscount_002 - * @tc.desc: Test function GetBrightnessDiscount - * @tc.require: issueI5NTXE - */ -HWTEST_F(AccessibilityConfigImplTest, GetBrightnessDiscount_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetBrightnessDiscount_002 start"; - - float value = 0; - auto &instance = Singleton::GetInstance(); - instance.GetBrightnessDiscount(value); - EXPECT_FLOAT_EQ(0, value); - GTEST_LOG_(INFO) << "GetBrightnessDiscount_002 end"; -} - -/** - * @tc.number: GetAudioMonoState_002 - * @tc.name: GetAudioMonoState_002 - * @tc.desc: Test function GetAudioMonoState - */ -HWTEST_F(AccessibilityConfigImplTest, GetAudioMonoState_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetAudioMonoState_002 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.GetAudioMonoState(value); - EXPECT_FALSE(value); - GTEST_LOG_(INFO) << "GetAudioMonoState_002 end"; -} - -/** - * @tc.number: GetAudioBalance_002 - * @tc.name: GetAudioBalance_002 - * @tc.desc: Test function GetAudioBalance - */ -HWTEST_F(AccessibilityConfigImplTest, GetAudioBalance_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetAudioBalance_002 start"; - - float value = 0; - auto &instance = Singleton::GetInstance(); instance.GetAudioBalance(value); EXPECT_FLOAT_EQ(0, value); - GTEST_LOG_(INFO) << "GetAudioBalance_002 end"; + GTEST_LOG_(INFO) << "SetAudioBalance_002 end"; } /** @@ -560,10 +364,305 @@ HWTEST_F(AccessibilityConfigImplTest, ConnectToService_001, TestSize.Level1) GTEST_LOG_(INFO) << "ConnectToService_001 end"; } +/** + * @tc.number: SetCaptionProperty_001 + * @tc.name: SetCaptionProperty_001 + * @tc.desc: Test function SetCaptionsProperty GetCaptionsProperty + */ +HWTEST_F(AccessibilityConfigImplTest, SetCaptionProperty_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetCaptionProperty_001 start"; + + CaptionProperty caption; + caption.SetFontFamily("sansSerif"); + CaptionProperty value; + + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetCaptionsProperty(caption); + instance.GetCaptionsProperty(value); + EXPECT_STREQ(caption.GetFontFamily().c_str(), value.GetFontFamily().c_str()); + GTEST_LOG_(INFO) << "SetCaptionProperty_001 end"; +} + +/** + * @tc.number: SetScreenMagnificationState_001 + * @tc.name: SetScreenMagnificationState_001 + * @tc.desc: Test function SetScreenMagnificationState GetScreenMagnificationState + */ +HWTEST_F(AccessibilityConfigImplTest, SetScreenMagnificationState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetScreenMagnificationState_001 start"; + + bool state = true; + bool value = false; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetScreenMagnificationState(state); + instance.GetScreenMagnificationState(value); + EXPECT_TRUE(value); + GTEST_LOG_(INFO) << "SetScreenMagnificationState_001 end"; +} + +/** + * @tc.number: SetShortKeyState_001 + * @tc.name: SetShortKeyState_001 + * @tc.desc: Test function SetShortKeyState GetShortKeyState + * @tc.require: issueI5NTXH + */ +HWTEST_F(AccessibilityConfigImplTest, SetShortKeyState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetShortKeyState_001 start"; + bool state = true; + bool value = false; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetShortKeyState(state); + instance.GetShortKeyState(value); + EXPECT_TRUE(value); + GTEST_LOG_(INFO) << "SetShortKeyState_001 end"; +} + +/** + * @tc.number: SetMouseKeyState_001 + * @tc.name: SetMouseKeyState_001 + * @tc.desc: Test function SetMouseKeyState GetMouseKeyState + * @tc.require: issueI5NTXA + */ +HWTEST_F(AccessibilityConfigImplTest, SetMouseKeyState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetMouseKeyState_001 start"; + bool state = true; + bool value = false; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetMouseKeyState(state); + instance.GetMouseKeyState(value); + EXPECT_TRUE(value); + GTEST_LOG_(INFO) << "SetMouseKeyState_001 end"; +} + +/** + * @tc.number: SetCaptionsState_001 + * @tc.name: SetCaptionsState_001 + * @tc.desc: Test function SetCaptionsState GetCaptionsState + */ +HWTEST_F(AccessibilityConfigImplTest, SetCaptionsState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetCaptionsState_001 start"; + + bool state = true; + bool value = false; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetCaptionsState(state); + instance.GetCaptionsState(value); + EXPECT_TRUE(value); + GTEST_LOG_(INFO) << "SetCaptionsState_001 end"; +} + +/** + * @tc.number: SetMouseAutoClick_001 + * @tc.name: SetMouseAutoClick_001 + * @tc.desc: Test function SetMouseAutoClick GetMouseAutoClick + * @tc.require: issueI5NTXC + */ +HWTEST_F(AccessibilityConfigImplTest, SetMouseAutoClick_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetMouseAutoClick_001 start"; + + int32_t time = 10; + int32_t value = 0; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetMouseAutoClick(time); + instance.GetMouseAutoClick(value); + EXPECT_EQ(time, value); + GTEST_LOG_(INFO) << "SetMouseAutoClick_001 end"; +} + +/** + * @tc.number: SetShortkeyTarget_001 + * @tc.name: SetShortkeyTarget_001 + * @tc.desc: Test function SetShortkeyTarget GetShortkeyTarget + * @tc.require: issueI5NTXH + */ +HWTEST_F(AccessibilityConfigImplTest, SetShortkeyTarget_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetShortkeyTarget_001 start"; + + std::string name = "test"; + std::string value = ""; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetShortkeyTarget(name); + instance.GetShortkeyTarget(value); + EXPECT_STREQ(name.c_str(), value.c_str()); + GTEST_LOG_(INFO) << "SetShortkeyTarget_001 end"; +} + +/** + * @tc.number: SetHighContrastTextState_001 + * @tc.name: SetHighContrastTextState_001 + * @tc.desc: Test function SetHighContrastTextState GetHighContrastTextState + * @tc.require: issueI5NTX9 + */ +HWTEST_F(AccessibilityConfigImplTest, SetHighContrastTextState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetHighContrastTextState_001 start"; + + bool state = true; + bool value = false; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetHighContrastTextState(state); + instance.GetHighContrastTextState(value); + EXPECT_TRUE(value); + GTEST_LOG_(INFO) << "SetHighContrastTextState_001 end"; +} + +/** + * @tc.number: SetInvertColorState_001 + * @tc.name: SetInvertColorState_001 + * @tc.desc: Test function SetInvertColorState GetInvertColorState + * @tc.require: issueI5NTX7 + */ +HWTEST_F(AccessibilityConfigImplTest, SetInvertColorState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetInvertColorState_001 start"; + + bool state = true; + bool value = false; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetInvertColorState(state); + instance.GetInvertColorState(value); + EXPECT_TRUE(value); + GTEST_LOG_(INFO) << "SetInvertColorState_001 end"; +} + +/** + * @tc.number: SetDaltonizationColorFilter_001 + * @tc.name: SetDaltonizationColorFilter_001 + * @tc.desc: Test function SetDaltonizationColorFilter GetDaltonizationColorFilter + * @tc.require: issueI5NTX8 + */ +HWTEST_F(AccessibilityConfigImplTest, SetDaltonizationColorFilter_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetDaltonizationColorFilter_001 start"; + + DALTONIZATION_TYPE type = Protanomaly; + DALTONIZATION_TYPE value = Normal; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetDaltonizationColorFilter(type); + instance.GetDaltonizationColorFilter(value); + EXPECT_EQ(static_cast(type), static_cast(value)); + GTEST_LOG_(INFO) << "SetDaltonizationColorFilter_001 end"; +} + +/** + * @tc.number: SetContentTimeout_001 + * @tc.name: SetContentTimeout_001 + * @tc.desc: Test function SetContentTimeout GetContentTimeout + * @tc.require: issueI5NTXF + */ +HWTEST_F(AccessibilityConfigImplTest, SetContentTimeout_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetContentTimeout_001 start"; + + uint32_t timer = 10; + uint32_t value = 0; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetContentTimeout(timer); + instance.GetContentTimeout(value); + EXPECT_EQ(timer, value); + GTEST_LOG_(INFO) << "SetContentTimeout_001 end"; +} + +/** + * @tc.number: SetAnimationOffState_001 + * @tc.name: SetAnimationOffState_001 + * @tc.desc: Test function SetAnimationOffState GetAnimationOffState + * @tc.require: issueI5NTXG + */ +HWTEST_F(AccessibilityConfigImplTest, SetAnimationOffState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetAnimationOffState_001 start"; + + bool state = true; + bool value = false; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetAnimationOffState(state); + instance.GetAnimationOffState(value); + EXPECT_TRUE(value); + GTEST_LOG_(INFO) << "SetAnimationOffState_001 end"; +} + +/** + * @tc.number: SetBrightnessDiscount_001 + * @tc.name: SetBrightnessDiscount_001 + * @tc.desc: Test function SetBrightnessDiscount GetBrightnessDiscount + * @tc.require: issueI5NTXE + */ +HWTEST_F(AccessibilityConfigImplTest, SetBrightnessDiscount_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetBrightnessDiscount_001 start"; + + float brightness = 0; + float value = BRIGHTNESS_DISCOUNT_VALUE; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetBrightnessDiscount(brightness); + instance.GetBrightnessDiscount(value); + EXPECT_FLOAT_EQ(brightness, value); + GTEST_LOG_(INFO) << "SetBrightnessDiscount_001 end"; +} + +/** + * @tc.number: SetAudioMonoState_001 + * @tc.name: SetAudioMonoState_001 + * @tc.desc: Test function SetAudioMonoState GetAudioMonoState + */ +HWTEST_F(AccessibilityConfigImplTest, SetAudioMonoState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetAudioMonoState_001 start"; + + bool state = true; + bool value = false; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetAudioMonoState(state); + instance.GetAudioMonoState(value); + EXPECT_TRUE(value); + GTEST_LOG_(INFO) << "SetAudioMonoState_001 end"; +} + +/** + * @tc.number: SetAudioBalance_001 + * @tc.name: SetAudioBalance_001 + * @tc.desc: Test function SetAudioBalance GetAudioBalance + */ +HWTEST_F(AccessibilityConfigImplTest, SetAudioBalance_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetAudioBalance_001 start"; + float balance = 0; + float value = 0; + auto &instance = Singleton::GetInstance(); + instance.InitializeContext(); + instance.SetAudioBalance(balance); + instance.GetAudioBalance(value); + EXPECT_FLOAT_EQ(balance, value); + sleep(1); + GTEST_LOG_(INFO) << "SetAudioBalance_001 end"; +} + /** * @tc.number: ConfigNotify_001 * @tc.name: ConfigNotify_001 - * @tc.desc: Test function SetAudioBalance + * @tc.desc: Test function OnConfigStateChanged */ HWTEST_F(AccessibilityConfigImplTest, ConfigNotify_001, TestSize.Level1) { @@ -578,523 +677,52 @@ HWTEST_F(AccessibilityConfigImplTest, ConfigNotify_001, TestSize.Level1) } instance.SetAudioBalance(balance); sleep(1); + instance.SetAudioBalance(balance); + sleep(1); + for (int32_t index = 0; index < static_cast(CONFIG_ID_MAX); index ++) { + instance.UnsubscribeConfigObserver(static_cast(index), observer); + } GTEST_LOG_(INFO) << "ConfigNotify_001 end"; } /** - * @tc.number: SetCaptionProperty_001 - * @tc.name: SetCaptionProperty_001 - * @tc.desc: Test function SetCaptionsProperty + * @tc.number: ConfigNotify_002 + * @tc.name: ConfigNotify_002 + * @tc.desc: Test function OnConfigStateChanged */ -HWTEST_F(AccessibilityConfigImplTest, SetCaptionProperty_001, TestSize.Level1) +HWTEST_F(AccessibilityConfigImplTest, ConfigNotify_002, TestSize.Level1) { - GTEST_LOG_(INFO) << "SetCaptionProperty_001 start"; - - CaptionProperty caption; - caption.SetFontFamily("sansSerif"); - + GTEST_LOG_(INFO) << "ConfigNotify_002 start"; + float balance = 0; auto &instance = Singleton::GetInstance(); + std::shared_ptr observer = + std::make_shared(); instance.InitializeContext(); - instance.SetCaptionsProperty(caption); - GTEST_LOG_(INFO) << "SetCaptionProperty_001 end"; + for (int32_t index = 0; index < static_cast(CONFIG_ID_MAX); index ++) { + instance.SubscribeConfigObserver(static_cast(index), observer); + } + instance.SetAudioBalance(balance); + sleep(1); + GTEST_LOG_(INFO) << "ConfigNotify_002 end"; } /** - * @tc.number: SetScreenMagnificationState_001 - * @tc.name: SetScreenMagnificationState_001 - * @tc.desc: Test function SetScreenMagnificationState + * @tc.number: ConfigNotify_003 + * @tc.name: ConfigNotify_003 + * @tc.desc: Test function OnConfigStateChanged */ -HWTEST_F(AccessibilityConfigImplTest, SetScreenMagnificationState_001, TestSize.Level1) +HWTEST_F(AccessibilityConfigImplTest, ConfigNotify_003, TestSize.Level1) { - GTEST_LOG_(INFO) << "SetScreenMagnificationState_001 start"; - - bool state = true; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetScreenMagnificationState(state); - GTEST_LOG_(INFO) << "SetScreenMagnificationState_001 end"; -} - -/** - * @tc.number: SetShortKeyState_001 - * @tc.name: SetShortKeyState_001 - * @tc.desc: Test function SetShortKeyState - * @tc.require: issueI5NTXH - */ -HWTEST_F(AccessibilityConfigImplTest, SetShortKeyState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetShortKeyState_001 start"; - - bool state = true; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetShortKeyState(state); - GTEST_LOG_(INFO) << "SetShortKeyState_001 end"; -} - -/** - * @tc.number: SetMouseKeyState_001 - * @tc.name: SetMouseKeyState_001 - * @tc.desc: Test function SetMouseKeyState - * @tc.require: issueI5NTXA - */ -HWTEST_F(AccessibilityConfigImplTest, SetMouseKeyState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetMouseKeyState_001 start"; - bool state = true; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetMouseKeyState(state); - GTEST_LOG_(INFO) << "SetMouseKeyState_001 end"; -} - -/** - * @tc.number: SetCaptionsState_001 - * @tc.name: SetCaptionsState_001 - * @tc.desc: Test function SetCaptionsState - */ -HWTEST_F(AccessibilityConfigImplTest, SetCaptionsState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetCaptionsState_001 start"; - - bool state = true; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetCaptionsState(state); - GTEST_LOG_(INFO) << "SetCaptionsState_001 end"; -} - -/** - * @tc.number: SetMouseAutoClick_001 - * @tc.name: SetMouseAutoClick_001 - * @tc.desc: Test function SetMouseAutoClick - * @tc.require: issueI5NTXC - */ -HWTEST_F(AccessibilityConfigImplTest, SetMouseAutoClick_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetMouseAutoClick_001 start"; - - int32_t time = 10; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetMouseAutoClick(time); - GTEST_LOG_(INFO) << "SetMouseAutoClick_001 end"; -} - -/** - * @tc.number: SetShortkeyTarget_001 - * @tc.name: SetShortkeyTarget_001 - * @tc.desc: Test function SetShortkeyTarget - * @tc.require: issueI5NTXH - */ -HWTEST_F(AccessibilityConfigImplTest, SetShortkeyTarget_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetShortkeyTarget_001 start"; - - std::string name = "test"; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetShortkeyTarget(name); - GTEST_LOG_(INFO) << "SetShortkeyTarget_001 end"; -} - -/** - * @tc.number: SetHighContrastTextState_001 - * @tc.name: SetHighContrastTextState_001 - * @tc.desc: Test function SetHighContrastTextState - * @tc.require: issueI5NTX9 - */ -HWTEST_F(AccessibilityConfigImplTest, SetHighContrastTextState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetHighContrastTextState_001 start"; - - bool state = true; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetHighContrastTextState(state); - GTEST_LOG_(INFO) << "SetHighContrastTextState_001 end"; -} - -/** - * @tc.number: SetInvertColorState_001 - * @tc.name: SetInvertColorState_001 - * @tc.desc: Test function SetInvertColorState - * @tc.require: issueI5NTX7 - */ -HWTEST_F(AccessibilityConfigImplTest, SetInvertColorState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetInvertColorState_001 start"; - - bool state = true; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetInvertColorState(state); - GTEST_LOG_(INFO) << "SetInvertColorState_001 end"; -} - -/** - * @tc.number: SetDaltonizationColorFilter_001 - * @tc.name: SetDaltonizationColorFilter_001 - * @tc.desc: Test function SetDaltonizationColorFilter - * @tc.require: issueI5NTX8 - */ -HWTEST_F(AccessibilityConfigImplTest, SetDaltonizationColorFilter_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetDaltonizationColorFilter_001 start"; - - DALTONIZATION_TYPE type = Protanomaly; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetDaltonizationColorFilter(type); - GTEST_LOG_(INFO) << "SetDaltonizationColorFilter_001 end"; -} - -/** - * @tc.number: SetContentTimeout_001 - * @tc.name: SetContentTimeout_001 - * @tc.desc: Test function SetContentTimeout - * @tc.require: issueI5NTXF - */ -HWTEST_F(AccessibilityConfigImplTest, SetContentTimeout_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetContentTimeout_001 start"; - - uint32_t timer = 10; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetContentTimeout(timer); - GTEST_LOG_(INFO) << "SetContentTimeout_001 end"; -} - -/** - * @tc.number: SetAnimationOffState_001 - * @tc.name: SetAnimationOffState_001 - * @tc.desc: Test function SetAnimationOffState - * @tc.require: issueI5NTXG - */ -HWTEST_F(AccessibilityConfigImplTest, SetAnimationOffState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetAnimationOffState_001 start"; - - bool state = true; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetAnimationOffState(state); - GTEST_LOG_(INFO) << "SetAnimationOffState_001 end"; -} - -/** - * @tc.number: SetBrightnessDiscount_001 - * @tc.name: SetBrightnessDiscount_001 - * @tc.desc: Test function SetBrightnessDiscount - * @tc.require: issueI5NTXE - */ -HWTEST_F(AccessibilityConfigImplTest, SetBrightnessDiscount_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetBrightnessDiscount_001 start"; - - float brightness = 0.2; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetBrightnessDiscount(brightness); - GTEST_LOG_(INFO) << "SetBrightnessDiscount_001 end"; -} - -/** - * @tc.number: SetAudioMonoState_001 - * @tc.name: SetAudioMonoState_001 - * @tc.desc: Test function SetAudioMonoState - */ -HWTEST_F(AccessibilityConfigImplTest, SetAudioMonoState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetAudioMonoState_001 start"; - - bool state = true; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.SetAudioMonoState(state); - GTEST_LOG_(INFO) << "SetAudioMonoState_001 end"; -} - -/** - * @tc.number: SetAudioBalance_001 - * @tc.name: SetAudioBalance_001 - * @tc.desc: Test function SetAudioBalance - */ -HWTEST_F(AccessibilityConfigImplTest, SetAudioBalance_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "SetAudioBalance_001 start"; + GTEST_LOG_(INFO) << "ConfigNotify_003 start"; float balance = -1.0; auto &instance = Singleton::GetInstance(); instance.InitializeContext(); + for (int32_t index = 0; index < static_cast(CONFIG_ID_MAX); index ++) { + instance.SubscribeConfigObserver(static_cast(index), nullptr); + } instance.SetAudioBalance(balance); sleep(1); - GTEST_LOG_(INFO) << "SetAudioBalance_001 end"; -} - -/** - * @tc.number: GetScreenMagnificationState_001 - * @tc.name: GetScreenMagnificationState_001 - * @tc.desc: Test function GetScreenMagnificationState - */ -HWTEST_F(AccessibilityConfigImplTest, GetScreenMagnificationState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetScreenMagnificationState_001 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetScreenMagnificationState(value); - EXPECT_TRUE(value); - GTEST_LOG_(INFO) << "GetScreenMagnificationState_001 end"; -} - -/** - * @tc.number: GetShortKeyState_001 - * @tc.name: GetShortKeyState_001 - * @tc.desc: Test function GetShortKeyState - * @tc.require: issueI5NTXH - */ -HWTEST_F(AccessibilityConfigImplTest, GetShortKeyState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetShortKeyState_001 start"; - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetShortKeyState(value); - EXPECT_TRUE(value); - GTEST_LOG_(INFO) << "GetShortKeyState_001 end"; -} - -/** - * @tc.number: GetMouseKeyState_001 - * @tc.name: GetMouseKeyState_001 - * @tc.desc: Test function GetMouseKeyState - * @tc.require: issueI5NTXA - */ -HWTEST_F(AccessibilityConfigImplTest, GetMouseKeyState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetMouseKeyState_001 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetMouseKeyState(value); - EXPECT_TRUE(value); - GTEST_LOG_(INFO) << "GetMouseKeyState_001 end"; -} - -/** - * @tc.number: GetCaptionsState_001 - * @tc.name: GetCaptionsState_001 - * @tc.desc: Test function GetCaptionsState - */ -HWTEST_F(AccessibilityConfigImplTest, GetCaptionsState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetCaptionsState_001 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetCaptionsState(value); - EXPECT_TRUE(value); - GTEST_LOG_(INFO) << "GetCaptionsState_001 end"; -} - -/** - * @tc.number: GetCaptionsProperty_001 - * @tc.name: GetCaptionsProperty_001 - * @tc.desc: Test function GetCaptionsProperty - */ -HWTEST_F(AccessibilityConfigImplTest, GetCaptionsProperty_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetCaptionsProperty_001 start"; - - - CaptionProperty value; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetCaptionsProperty(value); - GTEST_LOG_(INFO) << "GetCaptionsProperty_001 end"; -} - -/** - * @tc.number: GetMouseAutoClick_001 - * @tc.name: GetMouseAutoClick_001 - * @tc.desc: Test function GetMouseAutoClick - * @tc.require: issueI5NTXC - */ -HWTEST_F(AccessibilityConfigImplTest, GetMouseAutoClick_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetMouseAutoClick_001 start"; - - - int32_t value = 0; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetMouseAutoClick(value); - EXPECT_EQ(MOUSE_AUTO_CLICK_VALUE, value); - GTEST_LOG_(INFO) << "GetMouseAutoClick_001 end"; -} - -/** - * @tc.number: GetShortkeyTarget_001 - * @tc.name: GetShortkeyTarget_001 - * @tc.desc: Test function GetShortkeyTarget - * @tc.require: issueI5NTXH - */ -HWTEST_F(AccessibilityConfigImplTest, GetShortkeyTarget_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetShortkeyTarget_001 start"; - - std::string value = ""; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetShortkeyTarget(value); - EXPECT_STREQ(value.c_str(), "test"); - GTEST_LOG_(INFO) << "GetShortkeyTarget_001 end"; -} - -/** - * @tc.number: GetInvertColorState_001 - * @tc.name: GetInvertColorState_001 - * @tc.desc: Test function GetInvertColorState - * @tc.require: issueI5NTX7 - */ -HWTEST_F(AccessibilityConfigImplTest, GetInvertColorState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetInvertColorState_001 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetInvertColorState(value); - EXPECT_TRUE(value); - GTEST_LOG_(INFO) << "GetInvertColorState_001 end"; -} - -/** - * @tc.number:GetHighContrastTextState_001 - * @tc.name: GetHighContrastTextState_001 - * @tc.desc: Test function GetHighContrastTextState - * @tc.require: issueI5NTX9 - */ -HWTEST_F(AccessibilityConfigImplTest, GetHighContrastTextState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetHighContrastTextState_001 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetHighContrastTextState(value); - EXPECT_TRUE(value); - GTEST_LOG_(INFO) << "GetHighContrastTextState_001 end"; -} - -/** - * @tc.number: GetDaltonizationColorFilter_001 - * @tc.name: GetDaltonizationColorFilter_001 - * @tc.desc: Test function GetDaltonizationColorFilter - * @tc.require: issueI5NTX8 - */ -HWTEST_F(AccessibilityConfigImplTest, GetDaltonizationColorFilter_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetDaltonizationColorFilter_001 start"; - - DALTONIZATION_TYPE value = Normal; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetDaltonizationColorFilter(value); - EXPECT_EQ(1, static_cast(value)); - GTEST_LOG_(INFO) << "GetDaltonizationColorFilter_001 end"; -} - -/** - * @tc.number: GetContentTimeout_001 - * @tc.name: GetContentTimeout_001 - * @tc.desc: Test function GetContentTimeout - * @tc.require: issueI5NTXF - */ -HWTEST_F(AccessibilityConfigImplTest, GetContentTimeout_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetContentTimeout_001 start"; - - uint32_t value = 0; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetContentTimeout(value); - EXPECT_EQ(CONTENT_TIMEOUT_VALUE, value); - GTEST_LOG_(INFO) << "GetContentTimeout_001 end"; -} - -/** - * @tc.number: GetAnimationOffState_001 - * @tc.name: GetAnimationOffState_001 - * @tc.desc: Test function GetAnimationOffState - * @tc.require: issueI5NTXG - */ -HWTEST_F(AccessibilityConfigImplTest, GetAnimationOffState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetAnimationOffState_001 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetAnimationOffState(value); - EXPECT_TRUE(value); - GTEST_LOG_(INFO) << "GetAnimationOffState_001 end"; -} - -/** - * @tc.number: GetBrightnessDiscount_001 - * @tc.name: GetBrightnessDiscount_001 - * @tc.desc: Test function GetBrightnessDiscount - * @tc.require: issueI5NTXE - */ -HWTEST_F(AccessibilityConfigImplTest, GetBrightnessDiscount_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetBrightnessDiscount_001 start"; - - float value = 0; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetBrightnessDiscount(value); - EXPECT_FLOAT_EQ(BRIGHTNESS_DISCOUNT_VALUE, value); - GTEST_LOG_(INFO) << "GetBrightnessDiscount_001 end"; -} - -/** - * @tc.number: GetAudioMonoState_001 - * @tc.name: GetAudioMonoState_001 - * @tc.desc: Test function GetAudioMonoState - */ -HWTEST_F(AccessibilityConfigImplTest, GetAudioMonoState_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetAudioMonoState_001 start"; - - bool value = false; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetAudioMonoState(value); - EXPECT_TRUE(value); - GTEST_LOG_(INFO) << "GetAudioMonoState_001 end"; -} - -/** - * @tc.number: GetAudioBalance_001 - * @tc.name: GetAudioBalance_001 - * @tc.desc: Test function GetAudioBalance - */ -HWTEST_F(AccessibilityConfigImplTest, GetAudioBalance_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "GetAudioBalance_001 start"; - - float value = 0; - auto &instance = Singleton::GetInstance(); - instance.InitializeContext(); - instance.GetAudioBalance(value); - EXPECT_FLOAT_EQ(-1, value); - GTEST_LOG_(INFO) << "GetAudioBalance_001 end"; + GTEST_LOG_(INFO) << "ConfigNotify_003 end"; } /** @@ -1138,7 +766,8 @@ HWTEST_F(AccessibilityConfigImplTest, SubscribeEnableAbilityListsObserver_001, T { GTEST_LOG_(INFO) << "SubscribeEnableAbilityListsObserver_001 start"; - std::shared_ptr observer = nullptr; + std::shared_ptr observer = + std::make_shared(); auto &instance = Singleton::GetInstance(); instance.InitializeContext(); instance.SubscribeEnableAbilityListsObserver(observer); @@ -1157,6 +786,7 @@ HWTEST_F(AccessibilityConfigImplTest, UnsubscribeEnableAbilityListsObserver_001, std::shared_ptr observer = nullptr; auto &instance = Singleton::GetInstance(); instance.InitializeContext(); + instance.SubscribeEnableAbilityListsObserver(observer); instance.UnsubscribeEnableAbilityListsObserver(observer); GTEST_LOG_(INFO) << "UnsubscribeEnableAbilityListsObserver_001 end"; } @@ -1174,7 +804,8 @@ HWTEST_F(AccessibilityConfigImplTest, EnableAbility_001, TestSize.Level1) std::string name = "test"; auto &instance = Singleton::GetInstance(); instance.InitializeContext(); - instance.EnableAbility(name, 0); + EXPECT_TRUE(instance.EnableAbility(name, 0)); + sleep(1); GTEST_LOG_(INFO) << "EnableAbility_001 end"; } @@ -1190,7 +821,7 @@ HWTEST_F(AccessibilityConfigImplTest, DisableAbility_001, TestSize.Level1) std::string name = "test"; auto &instance = Singleton::GetInstance(); instance.InitializeContext(); - instance.DisableAbility(name); + EXPECT_TRUE(instance.DisableAbility(name)); GTEST_LOG_(INFO) << "DisableAbility_001 end"; } } // namespace AccessibilityConfig