merged tag ooo/OOO330_m14
[LibreOffice.git] / framework / qa / complex / broken_document / LoadDocument.java
blob5318b15bc1ea58a4111c59a647745c78e696d7d8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 package complex.broken_document;
29 import com.sun.star.beans.PropertyValue;
30 import com.sun.star.frame.FrameSearchFlag;
31 import com.sun.star.frame.XComponentLoader;
32 import com.sun.star.frame.XFrame;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.uno.UnoRuntime;
35 import complexlib.ComplexTestCase;
37 /**
38 * Check, if message boxes appear when the Office is in "headless" mode. Tests
39 * bug i15809. This test uses the broken document dbf.dbf.emf.
41 public class LoadDocument extends ComplexTestCase {
43 /** defect file to load **/
44 private final String mFileName = "dbf.dbf.emf";
46 /**
47 * Get all test methods.
48 * @return The test methods.
50 public String[] getTestMethodNames() {
51 return new String[]{"checkHeadlessState"};
54 /**
55 * Start Office with "-headless" parameter, then
56 * load the broken document "dbf.dbf.emf", that brings a message box up in
57 * the ui, see if the headless mode of SOffice changes.
59 public void checkHeadlessState() {
60 XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
61 XFrame xDesktop = null;
63 try {
64 xDesktop = (XFrame)UnoRuntime.queryInterface(XFrame.class,
65 xMSF.createInstance("com.sun.star.frame.Desktop"));
67 catch(com.sun.star.uno.Exception e) {
68 failed("Could not create a desktop instance.");
71 XComponentLoader xDesktopLoader = (XComponentLoader)
72 UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);
73 System.out.println("xDektopLoader is null: " + (xDesktopLoader == null));
74 PropertyValue[] val = new PropertyValue[0];
76 String workingDir = (String)param.get("WorkingDir") + System.getProperty("file.separator") + mFileName;
77 System.out.println("Working dir: " + workingDir);
78 String fileUrl = util.utils.getFullURL(workingDir);
79 System.out.println("File Url: " + fileUrl);
81 try {
82 xDesktopLoader.loadComponentFromURL(fileUrl, "_blank", 0, val);
84 catch(com.sun.star.io.IOException e) {
85 failed("Could not load document");
87 catch(com.sun.star.lang.IllegalArgumentException e) {
88 failed("Could not load document");
91 // try again: headless mode defect now?
92 try {
93 xDesktopLoader.loadComponentFromURL(fileUrl, "_blank", 0, val);
95 catch(com.sun.star.io.IOException e) {
96 failed("Could not load document");
98 catch(com.sun.star.lang.IllegalArgumentException e) {
99 failed("Could not load document");