1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/* -*- 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 <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <unotest/bootstrapfixturebase.hxx>
#include <widgetdraw/WidgetDefinitionReader.hxx>
namespace
{
static OUString const gaDataUrl("/vcl/qa/cppunit/widgetdraw/data/");
class WidgetDefinitionReaderTest : public test::BootstrapFixtureBase
{
private:
OUString getFullUrl(const OUString& sFileName)
{
return m_directories.getURLFromSrc(gaDataUrl) + sFileName;
}
public:
void testRead();
CPPUNIT_TEST_SUITE(WidgetDefinitionReaderTest);
CPPUNIT_TEST(testRead);
CPPUNIT_TEST_SUITE_END();
};
void WidgetDefinitionReaderTest::testRead()
{
vcl::WidgetDefinition aDefinition;
vcl::WidgetDefinitionReader aReader(getFullUrl("definition1.xml"), getFullUrl(""));
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->maFontColor.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, eState, ImplControlValue());
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates.size());
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpDrawCommands.size());
CPPUNIT_ASSERT_EQUAL(vcl::DrawCommandType::RECTANGLE,
aStates[0]->mpDrawCommands[0]->maType);
CPPUNIT_ASSERT_EQUAL(vcl::DrawCommandType::CIRCLE, aStates[0]->mpDrawCommands[1]->maType);
}
// Radiobutton
{
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
= aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
->getStates(ControlType::Radiobutton, ControlState::NONE,
ImplControlValue(ButtonValue::On));
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpDrawCommands.size());
}
{
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
= aDefinition.getDefinition(ControlType::Radiobutton, ControlPart::Entire)
->getStates(ControlType::Radiobutton, ControlState::NONE,
ImplControlValue(ButtonValue::Off));
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates[0]->mpDrawCommands.size());
}
}
} // namespace
CPPUNIT_TEST_SUITE_REGISTRATION(WidgetDefinitionReaderTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|