X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftoolkit-style-monitor.cpp;h=18c086f3b96a4068aa391a3d1f835564be52ee9f;hb=3928808cc2029cbfd59230f2edb8889a63a59cec;hp=ba0469d9bedf682ed6adecceae5b986e97aa8101;hpb=10213ff7b9185fbb7fd444c72c12dd4595b35204;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp index ba0469d..18c086f 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -15,35 +15,50 @@ * */ +// HEADER #include "toolkit-style-monitor.h" -#include +// EXTERNAL INCLUDES +#include +#include #include #include -namespace Dali -{ -const std::string Dali::StyleMonitor::DEFAULT_FONT_FAMILY("DefaultFont"); -const std::string Dali::StyleMonitor::DEFAULT_FONT_STYLE("Regular"); -const float Dali::StyleMonitor::DEFAULT_FONT_SIZE(1.0f); -} - namespace { const char* DEFAULT_THEME= - "{\"styles\":{\n" + "{\n" + " \"config\":\n" + " {\n" + " \"brokenImageUrl\":\"{DALI_IMAGE_DIR}broken.png\"\n" + " },\n" + " \"styles\":\n" + " {\n" " \"textlabel\":\n" " {\n" - " \"fontStyle\":\"Regular\",\n" + " \"fontStyle\":{\"weight\":\"normal\"},\n" " \"pointSize\":18\n" " }\n" " }\n" "}\n"; +struct NamedTheme +{ + NamedTheme( const std::string& name, const std::string& theme ) + : name(name), theme(theme) + { + } + + std::string name; + std::string theme; +}; +typedef std::vector< NamedTheme > NamedThemes; +NamedThemes gThemes; + std::string gTheme; -std::string gFontFamily = Dali::StyleMonitor::DEFAULT_FONT_FAMILY; -std::string gFontStyle = Dali::StyleMonitor::DEFAULT_FONT_STYLE; -float gFontSize = Dali::StyleMonitor::DEFAULT_FONT_SIZE; +std::string gFontFamily("LucidaSans"); +std::string gFontStyle("Regular"); +int gFontSize(1); } namespace Dali @@ -81,9 +96,8 @@ public: // Signals private: Dali::StyleMonitor::StyleChangeSignalType mStyleChangeSignal; static Dali::StyleMonitor mToolkitStyleMonitor; - std::string mTheme; - std::string mOutput; //<<< Test output. Use SetThemeFileOutput in a testharness to use it. + std::string mTheme; ///<< Current theme name }; Dali::StyleMonitor StyleMonitor::mToolkitStyleMonitor; @@ -119,7 +133,6 @@ std::string StyleMonitor::GetDefaultFontStyle() const float StyleMonitor::GetDefaultFontSize() const { return gFontSize; - } const std::string& StyleMonitor::GetTheme() const @@ -135,6 +148,16 @@ void StyleMonitor::SetTheme(std::string path) bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output ) { + for( NamedThemes::iterator iter = gThemes.begin(); iter != gThemes.end(); ++iter ) + { + NamedTheme& theme = *iter; + if( theme.name == filename ) + { + output = theme.theme; + return true; + } + } + if( !gTheme.empty() ) { output = gTheme; @@ -195,7 +218,7 @@ std::string StyleMonitor::GetDefaultFontStyle() const return GetImplementation(*this).GetDefaultFontStyle(); } -float StyleMonitor::GetDefaultFontSize() const +int StyleMonitor::GetDefaultFontSize() const { return GetImplementation(*this).GetDefaultFontSize(); } @@ -205,7 +228,7 @@ const std::string& StyleMonitor::GetTheme() const return GetImplementation(*this).GetTheme(); } -void StyleMonitor::SetTheme(std::string themeFilePath) +void StyleMonitor::SetTheme(const std::string& themeFilePath) { GetImplementation(*this).SetTheme(themeFilePath); } @@ -215,11 +238,6 @@ StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal() return GetImplementation(*this).StyleChangeSignal(); } -void StyleMonitor::EmitStyleChangeSignal(StyleChange::Type styleChange) -{ - GetImplementation(*this).EmitStyleChangeSignal(styleChange); -} - bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output ) { return GetImplementation(*this).LoadThemeFile(filename, output); @@ -246,9 +264,19 @@ namespace Test namespace StyleMonitor { -void SetThemeFileOutput( const std::string& output ) +void SetThemeFileOutput( const std::string& name, const std::string& output ) { - gTheme = output; + for( NamedThemes::iterator iter = gThemes.begin(); iter != gThemes.end(); ++iter ) + { + NamedTheme& theme = *iter; + if( theme.name == name ) + { + theme.theme = output; + return; + } + } + + gThemes.push_back( NamedTheme( name, output ) ); } void SetDefaultFontFamily(const std::string& family)