Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / uno / _XComponentContext.java
blob65363ac1bce8fb32a187f1ac19ea118ea604d089
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 .
18 package ifc.uno;
20 import lib.MultiMethodTest;
21 import util.ValueComparer;
23 import com.sun.star.lang.XMultiComponentFactory;
24 import com.sun.star.uno.UnoRuntime;
25 import com.sun.star.uno.XComponentContext;
28 public class _XComponentContext extends MultiMethodTest {
29 public XComponentContext oObj;
30 protected XMultiComponentFactory byValue = null;
31 protected XMultiComponentFactory directly = null;
33 public void _getServiceManager() {
34 log.println("getting manager");
36 directly = oObj.getServiceManager();
37 String[] names = directly.getAvailableServiceNames();
38 boolean res = true;
40 for (int i = 0; i < names.length; i++) {
41 try {
42 if (names[i].equals("com.sun.star.i18n.ConversionDictionary_ko")) continue;
43 if (names[i].equals("com.sun.star.i18n.TextConversion_ko")) continue;
44 log.println("try to instanciate found servicename " +
45 names[i]);
46 directly.createInstanceWithContext(names[i], oObj);
47 log.println("worked .... ok");
48 res &= true;
49 } catch (com.sun.star.uno.Exception e) {
50 log.println("Exception occurred " + e.getMessage());
51 res &= false;
55 tRes.tested("getServiceManager()", res);
58 public void _getValueByName() {
59 requiredMethod("getServiceManager()");
61 Object value = oObj.getValueByName(
62 "/singletons/com.sun.star.lang.theServiceManager");
63 byValue = UnoRuntime.queryInterface(
64 XMultiComponentFactory.class, value);
66 byValue.getAvailableServiceNames();
67 directly.getAvailableServiceNames();
69 boolean res = ValueComparer.equalValue(byValue, directly);
70 tRes.tested("getValueByName()", res);