1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <test/cppunitasserthelper.hxx>
11 #include <test/drawing/captionshape.hxx>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/uno/Any.hxx>
15 #include <com/sun/star/uno/Reference.hxx>
16 #include <com/sun/star/awt/Point.hpp>
18 #include <cppunit/extensions/HelperMacros.h>
20 using namespace com::sun::star
;
21 using namespace com::sun::star::uno
;
25 void CaptionShape::testCaptionShapeProperties()
27 uno::Reference
<beans::XPropertySet
> xCaptionShape(init(), UNO_QUERY_THROW
);
31 propName
= "CornerRadius";
32 sal_Int32 nCornerRadiusGet
= 5;
33 sal_Int32 nCornerRadiusSet
= 0;
34 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue CornerRadius",
35 xCaptionShape
->getPropertyValue(propName
) >>= nCornerRadiusGet
);
37 aNewValue
<<= nCornerRadiusGet
+ 5;
38 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
39 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= nCornerRadiusSet
);
40 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue CornerRadius", nCornerRadiusGet
+ 5,
43 propName
= "CaptionPoint";
44 awt::Point aCaptionPointGet
;
45 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionPoint",
46 xCaptionShape
->getPropertyValue(propName
) >>= aCaptionPointGet
);
48 awt::Point aCaptionPointSet
;
49 aNewValue
<<= awt::Point(5, 5);
50 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
51 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= aCaptionPointSet
);
52 CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue of CaptionPoint", aCaptionPointSet
,
55 propName
= "CaptionType";
56 sal_Int16 captionTypeGet
= 0;
57 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionType",
58 xCaptionShape
->getPropertyValue(propName
) >>= captionTypeGet
);
60 sal_Int16 captionTypeSet
= 0;
61 const sal_Int16 FIVE
= 5;
63 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
64 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionTypeSet
);
65 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionType", FIVE
,
68 propName
= "CaptionIsFixedAngle";
69 bool captionIsFixedAngleGet
= false;
70 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionPointIsFixedAngle",
71 xCaptionShape
->getPropertyValue(propName
) >>= captionIsFixedAngleGet
);
73 bool captionIsFixedAngleSet
= false;
74 aNewValue
<<= !captionIsFixedAngleGet
;
75 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
76 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionIsFixedAngleSet
);
77 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionPointisFixedAngle",
78 captionIsFixedAngleSet
, !captionIsFixedAngleGet
);
80 propName
= "CaptionAngle";
81 sal_Int32 captionAngleGet
;
82 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionAngle",
83 xCaptionShape
->getPropertyValue(propName
) >>= captionAngleGet
);
85 sal_Int32 captionAngleSet
= 0;
86 aNewValue
<<= captionAngleGet
+ 5;
87 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
88 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionAngleSet
);
89 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionAngle", captionAngleSet
,
92 propName
= "CaptionGap";
93 sal_Int32 captionGapGet
;
94 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionGap",
95 xCaptionShape
->getPropertyValue(propName
) >>= captionGapGet
);
97 sal_Int32 captionGapSet
= 0;
98 aNewValue
<<= captionGapGet
+ 5;
99 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
100 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionGapSet
);
101 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionGap", captionGapSet
,
104 propName
= "CaptionEscapeDirection";
105 sal_Int32 captionEscapeDirectionGet
;
106 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionEscapeDirection",
107 xCaptionShape
->getPropertyValue(propName
) >>= captionEscapeDirectionGet
);
109 sal_Int32 captionEscapeDirectionSet
= 0;
110 aNewValue
<<= captionEscapeDirectionGet
+ 5;
111 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
112 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionEscapeDirectionSet
);
113 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeDirection",
114 captionEscapeDirectionSet
, captionEscapeDirectionGet
+ 5);
116 propName
= "CaptionIsEscapeRelative";
117 bool captionIsEscapeRelativeGet
= false;
118 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionIsEscapeRelative",
119 xCaptionShape
->getPropertyValue(propName
)
120 >>= captionIsEscapeRelativeGet
);
122 bool captionIsEscapeRelativeSet
= false;
123 aNewValue
<<= !captionIsEscapeRelativeGet
;
124 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
125 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionIsEscapeRelativeSet
);
126 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionIsEscapeRelative",
127 captionIsEscapeRelativeSet
, !captionIsEscapeRelativeGet
);
129 propName
= "CaptionEscapeRelative";
130 sal_Int32 captionEscapeRelativeGet
;
131 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionEscapeRelative",
132 xCaptionShape
->getPropertyValue(propName
) >>= captionEscapeRelativeGet
);
134 sal_Int32 captionEscapeRelativeSet
= 0;
135 aNewValue
<<= captionEscapeRelativeGet
+ 5;
136 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
137 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionEscapeRelativeSet
);
138 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeRelative",
139 captionEscapeRelativeSet
, captionEscapeRelativeGet
+ 5);
141 propName
= "CaptionEscapeAbsolute";
142 sal_Int32 captionEscapeAbsoluteGet
;
143 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionEscapeAbsolute",
144 xCaptionShape
->getPropertyValue(propName
) >>= captionEscapeAbsoluteGet
);
146 sal_Int32 captionEscapeAbsoluteSet
= 0;
147 aNewValue
<<= captionEscapeAbsoluteGet
+ 5;
148 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
149 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionEscapeAbsoluteSet
);
150 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeAbsolute",
151 captionEscapeAbsoluteSet
, captionEscapeAbsoluteGet
+ 5);
153 propName
= "CaptionLineLength";
154 sal_Int32 captionLineLengthGet
;
155 CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionLineLength",
156 xCaptionShape
->getPropertyValue(propName
) >>= captionLineLengthGet
);
158 sal_Int32 captionLineLengthSet
= 0;
159 aNewValue
<<= captionLineLengthGet
+ 5;
160 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
161 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionLineLengthSet
);
162 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeAbsolute",
163 captionLineLengthSet
, captionLineLengthGet
+ 5);
165 propName
= "CaptionIsFitLineLength";
166 bool captionIsFitLineLengthGet
= false;
167 CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionIsFitLineLength",
168 xCaptionShape
->getPropertyValue(propName
) >>= captionIsFitLineLengthGet
);
170 bool captionIsFitLineLengthSet
= false;
171 aNewValue
<<= !captionIsFitLineLengthGet
;
172 xCaptionShape
->setPropertyValue(propName
, aNewValue
);
173 CPPUNIT_ASSERT(xCaptionShape
->getPropertyValue(propName
) >>= captionIsFitLineLengthSet
);
174 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionIsFitLineLength",
175 captionIsFitLineLengthSet
, !captionIsFitLineLengthGet
);
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */