1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: AccessibilityOptTest.cxx,v $
9 * last change: $Author: as $ $Date: 2008/03/19 11:09:23 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 #include "AccessibilityOptTest.hxx"
37 #include "configitems/accessibilityoptions_const.hxx"
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/container/XNameAccess.hpp>
42 #include <comphelper/configurationhelper.hxx>
43 #include <unotools/processfactory.hxx>
45 namespace css
= ::com::sun::star
;
47 AccessibilityOptTest::AccessibilityOptTest()
49 m_xCfg
= css::uno::Reference
< css::container::XNameAccess
>(
50 ::comphelper::ConfigurationHelper::openConfig(
51 ::utl::getProcessServiceFactory(),
53 ::comphelper::ConfigurationHelper::E_STANDARD
),
57 AccessibilityOptTest::~AccessibilityOptTest()
63 //=============================================================================
64 //test GetAutoDetectSystemHC()
65 void AccessibilityOptTest::impl_checkGetAutoDetectSystemHC()
67 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
68 sal_Bool bAutoDetectSystemHC
;
69 sal_Bool bAutoDetectSystemHC_
;
71 bAutoDetectSystemHC
= aAccessibilityOpt
.GetAutoDetectSystemHC();
72 xSet
->setPropertyValue( s_sAutoDetectSystemHC
, css::uno::makeAny(bAutoDetectSystemHC
? sal_False
:sal_True
) );
73 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
74 bAutoDetectSystemHC_
= aAccessibilityOpt
.GetAutoDetectSystemHC();
76 if ( bAutoDetectSystemHC_
== bAutoDetectSystemHC
)//old config item will not throw error
77 throw css::uno::RuntimeException(
78 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetAutoDetectSystemHC() error!")), 0);
81 //=============================================================================
82 //test GetIsForPagePreviews()
83 void AccessibilityOptTest::impl_checkGetIsForPagePreviews()
85 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
86 sal_Bool bIsForPagePreviews
;
87 sal_Bool bIsForPagePreviews_
;
89 bIsForPagePreviews
= aAccessibilityOpt
.GetIsForPagePreviews();
90 xSet
->setPropertyValue( s_sIsForPagePreviews
, css::uno::makeAny(bIsForPagePreviews
? sal_False
:sal_True
) );
91 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
92 bIsForPagePreviews_
= aAccessibilityOpt
.GetIsForPagePreviews();
94 if ( bIsForPagePreviews_
== bIsForPagePreviews
)//old config item will not throw error
95 throw css::uno::RuntimeException(
96 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsForPagePreviews() error!")), 0);
99 //=============================================================================
100 //test impl_checkGetIsHelpTipsDisappear()
101 void AccessibilityOptTest::impl_checkGetIsHelpTipsDisappear()
103 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
104 sal_Bool bIsHelpTipsDisappear
;
105 sal_Bool bIsHelpTipsDisappear_
;
107 bIsHelpTipsDisappear
= aAccessibilityOpt
.GetIsHelpTipsDisappear();
108 xSet
->setPropertyValue( s_sIsHelpTipsDisappear
, css::uno::makeAny(bIsHelpTipsDisappear
? sal_False
:sal_True
) );
109 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
110 bIsHelpTipsDisappear_
= aAccessibilityOpt
.GetIsHelpTipsDisappear();
112 if ( bIsHelpTipsDisappear_
== bIsHelpTipsDisappear
)//old config item will not throw error
113 throw css::uno::RuntimeException(
114 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsHelpTipsDisappear() error!")), 0);
117 //=============================================================================
118 //test impl_checkGetIsAllowAnimatedGraphics()
119 void AccessibilityOptTest::impl_checkGetIsAllowAnimatedGraphics()
121 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
122 sal_Bool bIsAllowAnimatedGraphics
;
123 sal_Bool bIsAllowAnimatedGraphics_
;
125 bIsAllowAnimatedGraphics
= aAccessibilityOpt
.GetIsAllowAnimatedGraphics();
126 xSet
->setPropertyValue( s_sIsAllowAnimatedGraphics
, css::uno::makeAny(bIsAllowAnimatedGraphics
? sal_False
:sal_True
) );
127 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
128 bIsAllowAnimatedGraphics_
= aAccessibilityOpt
.GetIsAllowAnimatedGraphics();
130 if ( bIsAllowAnimatedGraphics_
== bIsAllowAnimatedGraphics
)//old config item will not throw error
131 throw css::uno::RuntimeException(
132 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsAllowAnimatedGraphics() error!")), 0);
135 //=============================================================================
136 //test impl_checkGetIsAllowAnimatedText()
137 void AccessibilityOptTest::impl_checkGetIsAllowAnimatedText()
139 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
140 sal_Bool bIsAllowAnimatedText
;
141 sal_Bool bIsAllowAnimatedText_
;
143 bIsAllowAnimatedText
= aAccessibilityOpt
.GetIsAllowAnimatedText();
144 xSet
->setPropertyValue( s_sIsAllowAnimatedText
, css::uno::makeAny(bIsAllowAnimatedText
? sal_False
:sal_True
) );
145 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
146 bIsAllowAnimatedText_
= aAccessibilityOpt
.GetIsAllowAnimatedText();
148 if ( bIsAllowAnimatedText_
== bIsAllowAnimatedText
)//old config item will not throw error
149 throw css::uno::RuntimeException(
150 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsAllowAnimatedText() error!")), 0);
153 //=============================================================================
154 //test impl_checkGetIsAutomaticFontColor()
155 void AccessibilityOptTest::impl_checkGetIsAutomaticFontColor()
157 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
158 sal_Bool bIsAutomaticFontColor
;
159 sal_Bool bIsAutomaticFontColor_
;
161 bIsAutomaticFontColor
= aAccessibilityOpt
.GetIsAutomaticFontColor();
162 xSet
->setPropertyValue( s_sIsAutomaticFontColor
, css::uno::makeAny(bIsAutomaticFontColor
? sal_False
:sal_True
) );
163 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
164 bIsAutomaticFontColor_
= aAccessibilityOpt
.GetIsAutomaticFontColor();
166 if ( bIsAutomaticFontColor_
== bIsAutomaticFontColor
)//old config item will not throw error
167 throw css::uno::RuntimeException(
168 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsAutomaticFontColor() error!")), 0);
171 //=============================================================================
172 //test impl_checkGetIsSystemFont()
173 void AccessibilityOptTest::impl_checkGetIsSystemFont()
175 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
176 sal_Bool bIsSystemFont
;
177 sal_Bool bIsSystemFont_
;
179 bIsSystemFont
= aAccessibilityOpt
.GetIsSystemFont();
180 xSet
->setPropertyValue( s_sIsSystemFont
, css::uno::makeAny(bIsSystemFont
? sal_False
:sal_True
) );
181 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
182 bIsSystemFont_
= aAccessibilityOpt
.GetIsSystemFont();
184 if ( bIsSystemFont_
== bIsSystemFont
)//old config item will not throw error
185 throw css::uno::RuntimeException(
186 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsSystemFont() error!")), 0);
189 //=============================================================================
190 //test impl_checkGetHelpTipSeconds()
191 void AccessibilityOptTest::impl_checkGetHelpTipSeconds()
193 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
194 sal_Int16 nHelpTipSeconds
;
195 sal_Int16 nHelpTipSeconds_
;
197 nHelpTipSeconds
= aAccessibilityOpt
.GetHelpTipSeconds();
198 xSet
->setPropertyValue( s_sHelpTipSeconds
, css::uno::makeAny(sal_Int16(nHelpTipSeconds
+1)) );
199 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
200 nHelpTipSeconds_
= aAccessibilityOpt
.GetHelpTipSeconds();
202 if ( nHelpTipSeconds_
== nHelpTipSeconds
)//old config item will not throw error
203 throw css::uno::RuntimeException(
204 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetHelpTipSeconds() error!")), 0);
207 //=============================================================================
208 //test impl_checkIsSelectionInReadonly()
209 void AccessibilityOptTest::impl_checkIsSelectionInReadonly()
211 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
212 sal_Bool bIsSelectionInReadonly
;
213 sal_Bool bIsSelectionInReadonly_
;
215 bIsSelectionInReadonly
= aAccessibilityOpt
.IsSelectionInReadonly();
216 xSet
->setPropertyValue( s_sIsSelectionInReadonly
, css::uno::makeAny(bIsSelectionInReadonly
? sal_False
:sal_True
) );
217 ::comphelper::ConfigurationHelper::flush(m_xCfg
);
218 bIsSelectionInReadonly_
= aAccessibilityOpt
.IsSelectionInReadonly();
220 if ( bIsSelectionInReadonly_
== bIsSelectionInReadonly
)//old config item will not throw error
221 throw css::uno::RuntimeException(
222 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsSelectionInReadonly() error!")), 0);
225 //=============================================================================
226 //test SetAutoDetectSystemHC()
227 void AccessibilityOptTest::impl_checkSetAutoDetectSystemHC()
229 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
230 sal_Bool bAutoDetectSystemHC
;
231 sal_Bool bAutoDetectSystemHC_
;
233 xSet
->getPropertyValue(s_sAutoDetectSystemHC
) >>= bAutoDetectSystemHC
;
234 aAccessibilityOpt
.SetAutoDetectSystemHC( bAutoDetectSystemHC
? sal_False
:sal_True
);
235 xSet
->getPropertyValue(s_sAutoDetectSystemHC
) >>= bAutoDetectSystemHC_
;
237 if ( bAutoDetectSystemHC_
== bAutoDetectSystemHC
)//old config item will throw error
238 throw css::uno::RuntimeException(
239 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetAutoDetectSystemHC() error!")), 0);
242 //=============================================================================
243 //test SetIsForPagePreviews()
244 void AccessibilityOptTest::impl_checkSetIsForPagePreviews()
246 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
247 sal_Bool bIsForPagePreviews
;
248 sal_Bool bIsForPagePreviews_
;
250 xSet
->getPropertyValue(s_sIsForPagePreviews
) >>= bIsForPagePreviews
;
251 aAccessibilityOpt
.SetIsForPagePreviews( bIsForPagePreviews
? sal_False
:sal_True
);
252 xSet
->getPropertyValue(s_sIsForPagePreviews
) >>= bIsForPagePreviews_
;
254 if ( bIsForPagePreviews_
== bIsForPagePreviews
)//old config item will throw error
255 throw css::uno::RuntimeException(
256 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsForPagePreviews() error!")), 0);
259 //=============================================================================
260 //test impl_checkSetIsHelpTipsDisappear()
261 void AccessibilityOptTest::impl_checkSetIsHelpTipsDisappear()
263 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
264 sal_Bool bIsHelpTipsDisappear
;
265 sal_Bool bIsHelpTipsDisappear_
;
267 xSet
->getPropertyValue(s_sIsHelpTipsDisappear
) >>= bIsHelpTipsDisappear
;
268 aAccessibilityOpt
.SetIsHelpTipsDisappear( bIsHelpTipsDisappear
? sal_False
:sal_True
);
269 xSet
->getPropertyValue(s_sIsHelpTipsDisappear
) >>= bIsHelpTipsDisappear_
;
271 if ( bIsHelpTipsDisappear_
== bIsHelpTipsDisappear
)//old config item will throw error
272 throw css::uno::RuntimeException(
273 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsHelpTipsDisappear() error!")), 0);
276 //=============================================================================
277 //test impl_checkSetIsAllowAnimatedGraphics()
278 void AccessibilityOptTest::impl_checkSetIsAllowAnimatedGraphics()
280 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
281 sal_Bool bIsAllowAnimatedGraphics
;
282 sal_Bool bIsAllowAnimatedGraphics_
;
284 xSet
->getPropertyValue(s_sIsAllowAnimatedGraphics
) >>= bIsAllowAnimatedGraphics
;
285 aAccessibilityOpt
.SetIsAllowAnimatedGraphics( bIsAllowAnimatedGraphics
? sal_False
:sal_True
);
286 xSet
->getPropertyValue(s_sIsAllowAnimatedGraphics
) >>= bIsAllowAnimatedGraphics_
;
288 if ( bIsAllowAnimatedGraphics_
== bIsAllowAnimatedGraphics
)//old config item will throw error
289 throw css::uno::RuntimeException(
290 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsAllowAnimatedGraphics() error!")), 0);
293 //=============================================================================
294 //test impl_checkSetIsAllowAnimatedText()
295 void AccessibilityOptTest::impl_checkSetIsAllowAnimatedText()
297 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
298 sal_Bool bIsAllowAnimatedText
;
299 sal_Bool bIsAllowAnimatedText_
;
301 xSet
->getPropertyValue(s_sIsAllowAnimatedText
) >>= bIsAllowAnimatedText
;
302 aAccessibilityOpt
.SetIsAllowAnimatedText( bIsAllowAnimatedText
? sal_False
:sal_True
);
303 xSet
->getPropertyValue(s_sIsAllowAnimatedText
) >>= bIsAllowAnimatedText_
;
305 if ( bIsAllowAnimatedText_
== bIsAllowAnimatedText
)//old config item will throw error
306 throw css::uno::RuntimeException(
307 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsAllowAnimatedText() error!")), 0);
310 //=============================================================================
311 //test impl_checkSetIsAutomaticFontColor()
312 void AccessibilityOptTest::impl_checkSetIsAutomaticFontColor()
314 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
315 sal_Bool bIsAutomaticFontColor
;
316 sal_Bool bIsAutomaticFontColor_
;
318 xSet
->getPropertyValue(s_sIsAutomaticFontColor
) >>= bIsAutomaticFontColor
;
319 aAccessibilityOpt
.SetIsAutomaticFontColor( bIsAutomaticFontColor
? sal_False
:sal_True
);
320 xSet
->getPropertyValue(s_sIsAutomaticFontColor
) >>= bIsAutomaticFontColor_
;
322 if ( bIsAutomaticFontColor_
== bIsAutomaticFontColor
)//old config item will throw error
323 throw css::uno::RuntimeException(
324 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsAutomaticFontColor() error!")), 0);
327 //=============================================================================
328 //test impl_checkSetIsSystemFont()
329 void AccessibilityOptTest::impl_checkSetIsSystemFont()
331 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
332 sal_Bool bIsSystemFont
;
333 sal_Bool bIsSystemFont_
;
335 xSet
->getPropertyValue(s_sIsSystemFont
) >>= bIsSystemFont
;
336 aAccessibilityOpt
.SetIsSystemFont( bIsSystemFont
? sal_False
:sal_True
);
337 xSet
->getPropertyValue(s_sIsSystemFont
) >>= bIsSystemFont_
;
339 if ( bIsSystemFont_
== bIsSystemFont
)//old config item will throw error
340 throw css::uno::RuntimeException(
341 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsSystemFont() error!")), 0);
344 //=============================================================================
345 //test impl_checkSetHelpTipSeconds()
346 void AccessibilityOptTest::impl_checkSetHelpTipSeconds()
348 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
349 sal_Int16 nHelpTipSeconds
;
350 sal_Int16 nHelpTipSeconds_
;
352 xSet
->getPropertyValue(s_sHelpTipSeconds
) >>= nHelpTipSeconds
;
353 aAccessibilityOpt
.SetHelpTipSeconds( sal_Int16(nHelpTipSeconds
+1) );
354 xSet
->getPropertyValue(s_sHelpTipSeconds
) >>= nHelpTipSeconds_
;
356 if ( nHelpTipSeconds_
== nHelpTipSeconds
)//old config item will throw error
357 throw css::uno::RuntimeException(
358 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetHelpTipSeconds() error!")), 0);
361 //=============================================================================
362 //test impl_checkSetSelectionInReadonly()
363 void AccessibilityOptTest::impl_checkSetSelectionInReadonly()
365 css::uno::Reference
< css::beans::XPropertySet
> xSet(m_xCfg
, css::uno::UNO_QUERY
);
366 sal_Bool bIsSelectionInReadonly
;
367 sal_Bool bIsSelectionInReadonly_
;
369 xSet
->getPropertyValue(s_sIsSelectionInReadonly
) >>= bIsSelectionInReadonly
;
370 aAccessibilityOpt
.SetSelectionInReadonly( bIsSelectionInReadonly
? sal_False
:sal_True
);
371 xSet
->getPropertyValue(s_sIsSelectionInReadonly
) >>= bIsSelectionInReadonly_
;
373 if ( bIsSelectionInReadonly_
== bIsSelectionInReadonly
)//old config item will throw error
374 throw css::uno::RuntimeException(
375 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetSelectionInReadonly() error!")), 0);
378 //=============================================================================
379 void AccessibilityOptTest::impl_checkAccessibilityOptions()
381 impl_checkGetAutoDetectSystemHC();
382 impl_checkGetIsForPagePreviews();
383 impl_checkGetIsHelpTipsDisappear();
384 impl_checkGetIsAllowAnimatedGraphics();
385 impl_checkGetIsAllowAnimatedText();
386 impl_checkGetIsAutomaticFontColor();
387 impl_checkGetIsSystemFont();
388 impl_checkGetHelpTipSeconds();
389 impl_checkIsSelectionInReadonly();
391 impl_checkSetAutoDetectSystemHC();
392 impl_checkSetIsForPagePreviews();
393 impl_checkSetIsHelpTipsDisappear();
394 impl_checkSetIsAllowAnimatedGraphics();
395 impl_checkSetIsAllowAnimatedText();
396 impl_checkSetIsAutomaticFontColor();
397 impl_checkSetIsSystemFont();
398 impl_checkSetHelpTipSeconds();
399 impl_checkSetSelectionInReadonly();