tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / UnoControlComboBox.java
blob243e90c26897ce77d2f8d1aae10f363ab3c54827
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 java.io.PrintWriter;
22 import lib.TestCase;
23 import lib.TestEnvironment;
24 import lib.TestParameters;
25 import util.FormTools;
26 import util.SOfficeFactory;
27 import util.WriterTools;
28 import util.utils;
30 import com.sun.star.awt.XControl;
31 import com.sun.star.awt.XControlModel;
32 import com.sun.star.awt.XDevice;
33 import com.sun.star.awt.XGraphics;
34 import com.sun.star.awt.XTextComponent;
35 import com.sun.star.awt.XToolkit;
36 import com.sun.star.awt.XWindow;
37 import com.sun.star.awt.XWindowPeer;
38 import com.sun.star.drawing.XControlShape;
39 import com.sun.star.text.XTextDocument;
40 import com.sun.star.uno.UnoRuntime;
41 import com.sun.star.uno.XInterface;
42 import com.sun.star.view.XControlAccess;
45 public class UnoControlComboBox extends TestCase {
46 private static XTextDocument xTextDoc;
48 @Override
49 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
50 SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF());
52 log.println("creating a textdocument");
53 xTextDoc = SOF.createTextDoc(null);
56 @Override
57 protected void cleanup(TestParameters tParam, PrintWriter log) {
58 log.println(" disposing xTextDoc ");
60 util.DesktopTools.closeDoc(xTextDoc);
63 @Override
64 protected TestEnvironment createTestEnvironment(TestParameters Param,
65 PrintWriter log) throws Exception {
66 XInterface oObj = null;
67 XWindowPeer the_win = null;
68 XToolkit the_kit = null;
69 XDevice aDevice = null;
70 XGraphics aGraphic = null;
71 XControl aControl = null;
73 //Insert a ControlShape and get the ControlModel
74 XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000,
75 4500, 15000,
76 10000,
77 "ComboBox",
78 "UnoControlComboBox");
80 WriterTools.getDrawPage(xTextDoc).add(aShape);
82 XControlModel the_Model = aShape.getControl();
84 XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000,
85 4500, 5000, 10000,
86 "TextField");
88 WriterTools.getDrawPage(xTextDoc).add(aShape2);
90 XControlModel the_Model2 = aShape2.getControl();
92 //Try to query XControlAccess
93 XControlAccess the_access = UnoRuntime.queryInterface(
94 XControlAccess.class,
95 xTextDoc.getCurrentController());
97 //get the ComboBoxControl for the needed Object relations
98 oObj = the_access.getControl(the_Model);
99 aControl = the_access.getControl(the_Model2);
100 the_win = the_access.getControl(the_Model).getPeer();
101 the_kit = the_win.getToolkit();
102 aDevice = the_kit.createScreenCompatibleDevice(200, 200);
103 aGraphic = aDevice.createGraphics();
105 log.println("creating a new environment for UnoControlComboBox object");
107 TestEnvironment tEnv = new TestEnvironment(oObj);
110 //Adding ObjRelation for XView
111 tEnv.addObjRelation("GRAPHICS", aGraphic);
114 //Adding ObjRelation for XControl
115 tEnv.addObjRelation("CONTEXT", xTextDoc);
116 tEnv.addObjRelation("WINPEER", the_win);
117 tEnv.addObjRelation("TOOLKIT", the_kit);
118 tEnv.addObjRelation("MODEL", the_Model);
120 XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class,
121 aControl);
123 tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel);
124 tEnv.addObjRelation("XWindow.ControlShape", aShape);
126 // Adding relation for XTextListener
127 ifc.awt._XTextListener.TestTextListener listener =
128 new ifc.awt._XTextListener.TestTextListener();
129 XTextComponent textComp = UnoRuntime.queryInterface(
130 XTextComponent.class, oObj);
131 textComp.addTextListener(listener);
132 tEnv.addObjRelation("TestTextListener", listener);
134 log.println("ImplementationName: " + utils.getImplName(oObj));
136 return tEnv;
137 } // finish method getTestEnvironment
138 } // finish class UnoControlComboBox