tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / runner / complexlib / ShowTargets.java
blobf655e1330c1ab32a9444b40a2d5fcf302df89d30
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 complexlib;
21 import java.util.ArrayList;
23 public class ShowTargets
25 public static void main( String[] args )
27 ArrayList<String> targets = new ArrayList<String>();
28 ArrayList<String> descs = new ArrayList<String>();
30 targets.add( "run" );
31 descs.add( "runs all complex tests in this module" );
33 int maxTargetLength = 3;
35 for ( int i = 0; i < args.length; ++i )
37 String completePotentialClassName = args[i].replace( '/', '.' );
39 // filter
40 if ( completePotentialClassName.endsWith( ".TestCase" ) )
41 continue;
42 if ( completePotentialClassName.endsWith( ".TestSkeleton" ) )
43 continue;
45 // get the class
46 Class<?> potentialTestClass = null;
47 try { potentialTestClass = Class.forName( completePotentialClassName ); }
48 catch( java.lang.ClassNotFoundException e )
50 continue;
53 // see if it is derived from complexlib.ComplexTestCase
54 Class<?> superClass = potentialTestClass.getSuperclass();
55 while ( superClass != null )
57 if ( superClass.getName().equals( "complexlib.ComplexTestCase" ) )
59 String bareClassName = completePotentialClassName.substring( completePotentialClassName.lastIndexOf( '.' ) + 1 );
60 String target = "run_" + bareClassName;
61 targets.add( target );
62 descs.add( getShortTestDescription( potentialTestClass ) );
64 if ( maxTargetLength < target.length() )
65 maxTargetLength = target.length();
66 break;
68 superClass = superClass.getSuperclass();
72 System.out.println( "possible targets:" );
73 for ( int i=0; i<targets.size(); ++i )
75 // target
76 String target = targets.get(i);
77 // 'tab'
78 System.out.print( " " + target );
79 for ( int s = maxTargetLength - target.length(); s>0; --s )
80 System.out.print( " " );
81 // description
82 System.out.println( " (" + descs.get(i) + ")" );
86 private static String getShortTestDescription( Class<?> _testClass )
88 java.lang.reflect.Method getShortDescriptionMethod = null;
89 try { getShortDescriptionMethod = _testClass.getMethod( "getShortTestDescription", new Class[]{} ); }
90 catch( Exception e ) { }
92 if ( getShortDescriptionMethod != null )
94 try
96 return (String)getShortDescriptionMethod.invoke( null, new Object[]{} );
98 catch( Exception e ) { }
100 return "no description provided by the test";