Set that a non-modal Popover don't auto-grab focus on popup
[LibreOffice.git] / qadevOOo / tests / java / mod / _acceptor / uno / Acceptor.java
blob6cff44ff5c0d94d047b00e7bfce2a765425fd986
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 mod._acceptor.uno;
21 import com.sun.star.uno.XInterface;
22 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.utils;
28 /**
29 * Here <code>com.sun.star.connection.Acceptor</code> service is tested.<p>
30 * Test allows to run object tests in several threads concurrently.
31 * @see com.sun.star.connection.Acceptor
32 * @see com.sun.star.connection.XAcceptor
33 * @see com.sun.star.connection.XConnector
34 * @see ifc.connection._XAcceptor
36 public class Acceptor extends TestCase {
37 /**
38 * Acceptor chooses the first port after <code>basePort</code>
39 * which is free.
41 protected static final int basePort = 10000;
42 private int curPort ;
43 private String sOfficeHost = null ;
45 /**
46 * Retrieves host name where StarOffice is started from test
47 * parameter <code>'CONNECTION_STRING'</code>.
49 @Override
50 public void initialize( TestParameters tParam, PrintWriter log ) {
51 String cncstr = (String) tParam.get("CONNECTION_STRING") ;
52 int idx = cncstr.indexOf("host=") + 5 ;
53 sOfficeHost = cncstr.substring(idx, cncstr.indexOf(",", idx)) ;
56 /**
57 * Creating a TestEnvironment for the interfaces to be tested. <p>
58 * Creates <code>Acceptor</code> service and passed as relation
59 * connection string where port for accepting is unique among
60 * different object test threads. <p>
61 * The following object relations are created :
62 * <ul>
63 * <li> <code>'XAcceptor.connectStr'</code> : String variable for
64 * <code>XAcceptor</code> interface test. Has the following format :
65 * <code>'socket,host=<SOHost>,port=<UniquePort>' where <SOHost> is
66 * the host where StarOffice is started. </li>
67 * <li> <code>'Acceptor.Port'</code> : Integer value which specifies
68 * port on which Acceptor must listen, and which is required
69 * when disposing environment, to free this port number. </li>
70 * <ul>
72 @Override
73 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
75 XInterface acceptor = (XInterface)
76 Param.getMSF().createInstance
77 ("com.sun.star.connection.Acceptor");
79 // select the port
80 curPort = utils.getNextFreePort(basePort);
81 log.println("Choose Port nr: " + curPort);
83 TestEnvironment tEnv = new TestEnvironment(acceptor) ;
85 // adding connection string as relation
86 tEnv.addObjRelation("XAcceptor.connectStr",
87 "socket,host=" + sOfficeHost + ",port=" + curPort) ;
89 // adding port number for freeing it.
90 tEnv.addObjRelation("Acceptor.Port", Integer.valueOf(curPort)) ;
92 return tEnv ;
95 /**
96 * Just clears flag which indicates that port is free now.
98 @Override
99 public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
100 TestParameters tParam) {
102 curPort = ((Integer)tEnv.getObjRelation("Acceptor.Port")).intValue();