bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / TabController.java
blob49523a7a8e1727cf46ea7e838a1b4e696d992cee
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.XControlContainer;
22 import com.sun.star.awt.XControlModel;
23 import com.sun.star.awt.XTabControllerModel;
24 import com.sun.star.drawing.XControlShape;
25 import com.sun.star.form.XForm;
26 import com.sun.star.text.XTextDocument;
27 import com.sun.star.uno.AnyConverter;
28 import com.sun.star.uno.Type;
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.WriterTools;
42 import util.utils;
45 public class TabController extends TestCase {
46 private static XTextDocument xTextDoc = null;
48 @Override
49 protected void initialize(TestParameters param, PrintWriter log) {
50 try {
51 log.println("creating a textdocument");
52 xTextDoc = WriterTools.createTextDoc(
53 param.getMSF());
54 } catch (Exception e) {
55 // Some exception occurs.FAILED
56 e.printStackTrace(log);
57 throw new StatusException("Couldn't create document", e);
61 @Override
62 protected void cleanup(TestParameters param, PrintWriter log) {
63 log.println("disposing xTextDoc");
64 util.DesktopTools.closeDoc(xTextDoc);
67 @Override
68 public TestEnvironment createTestEnvironment(TestParameters param,
69 PrintWriter log) {
70 XInterface oObj = null;
71 XControl xCtrl1 = null;
72 XTabControllerModel tabCtrlModel = null;
73 XControlContainer aCtrlContainer = null;
76 // create object relations
77 FormTools.insertForm(xTextDoc,
78 FormTools.getForms(WriterTools.getDrawPage(
79 xTextDoc)), "MyForm");
81 XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000,
82 4500, 15000,
83 10000,
84 "CommandButton",
85 "UnoControlButton");
86 WriterTools.getDrawPage(xTextDoc).add(aShape);
88 XControlModel model = aShape.getControl();
89 XControlAccess access = UnoRuntime.queryInterface(
90 XControlAccess.class,
91 xTextDoc.getCurrentController());
93 try {
94 xCtrl1 = access.getControl(model);
95 } catch (Exception e) {
98 XForm form = null;
100 try {
101 form = (XForm) AnyConverter.toObject(new Type(XForm.class),
102 (FormTools.getForms(
103 WriterTools.getDrawPage(
104 xTextDoc)))
105 .getByName("MyForm"));
106 } catch (Exception e) {
107 log.println("Couldn't get Form");
108 e.printStackTrace(log);
111 tabCtrlModel = UnoRuntime.queryInterface(
112 XTabControllerModel.class, form);
114 aCtrlContainer = UnoRuntime.queryInterface(
115 XControlContainer.class, xCtrl1.getContext());
117 // create object
118 try {
119 oObj = (XInterface) param.getMSF().createInstance(
120 "com.sun.star.awt.TabController");
121 } catch (Exception e) {
124 TestEnvironment tEnv = new TestEnvironment(oObj);
126 String objName = "TabController";
127 tEnv.addObjRelation("OBJNAME", "toolkit." + objName);
128 tEnv.addObjRelation("MODEL", tabCtrlModel);
129 tEnv.addObjRelation("CONTAINER", aCtrlContainer);
130 System.out.println("ImplementationName: " + utils.getImplName(oObj));
132 return tEnv;