bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / UnoControlCurrencyField.java
blob7c511d75019e7e8e587749c3bd5890c191a8a313
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._toolkit;
20 import com.sun.star.awt.XControl;
21 import com.sun.star.awt.XControlModel;
22 import com.sun.star.awt.XDevice;
23 import com.sun.star.awt.XGraphics;
24 import com.sun.star.awt.XTextComponent;
25 import com.sun.star.awt.XToolkit;
26 import com.sun.star.awt.XWindow;
27 import com.sun.star.awt.XWindowPeer;
28 import com.sun.star.drawing.XControlShape;
29 import com.sun.star.text.XTextDocument;
30 import com.sun.star.uno.UnoRuntime;
31 import com.sun.star.uno.XInterface;
32 import com.sun.star.view.XControlAccess;
34 import java.io.PrintWriter;
36 import lib.StatusException;
37 import lib.TestCase;
38 import lib.TestEnvironment;
39 import lib.TestParameters;
41 import util.FormTools;
42 import util.SOfficeFactory;
43 import util.WriterTools;
44 import util.utils;
47 public class UnoControlCurrencyField extends TestCase {
48 private static XTextDocument xTextDoc;
50 @Override
51 protected void initialize(TestParameters Param, PrintWriter log) {
52 SOfficeFactory SOF = SOfficeFactory.getFactory(
53 Param.getMSF());
55 try {
56 log.println("creating a textdocument");
57 xTextDoc = SOF.createTextDoc(null);
58 } catch (com.sun.star.uno.Exception e) {
59 // Some exception occurs.FAILED
60 e.printStackTrace(log);
61 throw new StatusException("Couldn't create document", e);
65 @Override
66 protected void cleanup(TestParameters tParam, PrintWriter log) {
67 log.println(" disposing xTextDoc ");
69 util.DesktopTools.closeDoc(xTextDoc);
72 @Override
73 protected TestEnvironment createTestEnvironment(TestParameters Param,
74 PrintWriter log) {
75 XInterface oObj = null;
76 XWindowPeer the_win = null;
77 XToolkit the_kit = null;
78 XDevice aDevice = null;
79 XGraphics aGraphic = null;
80 XControl aControl = null;
82 //Insert a ControlShape and get the ControlModel
83 XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000,
84 4500, 15000,
85 10000,
86 "CurrencyField",
87 "UnoControlCurrencyField");
89 WriterTools.getDrawPage(xTextDoc).add(aShape);
91 XControlModel the_Model = aShape.getControl();
93 XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000,
94 4500, 5000, 10000,
95 "TextField");
97 WriterTools.getDrawPage(xTextDoc).add(aShape2);
99 XControlModel the_Model2 = aShape2.getControl();
101 //Try to query XControlAccess
102 XControlAccess the_access = UnoRuntime.queryInterface(
103 XControlAccess.class,
104 xTextDoc.getCurrentController());
106 //get the CurrencyFieldControl for the needed Object relations
107 try {
108 oObj = the_access.getControl(the_Model);
109 aControl = the_access.getControl(the_Model2);
110 the_win = the_access.getControl(the_Model).getPeer();
111 the_kit = the_win.getToolkit();
112 aDevice = the_kit.createScreenCompatibleDevice(200, 200);
113 aGraphic = aDevice.createGraphics();
114 } catch (Exception e) {
115 log.println("Couldn't get CurrencyFieldControl");
116 e.printStackTrace(log);
117 throw new StatusException("Couldn't get CurrencyFieldControl", e);
120 log.println(
121 "creating a new environment for UnoControlCurrencyField object");
123 TestEnvironment tEnv = new TestEnvironment(oObj);
126 //Adding ObjRelation for XView
127 tEnv.addObjRelation("GRAPHICS", aGraphic);
130 //Adding ObjRelation for XControl
131 tEnv.addObjRelation("CONTEXT", xTextDoc);
132 tEnv.addObjRelation("WINPEER", the_win);
133 tEnv.addObjRelation("TOOLKIT", the_kit);
134 tEnv.addObjRelation("MODEL", the_Model);
136 XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class,
137 aControl);
139 tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel);
140 tEnv.addObjRelation("XWindow.ControlShape", aShape);
142 // Adding relation for XTextListener
143 ifc.awt._XTextListener.TestTextListener listener =
144 new ifc.awt._XTextListener.TestTextListener();
145 XTextComponent textComp = UnoRuntime.queryInterface(
146 XTextComponent.class, oObj);
147 textComp.addTextListener(listener);
148 tEnv.addObjRelation("TestTextListener", listener);
150 log.println("ImplementationName: " + utils.getImplName(oObj));
152 return tEnv;
153 } // finish method getTestEnvironment
154 } // finish class UnoControlCurrencyField