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 .
21 import com
.sun
.star
.awt
.tree
.TreeDataModelEvent
;
22 import com
.sun
.star
.awt
.tree
.XTreeDataModel
;
23 import com
.sun
.star
.awt
.tree
.XTreeDataModelListener
;
24 import com
.sun
.star
.lang
.EventObject
;
25 import lib
.MultiMethodTest
;
27 import lib
.StatusException
;
30 * Testing <code>com.sun.star.awt.tree.XTreeDataModel</code>
33 * <li><code> createNode()</code></li>
34 * <li><code> setRoot()</code></li>
36 * Test is <b> NOT </b> multithread compliant. <p>
38 * @see com.sun.star.awt.tree.XTreeDataModel
40 public class _XTreeDataModel
extends MultiMethodTest
{
42 public XTreeDataModel oObj
= null;
44 XTreeDataModelListener mListener1
= new myEventListener1();
46 XTreeDataModelListener mListener2
= new myEventListener2();
48 XTreeDataModelListenerEvent mListenerEvent
= null;
50 boolean mTreeStructureChanged1
= false;
52 boolean mTreeStructureChanged2
= false;
54 public interface XTreeDataModelListenerEvent
{
58 public class myEventListener1
implements XTreeDataModelListener
{
59 public void treeNodesChanged(TreeDataModelEvent treeDataModelEvent
) {
60 log
.println("Listener 1: treeNodesChanged");
63 public void treeNodesInserted(TreeDataModelEvent treeDataModelEvent
) {
64 log
.println("Listener 1: treeNodesInserted");
67 public void treeNodesRemoved(TreeDataModelEvent treeDataModelEvent
) {
68 log
.println("Listener 1: treeNodesRemoved");
71 public void treeStructureChanged(TreeDataModelEvent treeDataModelEvent
) {
72 log
.println("Listener 1: treeStructureChanged");
73 mTreeStructureChanged1
= true;
76 public void disposing(EventObject eventObject
) {
77 log
.println("Listener 1: disposing");
81 public class myEventListener2
implements XTreeDataModelListener
{
82 public void treeNodesChanged(TreeDataModelEvent treeDataModelEvent
) {
83 log
.println("Listener 2: treeNodesChanged");
86 public void treeNodesInserted(TreeDataModelEvent treeDataModelEvent
) {
87 log
.println("Listener 2: treeNodesInserted");
90 public void treeNodesRemoved(TreeDataModelEvent treeDataModelEvent
) {
91 log
.println("Listener 2: treeNodesRemoved");
94 public void treeStructureChanged(TreeDataModelEvent treeDataModelEvent
) {
95 log
.println("Listener 2: treeStructureChanged");
96 mTreeStructureChanged2
= true;
99 public void disposing(EventObject eventObject
) {
100 log
.println("Listener 2: disposing");
106 public void before(){
107 mListenerEvent
= (XTreeDataModelListenerEvent
) tEnv
.getObjRelation("XTreeDataModelListenerEvent");
108 if (mListenerEvent
== null) {
109 throw new StatusException(Status
.failed("ERROR: could not get object relation 'XTreeDataModelListenerEvent'\n" +
110 "This object relation must be kind of 'ifc.awt.tree._XTreeDataModel.XTreeDataModelListenerEvent'"));
115 * Gets the title and compares it to the value set in
116 * <code>setTitle</code> method test. <p>
117 * Has <b>OK</b> status is set/get values are equal.
118 * The following method tests are to be completed successfully before :
120 * <li> <code> setTitle </code> </li>
123 public void _getRoot() {
128 tRes
.tested("getRoot()", bOK
);
132 public void _addTreeDataModelListener(){
136 log
.println("add listener 1 to object...");
137 oObj
.addTreeDataModelListener(mListener1
);
139 log
.println("add listener 2 to object...");
140 oObj
.addTreeDataModelListener(mListener2
);
142 mTreeStructureChanged1
= false;
143 mTreeStructureChanged2
= false;
145 mListenerEvent
.fireEvent();
147 bOK
= mTreeStructureChanged1
& mTreeStructureChanged2
;
149 tRes
.tested("addTreeDataModelListener()", bOK
);
152 public void _removeTreeDataModelListener(){
156 log
.println("remove listener 2 from object...");
157 oObj
.removeTreeDataModelListener(mListener2
);
159 mTreeStructureChanged1
= false;
160 mTreeStructureChanged2
= false;
162 mListenerEvent
.fireEvent();
164 bOK
= mTreeStructureChanged1
& ! mTreeStructureChanged2
;
166 tRes
.tested("removeTreeDataModelListener()", bOK
);