From 360982fda276f60def578e12c37725dfc323ee54 Mon Sep 17 00:00:00 2001 From: mlyuestc Date: Fri, 12 Sep 2025 11:46:08 +0000 Subject: [PATCH] revert theme info Signed-off-by: mlyuestc --- .../components/theme/theme_manager_impl.cpp | 17 ++++++----------- .../core/components/theme/theme_manager_impl.h | 2 +- .../core/manager/theme_manager_test_ng.cpp | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/frameworks/core/components/theme/theme_manager_impl.cpp b/frameworks/core/components/theme/theme_manager_impl.cpp index 0a28469716a..4d1b88db6f7 100644 --- a/frameworks/core/components/theme/theme_manager_impl.cpp +++ b/frameworks/core/components/theme/theme_manager_impl.cpp @@ -226,8 +226,7 @@ ThemeManagerImpl::ThemeManagerImpl(RefPtr& resourceAdapter) void ThemeManagerImpl::RegisterThemeKit(ThemeType type, Ace::Kit::BuildFunc func) { - auto key = GetThemesMapKey(type); - auto findIter = themes_.find(key); + auto findIter = themes_.find(type); if (findIter != themes_.end()) { return; } @@ -245,8 +244,7 @@ std::string ThemeManagerImpl::GetThemesMapKey(ThemeType type) const RefPtr ThemeManagerImpl::GetTheme(ThemeType type) { - auto key = GetThemesMapKey(type); - auto findIter = themes_.find(key); + auto findIter = themes_.find(type); if (findIter != themes_.end()) { return findIter->second; } @@ -264,8 +262,7 @@ RefPtr ThemeManagerImpl::GetThemeOrigin(ThemeType type) } auto theme = builderIter->second(themeConstants_); - auto key = GetThemesMapKey(type); - themes_.emplace(key, theme); + themes_.emplace(type, theme); return theme; } @@ -275,7 +272,6 @@ RefPtr ThemeManagerImpl::GetThemeKit(ThemeType type) if (builderIterKit == THEME_BUILDERS_KIT.end()) { return nullptr; } - auto key = GetThemesMapKey(type); if (auto pipeline = NG::PipelineContext::GetCurrentContext(); pipeline) { ColorMode localMode = pipeline->GetLocalColorMode(); ColorMode systemMode = pipeline->GetColorMode(); @@ -293,12 +289,12 @@ RefPtr ThemeManagerImpl::GetThemeKit(ThemeType type) ResourceManager::GetInstance().UpdateColorMode( pipeline->GetBundleName(), pipeline->GetModuleName(), pipeline->GetInstanceId(), localMode); } - themes_.emplace(key, theme); + themes_.emplace(type, theme); return theme; } auto theme = builderIterKit->second(); - themes_.emplace(key, theme); + themes_.emplace(type, theme); return theme; } @@ -411,8 +407,7 @@ RefPtr ThemeManagerImpl::GetThemeKit(ThemeType type, int32_t themeScopeId Color ThemeManagerImpl::GetBackgroundColor() const { - auto key = GetThemesMapKey(AppTheme::TypeId()); - auto findIter = themes_.find(key); + auto findIter = themes_.find(AppTheme::TypeId()); if (findIter != themes_.end()) { auto appTheme = AceType::DynamicCast(findIter->second); if (appTheme) { diff --git a/frameworks/core/components/theme/theme_manager_impl.h b/frameworks/core/components/theme/theme_manager_impl.h index 0b0cf9e6e4a..b9c50fce269 100644 --- a/frameworks/core/components/theme/theme_manager_impl.h +++ b/frameworks/core/components/theme/theme_manager_impl.h @@ -139,7 +139,7 @@ public: private: using ThemeWrappers = std::unordered_map>; - std::unordered_map> themes_; + std::unordered_map> themes_; ThemeWrappers themeWrappersLight_; ThemeWrappers themeWrappersDark_; diff --git a/test/unittest/core/manager/theme_manager_test_ng.cpp b/test/unittest/core/manager/theme_manager_test_ng.cpp index 46d82259de1..c43509671cf 100644 --- a/test/unittest/core/manager/theme_manager_test_ng.cpp +++ b/test/unittest/core/manager/theme_manager_test_ng.cpp @@ -77,4 +77,20 @@ HWTEST_F(ThemeManagerTestNg, GetThemesMapKey001, TestSize.Level1) themeManager->GetThemesMapKey(ButtonTheme::TypeId()); EXPECT_TRUE(AceType::InstanceOf(theme)); } + +/** + * @tc.name: GetCurrentColorMode001 + * @tc.desc: GetCurrentColorMode + * @tc.type: FUNC + */ +HWTEST_F(ThemeManagerTestNg, GetCurrentColorMode001, TestSize.Level1) +{ + /** + * @tc.steps: create themeManager + */ + auto themeManager = AceType::MakeRefPtr(); + auto theme = themeManager->GetThemeOrigin(ButtonTheme::TypeId()); + themeManager->GetCurrentColorMode(); + EXPECT_TRUE(AceType::InstanceOf(theme)); +} } -- Gitee