merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _fwk / ObjectMenuController.java
blob65f6bbc88bf0ce33a611a8b80643adb47fabb500
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ObjectMenuController.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._fwk;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.uno.UnoRuntime;
35 import com.sun.star.uno.XInterface;
36 import java.io.PrintWriter;
37 import com.sun.star.text.XTextDocument;
38 import com.sun.star.util.XCloseable;
39 import lib.StatusException;
40 import lib.TestCase;
41 import lib.TestEnvironment;
42 import lib.TestParameters;
43 import util.utils;
45 /**
47 public class ObjectMenuController extends TestCase {
48 XInterface oObj = null;
49 XTextDocument xTextDoc;
51 /**
52 * Cleanup: close the created document
53 * @param tParam The test parameters.
54 * @param The log writer.
55 * @return The test environment.
57 protected void cleanup(TestParameters tParam, PrintWriter log) {
58 log.println(" disposing xTextDoc ");
60 try {
61 XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
62 XCloseable.class, xTextDoc);
63 closer.close(true);
64 } catch (com.sun.star.util.CloseVetoException e) {
65 log.println("couldn't close document");
66 } catch (com.sun.star.lang.DisposedException e) {
67 log.println("couldn't close document");
71 /**
72 * Create test environment:
73 * <ul>
74 * <li>create a text doc</li>
75 * <li>get the model from the text doc</li>
76 * <li>query model for XUIConfigurationManagerSupplier interface</li>
77 * <li>get the manager from the supplier</li>
78 * </ul>
79 * @param tParam The test parameters.
80 * @param The log writer.
81 * @return The test environment.
83 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
84 TestEnvironment tEnv = null;
85 XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF();
87 try {
88 oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.ObjectMenuController");
90 catch(com.sun.star.uno.Exception e) {
91 e.printStackTrace(log);
92 throw new StatusException("Could not create object 'ControlMenuController'", e);
94 log.println("TestObject: " + utils.getImplName(oObj));
95 tEnv = new TestEnvironment(oObj);
96 return tEnv;