xref: /trunk/main/svl/qa/complex/ConfigItems/helper/AccessibilityOptTest.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "AccessibilityOptTest.hxx"
29 #include "configitems/accessibilityoptions_const.hxx"
30 
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 
34 #include <comphelper/configurationhelper.hxx>
35 #include <unotools/processfactory.hxx>
36 
37 namespace css = ::com::sun::star;
38 
39 AccessibilityOptTest::AccessibilityOptTest()
40 {
41     m_xCfg = css::uno::Reference< css::container::XNameAccess >(
42         ::comphelper::ConfigurationHelper::openConfig(
43         ::utl::getProcessServiceFactory(),
44         s_sAccessibility,
45         ::comphelper::ConfigurationHelper::E_STANDARD),
46         css::uno::UNO_QUERY);
47 }
48 
49 AccessibilityOptTest::~AccessibilityOptTest()
50 {
51     if (m_xCfg.is())
52         m_xCfg.clear();
53 }
54 
55 //=============================================================================
56 //test GetAutoDetectSystemHC()
57 void AccessibilityOptTest::impl_checkGetAutoDetectSystemHC()
58 {
59     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
60     sal_Bool bAutoDetectSystemHC;
61     sal_Bool bAutoDetectSystemHC_;
62 
63     bAutoDetectSystemHC  = aAccessibilityOpt.GetAutoDetectSystemHC();
64     xSet->setPropertyValue( s_sAutoDetectSystemHC, css::uno::makeAny(bAutoDetectSystemHC ? sal_False:sal_True) );
65     ::comphelper::ConfigurationHelper::flush(m_xCfg);
66     bAutoDetectSystemHC_ = aAccessibilityOpt.GetAutoDetectSystemHC();
67 
68     if ( bAutoDetectSystemHC_ == bAutoDetectSystemHC )//old config item will not throw error
69         throw css::uno::RuntimeException(
70         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetAutoDetectSystemHC() error!")), 0);
71 }
72 
73 //=============================================================================
74 //test GetIsForPagePreviews()
75 void AccessibilityOptTest::impl_checkGetIsForPagePreviews()
76 {
77     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
78     sal_Bool bIsForPagePreviews ;
79     sal_Bool bIsForPagePreviews_;
80 
81     bIsForPagePreviews  = aAccessibilityOpt.GetIsForPagePreviews();
82     xSet->setPropertyValue( s_sIsForPagePreviews, css::uno::makeAny(bIsForPagePreviews ? sal_False:sal_True) );
83     ::comphelper::ConfigurationHelper::flush(m_xCfg);
84     bIsForPagePreviews_ = aAccessibilityOpt.GetIsForPagePreviews();
85 
86     if ( bIsForPagePreviews_ == bIsForPagePreviews )//old config item will not throw error
87         throw css::uno::RuntimeException(
88         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsForPagePreviews() error!")),  0);
89 }
90 
91 //=============================================================================
92 //test impl_checkGetIsHelpTipsDisappear()
93 void AccessibilityOptTest::impl_checkGetIsHelpTipsDisappear()
94 {
95     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
96     sal_Bool bIsHelpTipsDisappear ;
97     sal_Bool bIsHelpTipsDisappear_;
98 
99     bIsHelpTipsDisappear  = aAccessibilityOpt.GetIsHelpTipsDisappear();
100     xSet->setPropertyValue( s_sIsHelpTipsDisappear, css::uno::makeAny(bIsHelpTipsDisappear ? sal_False:sal_True) );
101     ::comphelper::ConfigurationHelper::flush(m_xCfg);
102     bIsHelpTipsDisappear_ = aAccessibilityOpt.GetIsHelpTipsDisappear();
103 
104     if ( bIsHelpTipsDisappear_ == bIsHelpTipsDisappear )//old config item will not throw error
105         throw css::uno::RuntimeException(
106         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsHelpTipsDisappear() error!")),    0);
107 }
108 
109 //=============================================================================
110 //test impl_checkGetIsAllowAnimatedGraphics()
111 void AccessibilityOptTest::impl_checkGetIsAllowAnimatedGraphics()
112 {
113     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
114     sal_Bool bIsAllowAnimatedGraphics ;
115     sal_Bool bIsAllowAnimatedGraphics_;
116 
117     bIsAllowAnimatedGraphics  = aAccessibilityOpt.GetIsAllowAnimatedGraphics();
118     xSet->setPropertyValue( s_sIsAllowAnimatedGraphics, css::uno::makeAny(bIsAllowAnimatedGraphics ? sal_False:sal_True) );
119     ::comphelper::ConfigurationHelper::flush(m_xCfg);
120     bIsAllowAnimatedGraphics_ = aAccessibilityOpt.GetIsAllowAnimatedGraphics();
121 
122     if ( bIsAllowAnimatedGraphics_ == bIsAllowAnimatedGraphics )//old config item will not throw error
123         throw css::uno::RuntimeException(
124         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsAllowAnimatedGraphics() error!")),    0);
125 }
126 
127 //=============================================================================
128 //test impl_checkGetIsAllowAnimatedText()
129 void AccessibilityOptTest::impl_checkGetIsAllowAnimatedText()
130 {
131     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
132     sal_Bool bIsAllowAnimatedText ;
133     sal_Bool bIsAllowAnimatedText_;
134 
135     bIsAllowAnimatedText  = aAccessibilityOpt.GetIsAllowAnimatedText();
136     xSet->setPropertyValue( s_sIsAllowAnimatedText, css::uno::makeAny(bIsAllowAnimatedText ? sal_False:sal_True) );
137     ::comphelper::ConfigurationHelper::flush(m_xCfg);
138     bIsAllowAnimatedText_ = aAccessibilityOpt.GetIsAllowAnimatedText();
139 
140     if ( bIsAllowAnimatedText_ == bIsAllowAnimatedText )//old config item will not throw error
141         throw css::uno::RuntimeException(
142         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsAllowAnimatedText() error!")),    0);
143 }
144 
145 //=============================================================================
146 //test impl_checkGetIsAutomaticFontColor()
147 void AccessibilityOptTest::impl_checkGetIsAutomaticFontColor()
148 {
149     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
150     sal_Bool bIsAutomaticFontColor ;
151     sal_Bool bIsAutomaticFontColor_;
152 
153     bIsAutomaticFontColor  = aAccessibilityOpt.GetIsAutomaticFontColor();
154     xSet->setPropertyValue( s_sIsAutomaticFontColor, css::uno::makeAny(bIsAutomaticFontColor ? sal_False:sal_True) );
155     ::comphelper::ConfigurationHelper::flush(m_xCfg);
156     bIsAutomaticFontColor_ = aAccessibilityOpt.GetIsAutomaticFontColor();
157 
158     if ( bIsAutomaticFontColor_ == bIsAutomaticFontColor )//old config item will not throw error
159         throw css::uno::RuntimeException(
160         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsAutomaticFontColor() error!")),   0);
161 }
162 
163 //=============================================================================
164 //test impl_checkGetIsSystemFont()
165 void AccessibilityOptTest::impl_checkGetIsSystemFont()
166 {
167     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
168     sal_Bool bIsSystemFont ;
169     sal_Bool bIsSystemFont_;
170 
171     bIsSystemFont  = aAccessibilityOpt.GetIsSystemFont();
172     xSet->setPropertyValue( s_sIsSystemFont, css::uno::makeAny(bIsSystemFont ? sal_False:sal_True) );
173     ::comphelper::ConfigurationHelper::flush(m_xCfg);
174     bIsSystemFont_ = aAccessibilityOpt.GetIsSystemFont();
175 
176     if ( bIsSystemFont_ == bIsSystemFont )//old config item will not throw error
177         throw css::uno::RuntimeException(
178         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetIsSystemFont() error!")),   0);
179 }
180 
181 //=============================================================================
182 //test impl_checkGetHelpTipSeconds()
183 void AccessibilityOptTest::impl_checkGetHelpTipSeconds()
184 {
185     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
186     sal_Int16 nHelpTipSeconds ;
187     sal_Int16 nHelpTipSeconds_;
188 
189     nHelpTipSeconds  = aAccessibilityOpt.GetHelpTipSeconds();
190     xSet->setPropertyValue( s_sHelpTipSeconds, css::uno::makeAny(sal_Int16(nHelpTipSeconds+1)) );
191     ::comphelper::ConfigurationHelper::flush(m_xCfg);
192     nHelpTipSeconds_ = aAccessibilityOpt.GetHelpTipSeconds();
193 
194     if ( nHelpTipSeconds_ == nHelpTipSeconds )//old config item will not throw error
195         throw css::uno::RuntimeException(
196         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetHelpTipSeconds() error!")), 0);
197 }
198 
199 //=============================================================================
200 //test impl_checkIsSelectionInReadonly()
201 void AccessibilityOptTest::impl_checkIsSelectionInReadonly()
202 {
203     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
204     sal_Bool bIsSelectionInReadonly ;
205     sal_Bool bIsSelectionInReadonly_;
206 
207     bIsSelectionInReadonly  = aAccessibilityOpt.IsSelectionInReadonly();
208     xSet->setPropertyValue( s_sIsSelectionInReadonly, css::uno::makeAny(bIsSelectionInReadonly ? sal_False:sal_True) );
209     ::comphelper::ConfigurationHelper::flush(m_xCfg);
210     bIsSelectionInReadonly_ = aAccessibilityOpt.IsSelectionInReadonly();
211 
212     if ( bIsSelectionInReadonly_ == bIsSelectionInReadonly )//old config item will not throw error
213         throw css::uno::RuntimeException(
214         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsSelectionInReadonly() error!")), 0);
215 }
216 
217 //=============================================================================
218 //test SetAutoDetectSystemHC()
219 void AccessibilityOptTest::impl_checkSetAutoDetectSystemHC()
220 {
221     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
222     sal_Bool bAutoDetectSystemHC;
223     sal_Bool bAutoDetectSystemHC_;
224 
225     xSet->getPropertyValue(s_sAutoDetectSystemHC) >>= bAutoDetectSystemHC;
226     aAccessibilityOpt.SetAutoDetectSystemHC( bAutoDetectSystemHC ? sal_False:sal_True );
227     xSet->getPropertyValue(s_sAutoDetectSystemHC) >>= bAutoDetectSystemHC_;
228 
229     if ( bAutoDetectSystemHC_ == bAutoDetectSystemHC )//old config item will throw error
230         throw css::uno::RuntimeException(
231         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetAutoDetectSystemHC() error!")), 0);
232 }
233 
234 //=============================================================================
235 //test SetIsForPagePreviews()
236 void AccessibilityOptTest::impl_checkSetIsForPagePreviews()
237 {
238     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
239     sal_Bool bIsForPagePreviews ;
240     sal_Bool bIsForPagePreviews_;
241 
242     xSet->getPropertyValue(s_sIsForPagePreviews) >>= bIsForPagePreviews;
243     aAccessibilityOpt.SetIsForPagePreviews( bIsForPagePreviews ? sal_False:sal_True );
244     xSet->getPropertyValue(s_sIsForPagePreviews) >>= bIsForPagePreviews_;
245 
246     if ( bIsForPagePreviews_ == bIsForPagePreviews )//old config item will throw error
247         throw css::uno::RuntimeException(
248         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsForPagePreviews() error!")),  0);
249 }
250 
251 //=============================================================================
252 //test impl_checkSetIsHelpTipsDisappear()
253 void AccessibilityOptTest::impl_checkSetIsHelpTipsDisappear()
254 {
255     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
256     sal_Bool bIsHelpTipsDisappear ;
257     sal_Bool bIsHelpTipsDisappear_;
258 
259     xSet->getPropertyValue(s_sIsHelpTipsDisappear) >>= bIsHelpTipsDisappear;
260     aAccessibilityOpt.SetIsHelpTipsDisappear( bIsHelpTipsDisappear ? sal_False:sal_True );
261     xSet->getPropertyValue(s_sIsHelpTipsDisappear) >>= bIsHelpTipsDisappear_;
262 
263     if ( bIsHelpTipsDisappear_ == bIsHelpTipsDisappear )//old config item will throw error
264         throw css::uno::RuntimeException(
265         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsHelpTipsDisappear() error!")),    0);
266 }
267 
268 //=============================================================================
269 //test impl_checkSetIsAllowAnimatedGraphics()
270 void AccessibilityOptTest::impl_checkSetIsAllowAnimatedGraphics()
271 {
272     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
273     sal_Bool bIsAllowAnimatedGraphics ;
274     sal_Bool bIsAllowAnimatedGraphics_;
275 
276     xSet->getPropertyValue(s_sIsAllowAnimatedGraphics) >>= bIsAllowAnimatedGraphics;
277     aAccessibilityOpt.SetIsAllowAnimatedGraphics( bIsAllowAnimatedGraphics ? sal_False:sal_True );
278     xSet->getPropertyValue(s_sIsAllowAnimatedGraphics) >>= bIsAllowAnimatedGraphics_;
279 
280     if ( bIsAllowAnimatedGraphics_ == bIsAllowAnimatedGraphics )//old config item will throw error
281         throw css::uno::RuntimeException(
282         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsAllowAnimatedGraphics() error!")),    0);
283 }
284 
285 //=============================================================================
286 //test impl_checkSetIsAllowAnimatedText()
287 void AccessibilityOptTest::impl_checkSetIsAllowAnimatedText()
288 {
289     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
290     sal_Bool bIsAllowAnimatedText ;
291     sal_Bool bIsAllowAnimatedText_;
292 
293     xSet->getPropertyValue(s_sIsAllowAnimatedText) >>= bIsAllowAnimatedText;
294     aAccessibilityOpt.SetIsAllowAnimatedText( bIsAllowAnimatedText ? sal_False:sal_True );
295     xSet->getPropertyValue(s_sIsAllowAnimatedText) >>= bIsAllowAnimatedText_;
296 
297     if ( bIsAllowAnimatedText_ == bIsAllowAnimatedText )//old config item will throw error
298         throw css::uno::RuntimeException(
299         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsAllowAnimatedText() error!")),    0);
300 }
301 
302 //=============================================================================
303 //test impl_checkSetIsAutomaticFontColor()
304 void AccessibilityOptTest::impl_checkSetIsAutomaticFontColor()
305 {
306     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
307     sal_Bool bIsAutomaticFontColor ;
308     sal_Bool bIsAutomaticFontColor_;
309 
310     xSet->getPropertyValue(s_sIsAutomaticFontColor) >>= bIsAutomaticFontColor;
311     aAccessibilityOpt.SetIsAutomaticFontColor( bIsAutomaticFontColor ? sal_False:sal_True );
312     xSet->getPropertyValue(s_sIsAutomaticFontColor) >>= bIsAutomaticFontColor_;
313 
314     if ( bIsAutomaticFontColor_ == bIsAutomaticFontColor )//old config item will throw error
315         throw css::uno::RuntimeException(
316         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsAutomaticFontColor() error!")),   0);
317 }
318 
319 //=============================================================================
320 //test impl_checkSetIsSystemFont()
321 void AccessibilityOptTest::impl_checkSetIsSystemFont()
322 {
323     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
324     sal_Bool bIsSystemFont ;
325     sal_Bool bIsSystemFont_;
326 
327     xSet->getPropertyValue(s_sIsSystemFont) >>= bIsSystemFont;
328     aAccessibilityOpt.SetIsSystemFont( bIsSystemFont ? sal_False:sal_True );
329     xSet->getPropertyValue(s_sIsSystemFont) >>= bIsSystemFont_;
330 
331     if ( bIsSystemFont_ == bIsSystemFont )//old config item will throw error
332         throw css::uno::RuntimeException(
333         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetIsSystemFont() error!")),   0);
334 }
335 
336 //=============================================================================
337 //test impl_checkSetHelpTipSeconds()
338 void AccessibilityOptTest::impl_checkSetHelpTipSeconds()
339 {
340     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
341     sal_Int16 nHelpTipSeconds ;
342     sal_Int16 nHelpTipSeconds_;
343 
344     xSet->getPropertyValue(s_sHelpTipSeconds) >>= nHelpTipSeconds;
345     aAccessibilityOpt.SetHelpTipSeconds( sal_Int16(nHelpTipSeconds+1) );
346     xSet->getPropertyValue(s_sHelpTipSeconds) >>= nHelpTipSeconds_;
347 
348     if ( nHelpTipSeconds_ == nHelpTipSeconds )//old config item will throw error
349         throw css::uno::RuntimeException(
350         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetHelpTipSeconds() error!")), 0);
351 }
352 
353 //=============================================================================
354 //test impl_checkSetSelectionInReadonly()
355 void AccessibilityOptTest::impl_checkSetSelectionInReadonly()
356 {
357     css::uno::Reference< css::beans::XPropertySet > xSet(m_xCfg, css::uno::UNO_QUERY);
358     sal_Bool bIsSelectionInReadonly ;
359     sal_Bool bIsSelectionInReadonly_;
360 
361     xSet->getPropertyValue(s_sIsSelectionInReadonly) >>= bIsSelectionInReadonly;
362     aAccessibilityOpt.SetSelectionInReadonly( bIsSelectionInReadonly ? sal_False:sal_True );
363     xSet->getPropertyValue(s_sIsSelectionInReadonly) >>= bIsSelectionInReadonly_;
364 
365     if ( bIsSelectionInReadonly_ == bIsSelectionInReadonly )//old config item will throw error
366         throw css::uno::RuntimeException(
367         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetSelectionInReadonly() error!")),    0);
368 }
369 
370 //=============================================================================
371 void AccessibilityOptTest::impl_checkAccessibilityOptions()
372 {
373     impl_checkGetAutoDetectSystemHC();
374     impl_checkGetIsForPagePreviews();
375     impl_checkGetIsHelpTipsDisappear();
376     impl_checkGetIsAllowAnimatedGraphics();
377     impl_checkGetIsAllowAnimatedText();
378     impl_checkGetIsAutomaticFontColor();
379     impl_checkGetIsSystemFont();
380     impl_checkGetHelpTipSeconds();
381     impl_checkIsSelectionInReadonly();
382 
383     impl_checkSetAutoDetectSystemHC();
384     impl_checkSetIsForPagePreviews();
385     impl_checkSetIsHelpTipsDisappear();
386     impl_checkSetIsAllowAnimatedGraphics();
387     impl_checkSetIsAllowAnimatedText();
388     impl_checkSetIsAutomaticFontColor();
389     impl_checkSetIsSystemFont();
390     impl_checkSetHelpTipSeconds();
391     impl_checkSetSelectionInReadonly();
392 }
393