xref: /AOO41X/main/qadevOOo/tests/java/mod/_forms/OSpinButtonModel.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package mod._forms;
29 
30 import com.sun.star.beans.PropertyValue;
31 import com.sun.star.drawing.XControlShape;
32 import com.sun.star.drawing.XShape;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.text.XTextDocument;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XInterface;
37 import com.sun.star.util.XCloseable;
38 import java.io.PrintWriter;
39 import lib.TestCase;
40 import lib.TestEnvironment;
41 import lib.TestParameters;
42 import util.FormTools;
43 import util.WriterTools;
44 
45 public class OSpinButtonModel extends TestCase {
46 
47     XTextDocument xTextDoc;
48 
49     /**
50      * Creates a Writer document.
51      */
52     protected void initialize( TestParameters tParam, PrintWriter log ) {
53 
54         log.println( "creating a textdocument" );
55         xTextDoc = WriterTools.createTextDoc(((XMultiServiceFactory) tParam.getMSF()));
56     }
57 
58     /**
59      * Disposes the Writer document.
60      */
61     protected void cleanup(TestParameters tParam, PrintWriter log) {
62         log.println("    disposing xTextDoc ");
63 
64         try {
65             XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
66                 XCloseable.class, xTextDoc);
67             closer.close(true);
68         } catch (com.sun.star.util.CloseVetoException e) {
69             log.println("couldn't close document");
70         } catch (com.sun.star.lang.DisposedException e) {
71             log.println("couldn't close document");
72         }
73     }
74 
75 
76     /**
77      * Creating a Testenvironment for the interfaces to be tested.
78      * Adds spin button into text and retrieves it's control model.
79      */
80     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
81 
82         XInterface oObj = null;
83 
84         XControlShape aShape = FormTools.createControlShape(
85             xTextDoc,3000,4500,15000,10000,"SpinButton");
86 
87         WriterTools.getDrawPage(xTextDoc).add((XShape) aShape);
88         oObj = aShape.getControl();
89         log.println( "creating a new environment for OButtonModel object" );
90         TestEnvironment tEnv = new TestEnvironment( oObj );
91         tEnv.addObjRelation("OBJNAME", "com.sun.star.form.component.SpinButton");
92         PropertyValue prop = new PropertyValue();
93         prop.Name = "HelpText";
94         prop.Value = "new Help Text since XPropertyAccess";
95         tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop);
96         tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText");
97 
98         System.out.println("Implementation name: "+util.utils.getImplName(oObj));
99         return tEnv;
100     } // finish method getTestEnvironment
101 
102 }
103