bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / UnoControlRadioButton.java
blob0d232ab48fbf7ffec1ffaf694649c1e0992ef016
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.XToolkit;
25 import com.sun.star.awt.XWindow;
26 import com.sun.star.awt.XWindowPeer;
27 import com.sun.star.drawing.XControlShape;
28 import com.sun.star.text.XTextDocument;
29 import com.sun.star.uno.UnoRuntime;
30 import com.sun.star.uno.XInterface;
31 import com.sun.star.view.XControlAccess;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
40 import util.FormTools;
41 import util.SOfficeFactory;
42 import util.WriterTools;
43 import util.utils;
46 public class UnoControlRadioButton extends TestCase {
47 private static XTextDocument xTextDoc;
49 @Override
50 protected void initialize(TestParameters Param, PrintWriter log) {
51 SOfficeFactory SOF = SOfficeFactory.getFactory(
52 Param.getMSF());
54 try {
55 log.println("creating a textdocument");
56 xTextDoc = SOF.createTextDoc(null);
57 } catch (com.sun.star.uno.Exception e) {
58 // Some exception occurs.FAILED
59 e.printStackTrace(log);
60 throw new StatusException("Couldn't create document", e);
64 @Override
65 protected void cleanup(TestParameters tParam, PrintWriter log) {
66 log.println(" disposing xTextDoc ");
68 util.DesktopTools.closeDoc(xTextDoc);
71 @Override
72 protected TestEnvironment createTestEnvironment(TestParameters Param,
73 PrintWriter log) {
74 XInterface oObj = null;
75 XWindowPeer the_win = null;
76 XToolkit the_kit = null;
77 XDevice aDevice = null;
78 XGraphics aGraphic = null;
79 XControl aControl = null;
81 //Insert a ControlShape and get the ControlModel
82 XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000,
83 4500, 15000,
84 10000,
85 "RadioButton",
86 "UnoControlRadioButton");
88 WriterTools.getDrawPage(xTextDoc).add(aShape);
90 XControlModel the_Model = aShape.getControl();
92 XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000,
93 4500, 5000, 10000,
94 "TextField");
96 WriterTools.getDrawPage(xTextDoc).add(aShape2);
98 XControlModel the_Model2 = aShape2.getControl();
100 //Try to query XControlAccess
101 XControlAccess the_access = UnoRuntime.queryInterface(
102 XControlAccess.class,
103 xTextDoc.getCurrentController());
105 //get the RadioButtonControl for the needed Object relations
106 try {
107 oObj = the_access.getControl(the_Model);
108 aControl = the_access.getControl(the_Model2);
109 the_win = the_access.getControl(the_Model).getPeer();
110 the_kit = the_win.getToolkit();
111 aDevice = the_kit.createScreenCompatibleDevice(200, 200);
112 aGraphic = aDevice.createGraphics();
113 } catch (Exception e) {
114 log.println("Couldn't get RadioButtonControl");
115 e.printStackTrace(log);
116 throw new StatusException("Couldn't get RadioButtonControl", e);
119 log.println(
120 "creating a new environment for UnoControlRadioButton object");
122 TestEnvironment tEnv = new TestEnvironment(oObj);
125 //Adding ObjRelation for XView
126 tEnv.addObjRelation("GRAPHICS", aGraphic);
129 //Adding ObjRelation for XControl
130 tEnv.addObjRelation("CONTEXT", xTextDoc);
131 tEnv.addObjRelation("WINPEER", the_win);
132 tEnv.addObjRelation("TOOLKIT", the_kit);
133 tEnv.addObjRelation("MODEL", the_Model);
135 XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class,
136 aControl);
138 tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel);
140 System.out.println("ImplementationName: " + utils.getImplName(oObj));
142 return tEnv;
143 } // finish method getTestEnvironment
144 } // finish class UnoControlRadioButton