bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sch / AccDataSeries.java
blob57d8cbbf34660eea8aa6a4c30a5d099b48159d56
1 /*
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 .
18 package mod._sch;
20 import java.io.PrintWriter;
22 import lib.StatusException;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.AccessibilityTools;
27 import util.SOfficeFactory;
28 import util.utils;
30 import com.sun.star.accessibility.AccessibleRole;
31 import com.sun.star.accessibility.XAccessible;
32 import com.sun.star.accessibility.XAccessibleComponent;
33 import com.sun.star.accessibility.XAccessibleContext;
34 import com.sun.star.awt.XWindow;
35 import com.sun.star.chart.XChartDocument;
36 import com.sun.star.frame.XModel;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
40 public class AccDataSeries extends TestCase {
42 XChartDocument xChartDoc = null;
44 @Override
45 protected TestEnvironment createTestEnvironment(
46 TestParameters Param, PrintWriter log) {
48 if (xChartDoc != null) cleanup(Param, log);
49 log.println( "creating a chart document" );
50 SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF());
51 try {
52 log.println( "creating a chartdocument" );
53 xChartDoc = SOF.createChartDoc();
54 } catch (com.sun.star.uno.Exception e) {
55 // Some exception occurs.FAILED
56 e.printStackTrace( log );
57 throw new StatusException( "Couldn't create document", e );
60 XInterface oObj = null;
62 XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc);
64 XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel);
65 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
67 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
69 XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole(
70 xRoot, AccessibleRole.SHAPE, "", "AccDataSeries");
72 oObj = cont;
74 log.println("ImplementationName " + utils.getImplName(oObj));
75 log.println("AccessibleName " + cont.getAccessibleName());
77 TestEnvironment tEnv = new TestEnvironment(oObj);
79 final XAccessibleComponent acc = UnoRuntime.queryInterface(
80 XAccessibleComponent.class,oObj);
81 tEnv.addObjRelation("EventProducer",
82 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
83 public void fireEvent() {
84 acc.grabFocus();
86 });
88 return tEnv;
92 /**
93 * Called while disposing a <code>TestEnvironment</code>.
94 * Disposes text document.
95 * @param Param test parameters
96 * @param log writer to log information while testing
98 @Override
99 protected void cleanup( TestParameters Param, PrintWriter log) {
100 if( xChartDoc!=null ) {
101 log.println( " closing xChartDoc" );
102 util.DesktopTools.closeDoc(xChartDoc);
103 xChartDoc = null;