tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / Toolkit.java
blob346ef21f524cf387599a88d0d337fad79321e82a
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.XControlModel;
21 import com.sun.star.awt.XWindow;
22 import com.sun.star.awt.XWindowPeer;
23 import com.sun.star.drawing.XControlShape;
24 import com.sun.star.frame.XController;
25 import com.sun.star.frame.XModel;
26 import com.sun.star.text.XTextDocument;
27 import com.sun.star.uno.UnoRuntime;
28 import com.sun.star.uno.XInterface;
29 import com.sun.star.view.XControlAccess;
31 import java.io.PrintWriter;
33 import lib.TestCase;
34 import lib.TestEnvironment;
35 import lib.TestParameters;
37 import util.FormTools;
38 import util.SOfficeFactory;
39 import util.WriterTools;
40 import util.utils;
43 /**
44 * Test for <code>com.sun.star.awt.Toolkit</code> service.
46 public class Toolkit extends TestCase {
47 private static XTextDocument xTextDoc;
49 @Override
50 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
51 SOfficeFactory SOF = SOfficeFactory.getFactory(
52 Param.getMSF());
54 log.println("creating a textdocument");
55 xTextDoc = SOF.createTextDoc(null);
58 @Override
59 protected void cleanup(TestParameters tParam, PrintWriter log) {
60 log.println(" disposing xTextDoc ");
61 util.DesktopTools.closeDoc(xTextDoc);
64 /**
65 * Creating a TestEnvironment for the interfaces to be tested.
66 * Creates <code>com.sun.star.awt.Toolkit</code> service.
68 @Override
69 public TestEnvironment createTestEnvironment(TestParameters Param,
70 PrintWriter log)
71 throws Exception {
72 XInterface oObj = null;
73 XWindowPeer the_win = null;
74 XWindow win = null;
76 //Insert a ControlShape and get the ControlModel
77 XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000,
78 4500, 15000, 10000,
79 "CommandButton");
81 WriterTools.getDrawPage(xTextDoc).add(aShape);
83 XControlModel the_Model = aShape.getControl();
85 //Try to query XControlAccess
86 XControlAccess the_access = UnoRuntime.queryInterface(
87 XControlAccess.class,
88 xTextDoc.getCurrentController());
89 XController cntrlr = UnoRuntime.queryInterface(
90 XController.class,
91 xTextDoc.getCurrentController());
93 //now get the toolkit
94 win = cntrlr.getFrame().getContainerWindow();
96 the_win = the_access.getControl(the_Model).getPeer();
97 oObj = (XInterface) Param.getMSF().createInstance(
98 "com.sun.star.awt.Toolkit");
100 XModel xModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
102 log.println(" creating a new environment for toolkit object");
104 TestEnvironment tEnv = new TestEnvironment(oObj);
106 log.println("Implementation Name: " + utils.getImplName(oObj));
108 tEnv.addObjRelation("WINPEER", the_win);
110 tEnv.addObjRelation("XModel", xModel);
113 // adding relation for XDataTransferProviderAccess
114 tEnv.addObjRelation("XDataTransferProviderAccess.XWindow", win);
116 return tEnv;
117 } // finish method getTestEnvironment
118 } // finish class Toolkit