Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / UnoScrollBarControl.java
blob3a6b27474e1183b7f9d38dc95469fe57dc00765d
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.Rectangle;
21 import com.sun.star.awt.XControl;
22 import com.sun.star.awt.XControlModel;
23 import com.sun.star.awt.XDevice;
24 import com.sun.star.awt.XGraphics;
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.frame.XFrame;
30 import com.sun.star.frame.XModel;
31 import com.sun.star.text.XTextDocument;
32 import com.sun.star.uno.UnoRuntime;
33 import com.sun.star.uno.XInterface;
34 import com.sun.star.view.XControlAccess;
36 import java.awt.Dimension;
37 import java.awt.Toolkit;
38 import java.io.PrintWriter;
40 import lib.TestCase;
41 import lib.TestEnvironment;
42 import lib.TestParameters;
43 import util.FormTools;
44 import util.SOfficeFactory;
45 import util.WriterTools;
46 import util.utils;
49 public class UnoScrollBarControl extends TestCase {
50 private static XTextDocument xTextDoc;
52 @Override
53 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
54 SOfficeFactory SOF = SOfficeFactory.getFactory(
55 Param.getMSF());
57 log.println("creating a textdocument");
58 xTextDoc = SOF.createTextDoc(null);
60 log.println("maximize the window size");
61 XModel xModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
62 XFrame xFrame = xModel.getCurrentController().getFrame();
63 XWindow xWin = xFrame.getContainerWindow();
65 Toolkit.getDefaultToolkit();
66 Dimension dim = new Dimension(800, 600);
68 Rectangle newPosSize = xWin.getPosSize();
69 newPosSize.Width = (int) dim.getWidth();
70 newPosSize.Height = (int) dim.getHeight();
71 newPosSize.X = 0;
72 newPosSize.Y = 0;
74 xWin.setPosSize(newPosSize.X, newPosSize.Y, newPosSize.Width,
75 newPosSize.Height, com.sun.star.awt.PosSize.POSSIZE);
78 @Override
79 protected void cleanup(TestParameters tParam, PrintWriter log) {
80 log.println(" disposing xTextDoc ");
82 util.DesktopTools.closeDoc(xTextDoc);
85 @Override
86 protected TestEnvironment createTestEnvironment(TestParameters Param,
87 PrintWriter log) throws Exception {
88 XInterface oObj = null;
89 XWindowPeer the_win = null;
90 XToolkit the_kit = null;
91 XDevice aDevice = null;
92 XGraphics aGraphic = null;
93 XControl aControl = null;
95 //Insert a ControlShape and get the ControlModel
96 XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000,
97 4500, 15000,
98 10000,
99 "ScrollBar",
100 "UnoControlScrollBar");
102 WriterTools.getDrawPage(xTextDoc).add(aShape);
104 XControlModel the_Model = aShape.getControl();
106 XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000,
107 4500, 5000, 10000,
108 "TextField");
110 WriterTools.getDrawPage(xTextDoc).add(aShape2);
112 XControlModel the_Model2 = aShape2.getControl();
114 //Try to query XControlAccess
115 XControlAccess the_access = UnoRuntime.queryInterface(
116 XControlAccess.class,
117 xTextDoc.getCurrentController());
119 //get the ScrollBarControl for the needed Object relations
120 oObj = the_access.getControl(the_Model);
121 aControl = the_access.getControl(the_Model2);
122 the_win = the_access.getControl(the_Model).getPeer();
123 the_kit = the_win.getToolkit();
124 aDevice = the_kit.createScreenCompatibleDevice(200, 200);
125 aGraphic = aDevice.createGraphics();
127 log.println(
128 "creating a new environment for UnoControlScrollBar object");
130 TestEnvironment tEnv = new TestEnvironment(oObj);
133 //adding Object-Relation for XScrollBar
134 tEnv.addObjRelation("Document", xTextDoc);
137 //Adding ObjRelation for XView
138 tEnv.addObjRelation("GRAPHICS", aGraphic);
141 //Adding ObjRelation for XControl
142 tEnv.addObjRelation("CONTEXT", xTextDoc);
143 tEnv.addObjRelation("WINPEER", the_win);
144 tEnv.addObjRelation("TOOLKIT", the_kit);
145 tEnv.addObjRelation("MODEL", the_Model);
147 XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class,
148 aControl);
150 tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel);
152 System.out.println("ImplementationName: " + utils.getImplName(oObj));
154 return tEnv;
155 } // finish method getTestEnvironment