tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / system / _XSystemShellExecute.java
blob3906e7bdcd436b1bcaeb7a39750d5195cdd04a29
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.system;
21 import lib.MultiMethodTest;
22 import util.utils;
24 import com.sun.star.lang.XMultiServiceFactory;
25 import com.sun.star.system.XSystemShellExecute;
26 import com.sun.star.ucb.XSimpleFileAccess;
27 import com.sun.star.uno.UnoRuntime;
30 /**
31 * Testing <code>com.sun.star.system.XSystemShellExecute</code>
32 * interface methods :
33 * <ul>
34 * <li><code> execute()</code></li>
35 * </ul> <p>
36 * Test is <b> NOT </b> multithread compliant. <p>
37 * @see com.sun.star.system.XSystemShellExecute
39 public class _XSystemShellExecute extends MultiMethodTest {
41 public XSystemShellExecute oObj = null;
43 /**
44 * Executes 'java SystemShellExecute SystemShellExecute.txt' command line.
45 * <p>Has <b> OK </b> status if the method successfully returns
46 * and file 'SystemShellExecute.txt' was created. <p>
48 public void _execute() {
49 String cClassPath = System.getProperty("DOCPTH");
50 String cResFile = utils.getOfficeTempDirSys(tParam.getMSF())+"SystemShellExecute.txt";
51 String cResURL = utils.getOfficeTemp(tParam.getMSF())+"SystemShellExecute.txt";
52 String cArgs = "-classpath " + cClassPath +
53 " SystemShellExecute " + cResFile;
55 String jh = System.getProperty("java.home");
56 String fs = System.getProperty("file.separator");
57 String cmd = jh+fs+"bin"+fs+"java";
59 log.println("Executing : '"+cmd+" " + cArgs + "'");
60 try {
61 oObj.execute(cmd, cArgs, 1);
62 } catch (com.sun.star.system.SystemShellExecuteException e) {
63 log.println("Exception during execute: " + e);
64 log.println("This has been implemented due to security reasons");
65 tRes.tested("execute()", true);
66 return;
67 } catch (com.sun.star.lang.IllegalArgumentException e) {
68 log.println("Exception during execute: " + e);
69 tRes.tested("execute()", false);
70 return;
73 XSimpleFileAccess xFileAccess = null;
74 try {
75 XMultiServiceFactory xMSF = tParam.getMSF();
76 Object fa = xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
77 xFileAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
78 } catch (com.sun.star.uno.Exception e) {
79 log.println("Couldn't create SimpleFileAccess:" + e);
80 tRes.tested("execute()", false);
81 return;
84 log.println("Waiting while the file will be created or timeout "+
85 "reached ...");
86 boolean bExist = false;
87 int i = 0;
88 while (i < 20 && !bExist) {
89 try {
90 bExist = xFileAccess.exists(cResURL);
91 } catch(com.sun.star.uno.Exception e) {
92 log.println("Exception:" + e);
94 waitForEventIdle();
95 i++;
98 if (bExist) {
99 log.println("The command was executed and file created in " +
100 i + " sec.");
101 } else {
102 log.println("File was not created");
105 tRes.tested("execute()", bExist);
107 } // finish class _XSystemShellExecute