bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / MutableTreeDataModel.java
blob778970733c52b5b8c790424fe1104c1efa85dfbf
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.tree.XMutableTreeDataModel;
21 import com.sun.star.awt.tree.XMutableTreeNode;
22 import com.sun.star.lang.XMultiServiceFactory;
23 import com.sun.star.text.XTextDocument;
24 import com.sun.star.uno.UnoRuntime;
25 import com.sun.star.uno.XInterface;
27 import java.io.PrintWriter;
29 import lib.TestCase;
30 import lib.TestEnvironment;
31 import lib.TestParameters;
33 import util.WriterTools;
34 import util.utils;
37 public class MutableTreeDataModel extends TestCase {
38 private static XTextDocument xTextDoc;
39 private static XInterface oObj = null;
41 /**
42 * Creates StarOffice Writer document.
44 protected void initialize(TestParameters tParam, PrintWriter log) {
45 log.println("creating a textdocument");
46 xTextDoc = WriterTools.createTextDoc(
47 (XMultiServiceFactory) tParam.getMSF());
50 /**
51 * Disposes StarOffice Writer document.
53 protected void cleanup(TestParameters tParam, PrintWriter log) {
54 log.println(" disposing xTextDoc ");
56 util.DesktopTools.closeDoc(xTextDoc);
59 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param,
60 PrintWriter log) {
62 try {
63 oObj = (XInterface) ((XMultiServiceFactory) Param.getMSF()).createInstance(
64 "com.sun.star.awt.tree.MutableTreeDataModel");
65 } catch (Exception e) {
68 log.println(
69 "creating a new environment for MutableTreeDataModel object");
71 TestEnvironment tEnv = new TestEnvironment(oObj);
73 tEnv.addObjRelation("OBJNAME", "toolkit.MutableTreeDataModel");
74 log.println("ImplementationName: " + utils.getImplName(oObj));
76 tEnv.addObjRelation("XTreeDataModelListenerEvent", new XTreeDataModelListenerEvent());
78 return tEnv;
79 } // finish method getTestEnvironment
81 public class XTreeDataModelListenerEvent implements ifc.awt.tree._XTreeDataModel.XTreeDataModelListenerEvent{
83 public void fireEvent(){
85 XMutableTreeDataModel xModel = UnoRuntime.queryInterface(XMutableTreeDataModel.class, oObj);
86 XMutableTreeNode node = xModel.createNode("EventNode", true);
87 try {
88 xModel.setRoot(node);
89 } catch (com.sun.star.lang.IllegalArgumentException ex) {
90 log.println("ERROR: could not preform event: " + ex.toString());
91 ex.printStackTrace();
96 } // finish class UnoControlListBoxModel