merged tag ooo/DEV300_m102
[LibreOffice.git] / qadevOOo / runner / lib / TestResult.java
blobb0c70954a6ccc3e53711956d87e640b9cabb04d0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 package lib;
30 import java.util.Hashtable;
32 /**
33 * The class supports interface tests development and Status calculation.
35 public class TestResult {
36 /**
37 * Contains methods having been tested and their results.
39 protected Hashtable testedMethods = new Hashtable();
41 /**
42 * The method makes method tested with the result, i.e. it adds to its
43 * state OK (if result == true) or FAILED (if result == false) status
44 * and makes the state of the method completed. It's equal to
45 * tested(method, Status(result)) call.
47 * @param method reffers to the method whoch was tested
48 * @param result the result of testing the method
50 * @return the result value
52 * @throw java.lang.IllegalArgumentException if the method is not
53 * available in the interface.
55 * @see #tested(String, Status)
57 public boolean tested( String method, boolean result) {
58 System.out.println("Method "+method+" finished with state "+(result?"OK":"FAILED"));
59 return tested( method, Status.passed( result ) );
62 /**
63 * The method makes the method tested with the status, i.e. it adds the
64 * status to its state and makes it completed.
66 * @param method reffers to the method whoch was tested
67 * @param status describes the result of testing the method
68 * @return <tt>true</tt> if status is OK, <tt>false</tt> otherwise.
70 * @throw java.lang.IllegalArgumentException if the method is not
71 * available in the interface.
73 public boolean tested( String method, Status status ) {
74 testedMethods.put(method,status);
75 return true;
78 /**
79 * @return methods available in the interface tested.
81 public String[] getTestedMethods() {
82 return (String[])testedMethods.keySet().toArray(
83 new String[testedMethods.size()]);
86 /**
87 * @return <tt>true</tt> if the method belongs to the interface tested,
88 * <tt>false</tt> otherwise.
90 public boolean hasMethod( String method ) {
91 return testedMethods.containsKey( method );
94 /**
95 * @return status of testing the method, if it is available (was set by
96 * the tested or assert method), <tt>null</tt> otherwise.
98 * @see #tested(String, boolean)
99 * @see #tested(String, Status)
100 * @see #assert
102 public Status getStatusFor( String method ) {
103 return (Status)testedMethods.get( method );