Set that a non-modal Popover don't auto-grab focus on popup
[LibreOffice.git] / qadevOOo / tests / java / mod / _xmloff / Impress / XMLMetaImporter.java
blobc50782e7ed4fb3a9f5a02bf665e9e9c22dba7fd4
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._xmloff.Impress;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.SOfficeFactory;
28 import com.sun.star.document.XDocumentPropertiesSupplier;
29 import com.sun.star.document.XDocumentProperties;
30 import com.sun.star.lang.XComponent;
31 import com.sun.star.lang.XMultiServiceFactory;
32 import com.sun.star.uno.UnoRuntime;
33 import com.sun.star.uno.XInterface;
35 /**
36 * Test for object which is represented by service
37 * <code>com.sun.star.comp.Impress.XMLMetaImporter</code>. <p>
38 * Object implements the following interfaces :
39 * <ul>
40 * <li><code>com::sun::star::lang::XInitialization</code></li>
41 * <li><code>com::sun::star::document::XImporter</code></li>
42 * <li><code>com::sun::star::document::XFilter</code></li>
43 * <li><code>com::sun::star::document::ImportFilter</code></li>
44 * <li><code>com::sun::star::beans::XPropertySet</code></li>
45 * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li>
46 * </ul>
47 * @see com.sun.star.lang.XInitialization
48 * @see com.sun.star.document.XImporter
49 * @see com.sun.star.document.XFilter
50 * @see com.sun.star.document.ImportFilter
51 * @see com.sun.star.beans.XPropertySet
52 * @see com.sun.star.xml.sax.XDocumentHandler
53 * @see ifc.lang._XInitialization
54 * @see ifc.document._XImporter
55 * @see ifc.document._XFilter
56 * @see ifc.document._XExporter
57 * @see ifc.beans._XPropertySet
58 * @see ifc.xml.sax._XDocumentHandler
60 public class XMLMetaImporter extends TestCase {
61 XComponent xImpressDoc = null;
63 /**
64 * New impress document created.
66 @Override
67 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
69 // get a soffice factory object
70 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
72 log.println( "creating an impress document" );
73 xImpressDoc = SOF.createImpressDoc(null);
76 /**
77 * Impress document destroyed.
79 @Override
80 protected void cleanup( TestParameters tParam, PrintWriter log ) {
81 log.println( " disposing document " );
82 xImpressDoc.dispose();
85 /**
86 * Creating a TestEnvironment for the interfaces to be tested.
87 * Creates an instance of the service
88 * <code>com.sun.star.comp.Impress.XMLMetaImporter</code><p>
90 * The impress document is set as a target document for importer.
91 * Imported XML-data contains only meta tags including title tag
92 * with test title name. After import title name getting from
93 * target document is checked.
94 * Object relations created :
95 * <ul>
96 * <li> <code>'XDocumentHandler.XMLData'</code> for
97 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
98 * <li> <code>'XDocumentHandler.ImportChecker'</code> for
99 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
100 * <li> <code>'TargetDocument'</code> for
101 * {@link ifc.document._XImporter} interface </li>
102 * </ul>
104 @Override
105 public TestEnvironment createTestEnvironment
106 (TestParameters tParam,PrintWriter log ) throws Exception {
108 XInterface oObj = null;
109 Object oInt = null ;
110 final String impTitle = "XMLImporter_test" ;
112 // creation of testobject here
113 // first we write what we are intend to do to log file
114 log.println( "creating a test environment" );
116 XMultiServiceFactory xMSF = tParam.getMSF() ;
118 oInt = xMSF.createInstance
119 ("com.sun.star.comp.Impress.XMLMetaImporter") ;
121 oObj = (XInterface) oInt ;
123 // create testobject here
124 log.println( "creating a new environment for Paragraph object" );
125 TestEnvironment tEnv = new TestEnvironment( oObj );
127 // adding relation
128 tEnv.addObjRelation("TargetDocument", xImpressDoc) ;
130 // adding relation for XDocumentHandler
131 String[][] xml = new String[][] {
132 {"start", "office:document-meta" ,
133 "xmlns:office", "CDATA", "http://openoffice.org/2000/office",
134 "xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/"},
135 {"start", "office:meta"} ,
136 {"start", "dc:title"},
137 {"chars", impTitle},
138 {"end", "dc:title"},
139 {"end", "office:meta"},
140 {"end", "office:document-meta"}} ;
142 tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ;
144 XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface
145 (XDocumentPropertiesSupplier.class, xImpressDoc);
146 final XDocumentProperties xDocProps = xPropSup.getDocumentProperties();
147 final PrintWriter logF = log ;
149 tEnv.addObjRelation("XDocumentHandler.ImportChecker",
150 new ifc.xml.sax._XDocumentHandler.ImportChecker() {
151 public boolean checkImport() {
152 String title = xDocProps.getTitle();
153 logF.println("Title returned = '" + title + "'") ;
154 return impTitle.equals(title) ;
156 } );
158 return tEnv;
159 } // finish method getTestEnvironment