nss: upgrade to release 3.73
[LibreOffice.git] / vcl / qa / cppunit / widgetdraw / WidgetDefinitionReaderTest.cxx
blobac5accc5c940d13f02cbfb68cb111e84fc7d6ae7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <cppunit/TestAssert.h>
11 #include <cppunit/extensions/HelperMacros.h>
12 #include <cppunit/plugin/TestPlugIn.h>
13 #include <unotest/bootstrapfixturebase.hxx>
15 #include <widgetdraw/WidgetDefinitionReader.hxx>
17 namespace
19 constexpr OUStringLiteral gaDataUrl(u"/vcl/qa/cppunit/widgetdraw/data/");
21 class WidgetDefinitionReaderTest : public test::BootstrapFixtureBase
23 private:
24 OUString getFullUrl(const OUString& sFileName)
26 return m_directories.getURLFromSrc(gaDataUrl) + sFileName;
29 public:
30 void testRead();
31 void testReadSettings();
33 CPPUNIT_TEST_SUITE(WidgetDefinitionReaderTest);
34 CPPUNIT_TEST(testRead);
35 CPPUNIT_TEST(testReadSettings);
36 CPPUNIT_TEST_SUITE_END();
39 void WidgetDefinitionReaderTest::testReadSettings()
42 vcl::WidgetDefinition aDefinition;
43 vcl::WidgetDefinitionReader aReader(getFullUrl("definitionSettings1.xml"), getFullUrl(""));
44 CPPUNIT_ASSERT(aReader.read(aDefinition));
45 CPPUNIT_ASSERT_EQUAL(OString(""), aDefinition.mpSettings->msCenteredTabs);
49 vcl::WidgetDefinition aDefinition;
50 vcl::WidgetDefinitionReader aReader(getFullUrl("definitionSettings2.xml"), getFullUrl(""));
51 CPPUNIT_ASSERT(aReader.read(aDefinition));
52 CPPUNIT_ASSERT_EQUAL(OString("true"), aDefinition.mpSettings->msCenteredTabs);
56 vcl::WidgetDefinition aDefinition;
57 vcl::WidgetDefinitionReader aReader(getFullUrl("definitionSettings3.xml"), getFullUrl(""));
58 CPPUNIT_ASSERT(aReader.read(aDefinition));
59 CPPUNIT_ASSERT_EQUAL(OString("true"), aDefinition.mpSettings->msNoActiveTabTextRaise);
60 CPPUNIT_ASSERT_EQUAL(OString("false"), aDefinition.mpSettings->msCenteredTabs);
61 CPPUNIT_ASSERT_EQUAL(OString("0"), aDefinition.mpSettings->msListBoxEntryMargin);
62 CPPUNIT_ASSERT_EQUAL(OString("10"), aDefinition.mpSettings->msDefaultFontSize);
63 CPPUNIT_ASSERT_EQUAL(OString("16"), aDefinition.mpSettings->msTitleHeight);
64 CPPUNIT_ASSERT_EQUAL(OString("12"), aDefinition.mpSettings->msFloatTitleHeight);
65 CPPUNIT_ASSERT_EQUAL(OString("15"),
66 aDefinition.mpSettings->msListBoxPreviewDefaultLogicWidth);
67 CPPUNIT_ASSERT_EQUAL(OString("7"),
68 aDefinition.mpSettings->msListBoxPreviewDefaultLogicHeight);
72 void WidgetDefinitionReaderTest::testRead()
74 vcl::WidgetDefinition aDefinition;
76 vcl::WidgetDefinitionReader aReader(getFullUrl("definition1.xml"), getFullUrl(""));
77 CPPUNIT_ASSERT(aReader.read(aDefinition));
79 CPPUNIT_ASSERT_EQUAL(OUString("123456"), aDefinition.mpStyle->maFaceColor.AsRGBHexString());
80 CPPUNIT_ASSERT_EQUAL(OUString("234567"), aDefinition.mpStyle->maCheckedColor.AsRGBHexString());
81 CPPUNIT_ASSERT_EQUAL(OUString("345678"), aDefinition.mpStyle->maLightColor.AsRGBHexString());
83 CPPUNIT_ASSERT_EQUAL(OUString("ffffff"),
84 aDefinition.mpStyle->maVisitedLinkColor.AsRGBHexString());
85 CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aDefinition.mpStyle->maToolTextColor.AsRGBHexString());
86 CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aDefinition.mpStyle->maFontColor.AsRGBHexString());
88 // Pushbutton
90 ControlState eState
91 = ControlState::DEFAULT | ControlState::ENABLED | ControlState::ROLLOVER;
92 std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
93 = aDefinition.getDefinition(ControlType::Pushbutton, ControlPart::Entire)
94 ->getStates(ControlType::Pushbutton, ControlPart::Entire, eState,
95 PushButtonValue());
97 CPPUNIT_ASSERT_EQUAL(size_t(2), aStates.size());
99 CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpWidgetDrawActions.size());
100 CPPUNIT_ASSERT_EQUAL(vcl::WidgetDrawActionType::RECTANGLE,
101 aStates[0]->mpWidgetDrawActions[0]->maType);
102 CPPUNIT_ASSERT_EQUAL(vcl::WidgetDrawActionType::LINE,
103 aStates[0]->mpWidgetDrawActions[1]->maType);
106 // Radiobutton
108 std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
109 = aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
110 ->getStates(ControlType::Radiobutton, ControlPart::Entire, ControlState::NONE,
111 ImplControlValue(ButtonValue::On));
112 CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
113 CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpWidgetDrawActions.size());
117 std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
118 = aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
119 ->getStates(ControlType::Radiobutton, ControlPart::Entire, ControlState::NONE,
120 ImplControlValue(ButtonValue::Off));
121 CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
122 CPPUNIT_ASSERT_EQUAL(size_t(1), aStates[0]->mpWidgetDrawActions.size());
126 } // namespace
128 CPPUNIT_TEST_SUITE_REGISTRATION(WidgetDefinitionReaderTest);
130 CPPUNIT_PLUGIN_IMPLEMENT();
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */