tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / UnoControlPatternField.java
blob72a86437331af9157137d3c7d42a147df12c05c6
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.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.FormTools;
40 import util.SOfficeFactory;
41 import util.WriterTools;
42 import util.utils;
45 public class UnoControlPatternField extends TestCase {
46 private static XTextDocument xTextDoc;
48 @Override
49 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
50 SOfficeFactory SOF = SOfficeFactory.getFactory(
51 Param.getMSF());
53 log.println("creating a textdocument");
54 xTextDoc = SOF.createTextDoc(null);
57 @Override
58 protected void cleanup(TestParameters tParam, PrintWriter log) {
59 log.println(" disposing xTextDoc ");
61 util.DesktopTools.closeDoc(xTextDoc);
64 @Override
65 protected TestEnvironment createTestEnvironment(TestParameters Param,
66 PrintWriter log) throws Exception {
67 XInterface oObj = null;
68 XWindowPeer the_win = null;
69 XToolkit the_kit = null;
70 XDevice aDevice = null;
71 XGraphics aGraphic = null;
72 XControl aControl = null;
74 //Insert a ControlShape and get the ControlModel
75 XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000,
76 4500, 15000,
77 10000,
78 "PatternField",
79 "UnoControlPatternField");
81 WriterTools.getDrawPage(xTextDoc).add(aShape);
83 XControlModel the_Model = aShape.getControl();
85 XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000,
86 4500, 5000, 10000,
87 "TextField");
89 WriterTools.getDrawPage(xTextDoc).add(aShape2);
91 XControlModel the_Model2 = aShape2.getControl();
93 //Try to query XControlAccess
94 XControlAccess the_access = UnoRuntime.queryInterface(
95 XControlAccess.class,
96 xTextDoc.getCurrentController());
98 //get the PatternFieldControl for the needed Object relations
99 oObj = the_access.getControl(the_Model);
100 aControl = the_access.getControl(the_Model2);
101 the_win = the_access.getControl(the_Model).getPeer();
102 the_kit = the_win.getToolkit();
103 aDevice = the_kit.createScreenCompatibleDevice(200, 200);
104 aGraphic = aDevice.createGraphics();
106 log.println(
107 "creating a new environment for UnoControlPatternField object");
109 TestEnvironment tEnv = new TestEnvironment(oObj);
112 //Adding ObjRelation for XView
113 tEnv.addObjRelation("GRAPHICS", aGraphic);
116 //Adding ObjRelation for XControl
117 tEnv.addObjRelation("CONTEXT", xTextDoc);
118 tEnv.addObjRelation("WINPEER", the_win);
119 tEnv.addObjRelation("TOOLKIT", the_kit);
120 tEnv.addObjRelation("MODEL", the_Model);
122 XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class,
123 aControl);
125 tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel);
126 tEnv.addObjRelation("XWindow.ControlShape", aShape);
128 // Adding relation for XTextListener
129 ifc.awt._XTextListener.TestTextListener listener =
130 new ifc.awt._XTextListener.TestTextListener();
131 XTextComponent textComp = UnoRuntime.queryInterface(
132 XTextComponent.class, oObj);
133 textComp.addTextListener(listener);
134 tEnv.addObjRelation("TestTextListener", listener);
136 log.println("ImplementationName: " + utils.getImplName(oObj));
138 return tEnv;
139 } // finish method getTestEnvironment
140 } // finish class UnoControlPatternField