| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include <gtest/gtest.h> |
| |
|
| | #include <QString> |
| |
|
| | #include "src/App/InitApplication.h" |
| |
|
| | #include <Gui/Application.h> |
| | #include <Gui/StyleParameters/ParameterManager.h> |
| |
|
| | using namespace Gui; |
| |
|
| | class StyleParametersApplicationTest: public ::testing::Test |
| | { |
| | protected: |
| | static Application* app; |
| |
|
| | static void SetUpTestSuite() |
| | { |
| | tests::initApplication(); |
| | app = new Application(true); |
| | } |
| |
|
| | void SetUp() override |
| | { |
| | auto styleParamManager = app->styleParameterManager(); |
| |
|
| | styleParamManager->addSource(new StyleParameters::InMemoryParameterSource( |
| | { |
| | {.name = "ColorPrimary", .value = "#ff0000"}, |
| | {.name = "FontSize", .value = "12px"}, |
| | {.name = "BoxWidth", .value = "100px"}, |
| | }, |
| | {.name = "Fixture Source"} |
| | )); |
| | } |
| | }; |
| |
|
| | Application* StyleParametersApplicationTest::app = {}; |
| |
|
| | |
| | TEST_F(StyleParametersApplicationTest, ReplaceVariablesInQss) |
| | { |
| | QString qss = "QWidget { color: @ColorPrimary; font-size: @FontSize; width: @BoxWidth; }"; |
| | QString result = app->replaceVariablesInQss(qss); |
| |
|
| | EXPECT_EQ(result.toStdString(), "QWidget { color: #ff0000; font-size: 12px; width: 100px; }"); |
| | } |
| |
|
| | |
| | TEST_F(StyleParametersApplicationTest, ReplaceVariablesInQssWithUnknownVariable) |
| | { |
| | QString qss = "QWidget { color: @UnknownColor; margin: 10px; }"; |
| | QString result = app->replaceVariablesInQss(qss); |
| |
|
| | EXPECT_EQ(result.toStdString(), "QWidget { color: ; margin: 10px; }"); |
| | } |
| |
|
| | |
| | TEST_F(StyleParametersApplicationTest, ReplaceVariablesInQssWithEmptyString) |
| | { |
| | QString qss = ""; |
| | QString result = app->replaceVariablesInQss(qss); |
| |
|
| | EXPECT_EQ(result.toStdString(), ""); |
| | } |
| |
|
| | |
| | TEST_F(StyleParametersApplicationTest, ReplaceVariablesInQssWithMultipleOccurrences) |
| | { |
| | QString qss = "QWidget { color: @ColorPrimary; background: @ColorPrimary; }"; |
| | QString result = app->replaceVariablesInQss(qss); |
| |
|
| | EXPECT_EQ(result.toStdString(), "QWidget { color: #ff0000; background: #ff0000; }"); |
| | } |
| |
|