Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XDialog.java
blob8b9f6aa527b74c629f167d6eeb393a341b993670
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 .
19 package ifc.awt;
21 import lib.MultiMethodTest;
23 import com.sun.star.awt.XDialog;
25 /**
26 * Testing <code>com.sun.star.awt.XDialog</code>
27 * interface methods :
28 * <ul>
29 * <li><code> setTitle()</code></li>
30 * <li><code> getTitle()</code></li>
31 * <li><code> execute()</code></li>
32 * <li><code> endExecute()</code></li>
33 * </ul> <p>
34 * Test is <b> NOT </b> multithread compliant. <p>
35 * After test completion object environment has to be recreated.
36 * @see com.sun.star.awt.XDialog
38 public class _XDialog extends MultiMethodTest {
40 public XDialog oObj = null;
42 /**
43 * As <code>execute()</code> method is a blocking call,
44 * then it must be executed in a separate thread. This
45 * thread class just call <code>execute</code> method
46 * of tested object.
48 protected Thread execThread = new Thread(
49 new Runnable() {
50 public void run() {
51 oObj.execute() ;
53 }) ;
55 /**
56 * Sets the title to some string. <p>
57 * Has <b>OK</b> status if no runtime exceptions occurs.
59 public void _setTitle() {
61 oObj.setTitle("XDialog test") ;
63 tRes.tested("setTitle()", true) ;
66 /**
67 * Gets the title and compares it to the value set in
68 * <code>setTitle</code> method test. <p>
69 * Has <b>OK</b> status is set/get values are equal.
70 * The following method tests are to be completed successfully before :
71 * <ul>
72 * <li> <code> setTitle </code> </li>
73 * </ul>
75 public void _getTitle() {
76 requiredMethod("setTitle()") ;
78 tRes.tested("getTitle()",
79 "XDialog test".equals(oObj.getTitle())) ;
82 /**
83 * Starts the execution of dialog in a separate thread.
84 * As this call is blocking then the thread execution
85 * must not be finished. <p>
86 * Has <b>OK</b> status if thread wasn't finished and
87 * no exceptions occurred.
89 public void _execute() {
90 boolean result = true ;
92 log.println("Starting execute() thread ...") ;
93 execThread.start() ;
95 try {
96 execThread.join(200) ;
97 } catch (InterruptedException e) {
98 log.println("execute() thread was interrupted") ;
99 result = false ;
101 result &= execThread.isAlive() ;
103 tRes.tested("execute()", result) ;
107 * Calls the method and checks if the execution thread
108 * where <code>execute()</code> method is running was
109 * finished. If <code>execute</code> method didn't return
110 * and still running then thread interrupted. <p>
111 * Has <b>OK</b> status if <code>execute</code> method
112 * call successfully retured.
113 * The following method tests are to be completed successfully before :
114 * <ul>
115 * <li> <code> execute </code> </li>
116 * </ul>
118 public void _endExecute() {
119 requiredMethod("execute()") ;
121 boolean result = true ;
123 oObj.endExecute() ;
125 try {
126 execThread.join(200) ;
127 } catch (InterruptedException e) {
128 log.println("execute() thread was interrupted") ;
129 result = false ;
132 if (execThread.isAlive()) {
133 execThread.interrupt() ;
136 result &= !execThread.isAlive() ;
138 tRes.tested("endExecute()", result) ;
142 * Disposes object environment.
144 @Override
145 public void after() {
146 disposeEnvironment() ;