2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package complex
.indeterminateState
;
21 import com
.sun
.star
.accessibility
.AccessibleRole
;
22 import com
.sun
.star
.accessibility
.AccessibleStateType
;
23 import com
.sun
.star
.accessibility
.XAccessible
;
24 import com
.sun
.star
.accessibility
.XAccessibleContext
;
25 import com
.sun
.star
.awt
.FontWeight
;
26 import com
.sun
.star
.awt
.XWindow
;
27 import com
.sun
.star
.beans
.XPropertySet
;
28 import com
.sun
.star
.frame
.XController
;
29 import com
.sun
.star
.frame
.XModel
;
30 import com
.sun
.star
.lang
.XMultiServiceFactory
;
31 import com
.sun
.star
.text
.XText
;
32 import com
.sun
.star
.text
.XTextDocument
;
33 import com
.sun
.star
.text
.XTextRange
;
34 import com
.sun
.star
.text
.XTextViewCursorSupplier
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
37 import org
.junit
.After
;
38 import org
.junit
.AfterClass
;
39 import org
.junit
.Before
;
40 import org
.junit
.BeforeClass
;
41 import org
.junit
.Test
;
42 import org
.openoffice
.test
.OfficeConnection
;
43 import util
.AccessibilityTools
;
44 import util
.DesktopTools
;
45 import util
.SOfficeFactory
;
46 import static org
.junit
.Assert
.*;
50 public class CheckIndeterminateState
{
52 * Test the indeterminate state of AccessibleToolBarItem
53 * The used tools are in project qadevOOo/runner
55 @Test public void checkToolBoxItem() throws Exception
{
56 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, document
);
58 XController xController
= aModel
.getCurrentController();
60 XText text
= document
.getText();
61 text
.setString("normal");
62 XTextRange end
= text
.getEnd();
63 end
.setString("bold");
64 UnoRuntime
.queryInterface(XPropertySet
.class, end
).setPropertyValue(
65 "CharWeight", FontWeight
.BOLD
);
66 UnoRuntime
.queryInterface(XTextViewCursorSupplier
.class, xController
).
67 getViewCursor().gotoRange(text
, false);
69 XInterface oObj
= null;
71 XWindow xWindow
= AccessibilityTools
.getCurrentContainerWindow(aModel
);
72 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
74 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
75 AccessibleRole
.TOGGLE_BUTTON
, "Bold");
76 assertNotNull("Found a TOGGLE_BUTTON", oObj
);
78 XAccessibleContext oContext
= UnoRuntime
.queryInterface(XAccessibleContext
.class, oObj
);
80 long oSet
= oContext
.getAccessibleStateSet();
82 assertTrue("The 'INDETERMINATE' state is not set.", (oSet
& AccessibleStateType
.INDETERMINATE
) != 0);
85 @Before public void setUpDocument() throws com
.sun
.star
.uno
.Exception
{
86 document
= SOfficeFactory
.getFactory(getFactory()).createTextDoc(null);
89 @After public void tearDownDocument() {
90 DesktopTools
.closeDoc(document
);
93 private XTextDocument document
= null;
95 @BeforeClass public static void setUpConnection() throws Exception
{
99 @AfterClass public static void tearDownConnection()
100 throws InterruptedException
, com
.sun
.star
.uno
.Exception
102 connection
.tearDown();
105 private static final OfficeConnection connection
= new OfficeConnection();
107 private static final XMultiServiceFactory
getFactory() {
108 return UnoRuntime
.queryInterface(
109 XMultiServiceFactory
.class,
110 connection
.getComponentContext().getServiceManager());