/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
END_TEST;
}
-int UtcDaliStyleManagerConfigSectionTest(void)
+int UtcDaliStyleManagerConfigSectionTestP(void)
{
tet_infoline("Test that the properties in config section are works");
END_TEST;
}
+int UtcDaliStyleManagerConfigSectionTestN(void)
+{
+ tet_infoline("Test that the properties in config section are works as default if theme is broken");
+
+ const char* brokenTheme = "INVALID";
+
+ Test::StyleMonitor::SetThemeFileOutput(DALI_STYLE_DIR "dali-toolkit-default-theme.json", brokenTheme);
+ try
+ {
+ ToolkitTestApplication application;
+
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+
+ Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ DALI_TEST_CHECK(config.Empty());
+
+ // For coverage
+ Toolkit::TextEditor editor = Toolkit::TextEditor::New();
+ editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+ application.GetScene().Add(editor);
+
+ Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
+
+ application.ProcessEvent(Integration::KeyEvent("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE));
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::TextLabel label = Toolkit::TextLabel::New();
+ label.SetProperty(Toolkit::TextLabel::Property::TEXT, "Hello, World!");
+ application.GetScene().Add(label);
+
+ application.SendNotification();
+ application.Render();
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(false); ///< Should not get here
+ }
+
+ // Restore default theme data.
+ Test::StyleMonitor::SetThemeFileOutput(DALI_STYLE_DIR "dali-toolkit-default-theme.json", defaultTheme);
+
+ END_TEST;
+}
+
int UtcDaliStyleManagerNewWithAdditionalBehavior(void)
{
ToolkitTestApplication application;
return fontClientHandle;
}
+ void ClearCache()
+ {
+ }
+ void ClearCacheOnLocaleChanged()
+ {
+ }
void SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi)
{
}
+ void SetDpiFromWindowSystem()
+ {
+ }
void GetDpi(unsigned int& horizontalDpi, unsigned int& verticalDpi)
{
horizontalDpi = verticalDpi = 96;
}
-
+ int GetDefaultFontSize()
+ {
+ return 10.0f;
+ }
void ResetSystemDefaults()
{
}
void GetDefaultFonts(FontList& defaultFonts)
{
}
+ void InitDefaultFontDescription()
+ {
+ }
void GetDefaultPlatformFontDescription(FontDescription& fontDescription)
{
}
void GetDescription(FontId id, FontDescription& fontDescription)
{
}
+ bool IsCharacterSupportedByFont(FontId fontId, Character character)
+ {
+ return true;
+ }
PointSize26Dot6 GetPointSize(FontId id)
{
return 9;
void GetFixedSizes(const FontDescription& fontDescription, Dali::Vector<PointSize26Dot6>& sizes)
{
}
+ bool HasItalicStyle(FontId fontId) const
+ {
+ return false;
+ }
void GetFontMetrics(FontId fontId, FontMetrics& metrics)
{
}
{
return 0;
}
+ GlyphIndex GetGlyphIndex(FontId fontId, Character charcode, Character variantSelector)
+ {
+ return 0;
+ }
bool GetGlyphMetrics(GlyphInfo* array, uint32_t size, bool horizontal)
{
return true;
return static_cast<TextAbstraction::Internal::FontClient&>(handle);
}
+inline static const TextAbstraction::Internal::FontClient& GetImplementation(const TextAbstraction::FontClient& fontClient)
+{
+ DALI_ASSERT_ALWAYS(fontClient && "fontClient handle is empty");
+ const BaseObject& handle = fontClient.GetBaseObject();
+ return static_cast<const TextAbstraction::Internal::FontClient&>(handle);
+}
+
inline static TextAbstraction::Internal::Shaping& GetImplementation(TextAbstraction::Shaping& shaping)
{
DALI_ASSERT_ALWAYS(shaping && "shaping handle is empty");
return *this;
}
+void FontClient::ClearCache()
+{
+ GetImplementation(*this).ClearCache();
+}
+
+void FontClient::ClearCacheOnLocaleChanged()
+{
+ GetImplementation(*this).ClearCacheOnLocaleChanged();
+}
+
void FontClient::SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi)
{
GetImplementation(*this).SetDpi(horizontalDpi, verticalDpi);
}
+void FontClient::SetDpiFromWindowSystem()
+{
+ GetImplementation(*this).SetDpiFromWindowSystem();
+}
+
void FontClient::GetDpi(unsigned int& horizontalDpi, unsigned int& verticalDpi)
{
GetImplementation(*this).GetDpi(horizontalDpi, verticalDpi);
}
+int FontClient::GetDefaultFontSize()
+{
+ return GetImplementation(*this).GetDefaultFontSize();
+}
+
void FontClient::ResetSystemDefaults()
{
GetImplementation(*this).ResetSystemDefaults();
GetImplementation(*this).GetDefaultFonts(defaultFonts);
}
+void FontClient::InitDefaultFontDescription()
+{
+ GetImplementation(*this).InitDefaultFontDescription();
+}
+
void FontClient::GetDefaultPlatformFontDescription(FontDescription& fontDescription)
{
GetImplementation(*this).GetDefaultPlatformFontDescription(fontDescription);
return GetImplementation(*this).GetPointSize(id);
}
+bool FontClient::IsCharacterSupportedByFont(FontId fontId, Character character)
+{
+ return GetImplementation(*this).IsCharacterSupportedByFont(fontId, character);
+}
+
FontId FontClient::FindDefaultFont(Character charcode, PointSize26Dot6 pointSize, bool preferColor)
{
return GetImplementation(*this).FindDefaultFont(charcode, pointSize, preferColor);
GetImplementation(*this).GetFixedSizes(fontDescription, sizes);
}
+bool FontClient::HasItalicStyle(FontId fontId) const
+{
+ return GetImplementation(*this).HasItalicStyle(fontId);
+}
+
void FontClient::GetFontMetrics(FontId fontId, FontMetrics& metrics)
{
GetImplementation(*this).GetFontMetrics(fontId, metrics);
return GetImplementation(*this).GetGlyphIndex(fontId, charcode);
}
+GlyphIndex FontClient::GetGlyphIndex(FontId fontId, Character charcode, Character variantSelector)
+{
+ return GetImplementation(*this).GetGlyphIndex(fontId, charcode, variantSelector);
+}
+
bool FontClient::GetGlyphMetrics(GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal)
{
return GetImplementation(*this).GetGlyphMetrics(array, size, horizontal);
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
ApplyDefaultTheme();
}
- if(mThemeBuilder)
+ if(DALI_LIKELY(mThemeBuilder))
{
ApplyStyle(mThemeBuilder, control);
}
mThemeBuilder = CreateBuilder(mThemeBuilderConstants);
// Load default theme because this is first try to load stylesheet.
-#if defined(DEBUG_ENABLED)
- bool themeLoaded = LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
+ const bool themeLoaded = LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
DALI_LOG_STREAM(gLogFilter, Debug::Concise, " themeLoaded" << (themeLoaded ? "success" : "failure"));
-#else
- LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
-#endif
+
+ if(DALI_UNLIKELY(!themeLoaded))
+ {
+ DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations() Failed\n");
+
+ // We tried to load a theme, but it failed. Ensure the builder is reset
+ mThemeBuilder.Reset();
+
+ static const Property::Map emptyMap;
+
+ return emptyMap;
+ }
mThemeFile = mDefaultThemeFilePath;
}