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
.accessibility
.XAccessibleStateSet
;
26 import com
.sun
.star
.awt
.FontWeight
;
27 import com
.sun
.star
.awt
.XWindow
;
28 import com
.sun
.star
.beans
.XPropertySet
;
29 import com
.sun
.star
.frame
.XController
;
30 import com
.sun
.star
.frame
.XModel
;
31 import com
.sun
.star
.lang
.XMultiServiceFactory
;
32 import com
.sun
.star
.text
.XText
;
33 import com
.sun
.star
.text
.XTextDocument
;
34 import com
.sun
.star
.text
.XTextRange
;
35 import com
.sun
.star
.text
.XTextViewCursorSupplier
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
37 import com
.sun
.star
.uno
.XInterface
;
38 import org
.junit
.After
;
39 import org
.junit
.AfterClass
;
40 import org
.junit
.Before
;
41 import org
.junit
.BeforeClass
;
42 import org
.junit
.Test
;
43 import org
.openoffice
.test
.OfficeConnection
;
44 import util
.AccessibilityTools
;
45 import util
.DesktopTools
;
46 import util
.SOfficeFactory
;
47 import static org
.junit
.Assert
.*;
51 public class CheckIndeterminateState
{
53 * Test the indeterminate state of AccessibleToolBarItem
54 * The used tools are in project qadevOOo/runner
56 @Test public void checkToolBoxItem() throws Exception
{
57 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, document
);
59 XController xController
= aModel
.getCurrentController();
61 XText text
= document
.getText();
62 text
.setString("normal");
63 XTextRange end
= text
.getEnd();
64 end
.setString("bold");
65 UnoRuntime
.queryInterface(XPropertySet
.class, end
).setPropertyValue(
66 "CharWeight", FontWeight
.BOLD
);
67 UnoRuntime
.queryInterface(XTextViewCursorSupplier
.class, xController
).
68 getViewCursor().gotoRange(text
, false);
70 XInterface oObj
= null;
72 XWindow xWindow
= AccessibilityTools
.getCurrentContainerWindow(aModel
);
73 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
75 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
76 AccessibleRole
.TOGGLE_BUTTON
, "Bold");
77 assertNotNull("Found a TOGGLE_BUTTON", oObj
);
79 XAccessibleContext oContext
= UnoRuntime
.queryInterface(XAccessibleContext
.class, oObj
);
81 XAccessibleStateSet oSet
= oContext
.getAccessibleStateSet();
83 assertTrue("The 'INDETERMINATE' state is not set.",oSet
.contains(AccessibleStateType
.INDETERMINATE
));
86 @Before public void setUpDocument() throws com
.sun
.star
.uno
.Exception
{
87 document
= SOfficeFactory
.getFactory(getFactory()).createTextDoc(null);
90 @After public void tearDownDocument() {
91 DesktopTools
.closeDoc(document
);
94 private XTextDocument document
= null;
96 @BeforeClass public static void setUpConnection() throws Exception
{
100 @AfterClass public static void tearDownConnection()
101 throws InterruptedException
, com
.sun
.star
.uno
.Exception
103 connection
.tearDown();
106 private static final OfficeConnection connection
= new OfficeConnection();
108 private static final XMultiServiceFactory
getFactory() {
109 return UnoRuntime
.queryInterface(
110 XMultiServiceFactory
.class,
111 connection
.getComponentContext().getServiceManager());