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