tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / ucb / _XContentProvider.java
blob7f56233fb9b96d25e00eac1857971e9c81f85fc2
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.ucb;
21 import lib.MultiMethodTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.ucb.XContent;
26 import com.sun.star.ucb.XContentIdentifier;
27 import com.sun.star.ucb.XContentIdentifierFactory;
28 import com.sun.star.ucb.XContentProvider;
30 /**
31 * Testing <code>com.sun.star.ucb.XContentProvider</code>
32 * interface methods :
33 * <ul>
34 * <li><code> queryContent()</code></li>
35 * <li><code> compareContentIds()</code></li>
36 * </ul> <p>
37 * This test needs the following object relations :
38 * <ul>
39 * <li> <code>'FACTORY'</code> (of type
40 * <code>com.sun.star.ucb.XContentIdentifierFactory</code>):
41 * a suitable factory which can produce content identifiers </li>
42 * <li> <code>'CONTENT1'</code> (<b>optional</b>) (of type <code>String</code>):
43 * name of the suitable content for provider tested. If relation
44 * is not specified the 'vnd.sun.star.help://' name will be used.</li>
45 * <li> <code>'CONTENT2'</code> (<b>optional</b>) (of type <code>String</code>):
46 * another name of the suitable content for provider tested. If relation
47 * is not specified the 'vnd.sun.star.writer://' name will be used.</li>
48 * <ul> <p>
49 * Test is <b> NOT </b> multithread compliant. <p>
50 * @see com.sun.star.ucb.XContentProvider
52 public class _XContentProvider extends MultiMethodTest {
54 public static XContentProvider oObj = null;
55 protected XContentIdentifierFactory CIF = null ;
56 protected String content1 = "vnd.sun.star.help://" ;
57 protected String content2 = "vnd.sun.star.writer://" ;
59 /**
60 * Retrieves object relations.
61 * @throws StatusException If one of relations not found.
63 @Override
64 public void before() {
65 CIF = (XContentIdentifierFactory) tEnv.getObjRelation("FACTORY");
66 String tmp = (String) tEnv.getObjRelation("CONTENT1") ;
67 if (tmp != null) content1 = tmp ;
68 tmp = (String) tEnv.getObjRelation("CONTENT2") ;
69 if (tmp != null) content2 = tmp ;
71 if (CIF == null) throw new StatusException(
72 Status.failed("'FACTORY' relation is not found.")) ;
75 /**
76 * Tries to query for some content suitable for this provider. <p>
77 * Has <b>OK</b> status if not null value is returned.
79 public void _queryContent() {
80 try {
81 XContentIdentifierFactory CIF = (XContentIdentifierFactory)
82 tEnv.getObjRelation("FACTORY");
83 String aURL = content1;
84 log.println("Trying to query "+aURL);
85 XContentIdentifier CI = CIF.createContentIdentifier(aURL);
86 XContent aContent = oObj.queryContent(CI);
87 boolean res = true;
88 Object nc = tEnv.getObjRelation("NoCONTENT");
89 if (nc == null) {
90 res = aContent != null;
92 tRes.tested("queryContent()",res);
93 } catch (com.sun.star.ucb.IllegalIdentifierException e) {
94 log.println("Exception while checking 'queryContent'");
95 e.printStackTrace(log);
96 tRes.tested("queryContent()",false);
101 * Creates two different content identifiers. First two different
102 * identifiers compared, then two same identifiers. <p>
103 * Has <b>OK</b> status if in the first case <code>false</code>
104 * returned, and in the second - <code>true</code>.
106 public void _compareContentIds() {
107 XContentIdentifierFactory CIF = (XContentIdentifierFactory)
108 tEnv.getObjRelation("FACTORY");
109 String aURL = content1 ;
110 XContentIdentifier CI = CIF.createContentIdentifier(aURL);
111 aURL = content2 ;
112 XContentIdentifier CI2 = CIF.createContentIdentifier(aURL);
113 int compare = oObj.compareContentIds(CI,CI2);
114 boolean res = (compare != 0);
115 if (!res) {
116 log.println("Didn't work with different IDs");
117 log.println(compare+" was returned");
119 compare = oObj.compareContentIds(CI,CI);
120 res &= (compare == 0);
121 if (!res) {
122 log.println("Didn't work with equal IDs");
123 log.println(compare+" was returned");
125 tRes.tested("compareContentIds()",res);