diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /vcl/qa/cppunit/widgetdraw | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/qa/cppunit/widgetdraw')
5 files changed, 243 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx new file mode 100644 index 0000000000..2665508ee4 --- /dev/null +++ b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> + +#include <string_view> + +#include <cppunit/TestAssert.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> +#include <unotest/bootstrapfixturebase.hxx> + +#include <widgetdraw/WidgetDefinitionReader.hxx> + +namespace +{ +constexpr OUStringLiteral gaDataUrl(u"/vcl/qa/cppunit/widgetdraw/data/"); + +class WidgetDefinitionReaderTest : public test::BootstrapFixtureBase +{ +private: + OUString getFullUrl(std::u16string_view sFileName) + { + return m_directories.getURLFromSrc(gaDataUrl) + sFileName; + } + +public: + void testRead(); + void testReadSettings(); + + CPPUNIT_TEST_SUITE(WidgetDefinitionReaderTest); + CPPUNIT_TEST(testRead); + CPPUNIT_TEST(testReadSettings); + CPPUNIT_TEST_SUITE_END(); +}; + +void WidgetDefinitionReaderTest::testReadSettings() +{ + { + vcl::WidgetDefinition aDefinition; + vcl::WidgetDefinitionReader aReader(getFullUrl(u"definitionSettings1.xml"), + getFullUrl(u"")); + CPPUNIT_ASSERT(aReader.read(aDefinition)); + CPPUNIT_ASSERT_EQUAL(""_ostr, aDefinition.mpSettings->msCenteredTabs); + } + + { + vcl::WidgetDefinition aDefinition; + vcl::WidgetDefinitionReader aReader(getFullUrl(u"definitionSettings2.xml"), + getFullUrl(u"")); + CPPUNIT_ASSERT(aReader.read(aDefinition)); + CPPUNIT_ASSERT_EQUAL("true"_ostr, aDefinition.mpSettings->msCenteredTabs); + } + + { + vcl::WidgetDefinition aDefinition; + vcl::WidgetDefinitionReader aReader(getFullUrl(u"definitionSettings3.xml"), + getFullUrl(u"")); + CPPUNIT_ASSERT(aReader.read(aDefinition)); + CPPUNIT_ASSERT_EQUAL("true"_ostr, aDefinition.mpSettings->msNoActiveTabTextRaise); + CPPUNIT_ASSERT_EQUAL("false"_ostr, aDefinition.mpSettings->msCenteredTabs); + CPPUNIT_ASSERT_EQUAL("0"_ostr, aDefinition.mpSettings->msListBoxEntryMargin); + CPPUNIT_ASSERT_EQUAL("10"_ostr, aDefinition.mpSettings->msDefaultFontSize); + CPPUNIT_ASSERT_EQUAL("16"_ostr, aDefinition.mpSettings->msTitleHeight); + CPPUNIT_ASSERT_EQUAL("12"_ostr, aDefinition.mpSettings->msFloatTitleHeight); + CPPUNIT_ASSERT_EQUAL("15"_ostr, aDefinition.mpSettings->msListBoxPreviewDefaultLogicWidth); + CPPUNIT_ASSERT_EQUAL("7"_ostr, aDefinition.mpSettings->msListBoxPreviewDefaultLogicHeight); + } +} + +void WidgetDefinitionReaderTest::testRead() +{ + vcl::WidgetDefinition aDefinition; + + vcl::WidgetDefinitionReader aReader(getFullUrl(u"definition1.xml"), getFullUrl(u"")); + CPPUNIT_ASSERT(aReader.read(aDefinition)); + + CPPUNIT_ASSERT_EQUAL(OUString("123456"), aDefinition.mpStyle->maFaceColor.AsRGBHexString()); + CPPUNIT_ASSERT_EQUAL(OUString("234567"), aDefinition.mpStyle->maCheckedColor.AsRGBHexString()); + CPPUNIT_ASSERT_EQUAL(OUString("345678"), aDefinition.mpStyle->maLightColor.AsRGBHexString()); + + CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), + aDefinition.mpStyle->maVisitedLinkColor.AsRGBHexString()); + CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aDefinition.mpStyle->maToolTextColor.AsRGBHexString()); + CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), + aDefinition.mpStyle->maWindowTextColor.AsRGBHexString()); + + // Pushbutton + { + ControlState eState + = ControlState::DEFAULT | ControlState::ENABLED | ControlState::ROLLOVER; + std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates + = aDefinition.getDefinition(ControlType::Pushbutton, ControlPart::Entire) + ->getStates(ControlType::Pushbutton, ControlPart::Entire, eState, + PushButtonValue()); + + CPPUNIT_ASSERT_EQUAL(size_t(2), aStates.size()); + + CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpWidgetDrawActions.size()); + CPPUNIT_ASSERT_EQUAL(vcl::WidgetDrawActionType::RECTANGLE, + aStates[0]->mpWidgetDrawActions[0]->maType); + CPPUNIT_ASSERT_EQUAL(vcl::WidgetDrawActionType::LINE, + aStates[0]->mpWidgetDrawActions[1]->maType); + } + + // Radiobutton + { + std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates + = aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire) + ->getStates(ControlType::Radiobutton, ControlPart::Entire, ControlState::NONE, + ImplControlValue(ButtonValue::On)); + CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size()); + CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpWidgetDrawActions.size()); + } + + { + std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates + = aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire) + ->getStates(ControlType::Radiobutton, ControlPart::Entire, ControlState::NONE, + ImplControlValue(ButtonValue::Off)); + CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size()); + CPPUNIT_ASSERT_EQUAL(size_t(1), aStates[0]->mpWidgetDrawActions.size()); + } +} + +} // namespace + +CPPUNIT_TEST_SUITE_REGISTRATION(WidgetDefinitionReaderTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qa/cppunit/widgetdraw/data/definition1.xml b/vcl/qa/cppunit/widgetdraw/data/definition1.xml new file mode 100644 index 0000000000..34e2196181 --- /dev/null +++ b/vcl/qa/cppunit/widgetdraw/data/definition1.xml @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<widgets> + <style> + <faceColor value="#123456"/> + <checkedColor value="#234567"/> + <lightColor value="#345678"/> + <lightBorderColor value="#FFFFFF"/> + <shadowColor value="#FFFFFF"/> + <darkShadowColor value="#FFFFFF"/> + <buttonTextColor value="#FFFFFF"/> + <buttonRolloverTextColor value="#FFFFFF"/> + <radioCheckTextColor value="#FFFFFF"/> + <groupTextColor value="#FFFFFF"/> + <labelTextColor value="#FFFFFF"/> + <windowColor value="#FFFFFF"/> + <windowTextColor value="#FFFFFF"/> + <dialogColor value="#FFFFFF"/> + <dialogTextColor value="#FFFFFF"/> + <workspaceColor value="#FFFFFF"/> + <monoColor value="#FFFFFF"/> + <fieldColor value="#FFFFFF"/> + <fieldTextColor value="#FFFFFF"/> + <fieldRolloverTextColor value="#FFFFFF"/> + <activeColor value="#FFFFFF"/> + <activeTextColor value="#FFFFFF"/> + <activeBorderColor value="#FFFFFF"/> + <deactiveColor value="#FFFFFF"/> + <deactiveTextColor value="#FFFFFF"/> + <deactiveBorderColor value="#FFFFFF"/> + <menuColor value="#FFFFFF"/> + <menuBarColor value="#FFFFFF"/> + <menuBarRolloverColor value="#FFFFFF"/> + <menuBorderColor value="#FFFFFF"/> + <menuTextColor value="#FFFFFF"/> + <menuBarTextColor value="#FFFFFF"/> + <menuBarRolloverTextColor value="#FFFFFF"/> + <menuBarHighlightTextColor value="#FFFFFF"/> + <menuHighlightColor value="#FFFFFF"/> + <menuHighlightTextColor value="#FFFFFF"/> + <highlightColor value="#FFFFFF"/> + <highlightTextColor value="#FFFFFF"/> + <activeTabColor value="#FFFFFF"/> + <inactiveTabColor value="#FFFFFF"/> + <tabTextColor value="#FFFFFF"/> + <tabRolloverTextColor value="#FFFFFF"/> + <tabHighlightTextColor value="#FFFFFF"/> + <disableColor value="#FFFFFF"/> + <helpColor value="#FFFFFF"/> + <helpTextColor value="#FFFFFF"/> + <linkColor value="#FFFFFF"/> + <visitedLinkColor value="#FFFFFF"/> + <toolTextColor value="#FFFFFF"/> + </style> + <pushbutton> + <part value="Entire"> + <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any"> + <rect stroke="#808080" fill="#FFFFFF" stroke-width="1.0" rx="5" ry="5" margin="1"/> + <line stroke="#808080" fill="#808080" stroke-width="1.0"/> + </state> + <state enabled="true" focused="any" pressed="any" rollover="true" default="true" selected="any" button-value="any"> + <rect stroke="#808080" fill="#808080" stroke-width="1.0" rx="5" ry="5" margin="1"/> + </state> + </part> + <part value="Focus"> + <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any"> + <rect stroke="#808080" fill="#FFFFFF" stroke-width="1.0" rx="5" ry="5" margin="1"/> + </state> + </part> + </pushbutton> + <radiobutton> + <part value="Entire"> + <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="false"> + <rect stroke="#007AFF" fill="#FFFFFF" stroke-width="1" margin="0"/> + </state> + <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="true"> + <rect stroke="#007AFF" fill="#FFFFFF" stroke-width="1" margin="0"/> + <rect stroke="#007AFF" fill="#007AFF" stroke-width="1" margin="3"/> + </state> + </part> + </radiobutton> +</widgets> diff --git a/vcl/qa/cppunit/widgetdraw/data/definitionSettings1.xml b/vcl/qa/cppunit/widgetdraw/data/definitionSettings1.xml new file mode 100644 index 0000000000..9ca7f894f2 --- /dev/null +++ b/vcl/qa/cppunit/widgetdraw/data/definitionSettings1.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<widgets> + <settings> + </settings> +</widgets> diff --git a/vcl/qa/cppunit/widgetdraw/data/definitionSettings2.xml b/vcl/qa/cppunit/widgetdraw/data/definitionSettings2.xml new file mode 100644 index 0000000000..0d6d6e1115 --- /dev/null +++ b/vcl/qa/cppunit/widgetdraw/data/definitionSettings2.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<widgets> + <settings> + <centeredTabs value="true"/> + </settings> +</widgets> diff --git a/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml b/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml new file mode 100644 index 0000000000..9ad88dd545 --- /dev/null +++ b/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<widgets> + <settings> + <noActiveTabTextRaise value="true"/> + <centeredTabs value="false"/> + <listBoxEntryMargin value="0"/> + <defaultFontSize value="10"/> + <titleHeight value="16"/> + <floatTitleHeight value="12"/> + <listBoxPreviewDefaultLogicWidth value="15"/> + <listBoxPreviewDefaultLogicHeight value="7"/> + </settings> +</widgets> |