diff options
Diffstat (limited to 'toolkit/qa')
12 files changed, 315 insertions, 742 deletions
diff --git a/toolkit/qa/complex/toolkit/CheckAccessibleStatusBar.java b/toolkit/qa/complex/toolkit/AccessibleStatusBar.java index cfb40614beab..d4f2329d8f31 100755 --- a/toolkit/qa/complex/toolkit/CheckAccessibleStatusBar.java +++ b/toolkit/qa/complex/toolkit/AccessibleStatusBar.java @@ -27,12 +27,15 @@ package complex.toolkit; -// import complexlib.ComplexTestCase; -import lib.TestParameters; +import complex.toolkit.accessibility._XAccessibleEventBroadcaster; +import complex.toolkit.accessibility._XAccessibleExtendedComponent; +import complex.toolkit.accessibility._XAccessibleComponent; +import complex.toolkit.accessibility._XAccessibleContext; +import java.util.logging.Logger; +import java.util.logging.Level; import util.SOfficeFactory; import util.AccessibilityTools; import com.sun.star.awt.XWindow; -// import com.sun.star.chart.XChartDocument; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XComponent; import com.sun.star.lang.XServiceInfo; @@ -45,11 +48,8 @@ import com.sun.star.accessibility.AccessibleRole; import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.awt.XExtendedToolkit; -// import java.io.PrintWriter; -// import org.junit.After; import org.junit.AfterClass; -// import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.openoffice.test.OfficeConnection; @@ -58,26 +58,12 @@ import static org.junit.Assert.*; /** * */ -public class CheckAccessibleStatusBar { +public class AccessibleStatusBar { XInterface testObject = null; XMultiServiceFactory xMSF = null; XWindow xWindow = null; - /** - * The test parameters - */ - private static TestParameters param = null; - -// public String[] getTestMethodNames() { -// return new String[]{"checkDocs"};//WriterDoc", "checkDrawDoc", -//// "checkMathDoc", "checkImpressDoc", "checkCalcDoc"}; -// } - -/* public String getTestObjectName() { - return "com.sun.star.awt.AccessibleStatusBar"; - } -*/ private XMultiServiceFactory getMSF() { final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); @@ -100,41 +86,13 @@ public class CheckAccessibleStatusBar { /** * Check document types */ - @Test public void checkDocs() { - Object doc = param.get("DocType"); - String testDocType; - if (doc == null) - { - testDocType = "all"; - } - else - { - testDocType = (String)doc; - } - - System.out.println("Param was " + doc); - System.out.println("DocType " + testDocType); - if (testDocType.equalsIgnoreCase("writer") || testDocType.equalsIgnoreCase("all")) - { - checkWriterDoc(); - } - if (testDocType.equalsIgnoreCase("math") || testDocType.equalsIgnoreCase("all")) - { - checkMathDoc(); - } - if (testDocType.equalsIgnoreCase("draw") || testDocType.equalsIgnoreCase("all")) - { - checkDrawDoc(); - } - if (testDocType.equalsIgnoreCase("impress") || testDocType.equalsIgnoreCase("all")) - { - checkImpressDoc(); - } - if (testDocType.equalsIgnoreCase("calc") || testDocType.equalsIgnoreCase("all")) - { - checkCalcDoc(); - } - + @Test + public void checkDocs() { + checkWriterDoc(); + checkMathDoc(); + checkDrawDoc(); + checkImpressDoc(); + checkCalcDoc(); } /** @@ -150,7 +108,7 @@ public class CheckAccessibleStatusBar { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -160,7 +118,7 @@ public class CheckAccessibleStatusBar { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -178,7 +136,7 @@ public class CheckAccessibleStatusBar { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -188,7 +146,7 @@ public class CheckAccessibleStatusBar { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -206,7 +164,7 @@ public class CheckAccessibleStatusBar { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -216,7 +174,7 @@ public class CheckAccessibleStatusBar { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -234,7 +192,7 @@ public class CheckAccessibleStatusBar { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -244,7 +202,7 @@ public class CheckAccessibleStatusBar { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -262,7 +220,7 @@ public class CheckAccessibleStatusBar { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -272,7 +230,7 @@ public class CheckAccessibleStatusBar { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -287,12 +245,11 @@ public class CheckAccessibleStatusBar { xWindow = UnoRuntime.queryInterface(XWindow.class, tk.getActiveTopWindow()); shortWait(); - AccessibilityTools at = new AccessibilityTools(); - XAccessible xRoot = at.getAccessibleObject(xWindow); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); XAccessibleContext parentContext = null; System.out.println("Get the accessible status bar."); - parentContext = at.getAccessibleObjectForRole( + parentContext = AccessibilityTools.getAccessibleObjectForRole( xRoot, AccessibleRole.STATUS_BAR, ""); shortWait(); System.out.println("...OK."); @@ -309,11 +266,11 @@ public class CheckAccessibleStatusBar { testObject=parentContext; } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } catch(Throwable t) { System.out.println("Got throwable:"); - t.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", t ); } } @@ -354,7 +311,7 @@ public class CheckAccessibleStatusBar { System.out.println("*** Now testing XAccessibleEventBroadcaster ***"); _XAccessibleEventBroadcaster _xAccEvBcast = - new _XAccessibleEventBroadcaster(testObject, "Pfff", xWindow); + new _XAccessibleEventBroadcaster(testObject, xWindow); assertTrue("failed: XAccessibleEventBroadcaster::addEventListener", _xAccEvBcast._addEventListener()); assertTrue("failed: XAccessibleEventBroadcaster::removeEventListener", _xAccEvBcast._removeEventListener()); } @@ -362,12 +319,14 @@ public class CheckAccessibleStatusBar { - @BeforeClass public static void setUpConnection() throws Exception { + @BeforeClass + public static void setUpConnection() throws Exception { System.out.println("setUpConnection()"); connection.setUp(); } - @AfterClass public static void tearDownConnection() + @AfterClass + public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception { System.out.println("tearDownConnection()"); diff --git a/toolkit/qa/complex/toolkit/CheckAccessibleStatusBarItem.java b/toolkit/qa/complex/toolkit/AccessibleStatusBarItem.java index 537654c6aacc..edd84651d45e 100755 --- a/toolkit/qa/complex/toolkit/CheckAccessibleStatusBarItem.java +++ b/toolkit/qa/complex/toolkit/AccessibleStatusBarItem.java @@ -27,14 +27,16 @@ package complex.toolkit; -// import complexlib.ComplexTestCase; -import lib.TestParameters; -// import util.SOfficeFactory; -// import complexlib.ComplexTestCase; +import java.util.logging.Logger; +import java.util.logging.Level; +import complex.toolkit.accessibility._XAccessibleEventBroadcaster; +import complex.toolkit.accessibility._XAccessibleExtendedComponent; +import complex.toolkit.accessibility._XAccessibleText; +import complex.toolkit.accessibility._XAccessibleComponent; +import complex.toolkit.accessibility._XAccessibleContext; import util.SOfficeFactory; import util.AccessibilityTools; import com.sun.star.awt.XWindow; -// import com.sun.star.chart.XChartDocument; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XComponent; import com.sun.star.lang.XServiceInfo; @@ -47,12 +49,9 @@ import com.sun.star.accessibility.AccessibleRole; import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.awt.XExtendedToolkit; -// import java.io.PrintWriter; -// import org.junit.After; import org.junit.AfterClass; -// import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.openoffice.test.OfficeConnection; @@ -61,35 +60,17 @@ import static org.junit.Assert.*; /** * */ -public class CheckAccessibleStatusBarItem { +public class AccessibleStatusBarItem { XMultiServiceFactory xMSF = null; XAccessibleContext testObject = null; XWindow xWindow = null; - /** - * The test parameters - */ - private static TestParameters param = null; - -// public String[] getTestMethodNames() { -// return new String[]{"checkDocs"};//{"checkWriterDoc", "checkDrawDoc", -//// "checkMathDoc", "checkImpressDoc", "checkCalcDoc"}; -// } - - /** - * Sleeps for 0.5 sec. to allow StarOffice to react on <code> - * reset</code> call. - */ - private void shortWait() { - shortWait(500) ; - } - /** * Sleeps for a certain time. * @param Thread is sleeping for this time in milliseconds. */ - private void shortWait(int time) { + private void shortWait() { try { Thread.sleep(500); } catch (InterruptedException e) { @@ -100,43 +81,14 @@ public class CheckAccessibleStatusBarItem { /** * Check document types */ - @Test public void checkDocs() + @Test + public void checkDocs() { - param = new TestParameters(); - Object doc = param.get("DocType"); - String testDocType; - if (doc == null) - { - testDocType = "all"; - } - else - { - testDocType = (String)doc; - } - - System.out.println("Param was " + doc); - System.out.println("DocType " + testDocType); - if (testDocType.equalsIgnoreCase("writer") || testDocType.equalsIgnoreCase("all")) - { - checkWriterDoc(); - } - if (testDocType.equalsIgnoreCase("math") || testDocType.equalsIgnoreCase("all")) - { - checkMathDoc(); - } - if (testDocType.equalsIgnoreCase("draw") || testDocType.equalsIgnoreCase("all")) - { - checkDrawDoc(); - } - if (testDocType.equalsIgnoreCase("impress") || testDocType.equalsIgnoreCase("all")) - { - checkImpressDoc(); - } - if (testDocType.equalsIgnoreCase("calc") || testDocType.equalsIgnoreCase("all")) - { - checkCalcDoc(); - } - + checkWriterDoc(); + checkMathDoc(); + checkDrawDoc(); + checkImpressDoc(); + checkCalcDoc(); } private XMultiServiceFactory getMSF() @@ -158,7 +110,7 @@ public class CheckAccessibleStatusBarItem { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -168,7 +120,7 @@ public class CheckAccessibleStatusBarItem { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -186,7 +138,7 @@ public class CheckAccessibleStatusBarItem { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -196,7 +148,7 @@ public class CheckAccessibleStatusBarItem { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -214,7 +166,7 @@ public class CheckAccessibleStatusBarItem { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -224,7 +176,7 @@ public class CheckAccessibleStatusBarItem { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -242,7 +194,7 @@ public class CheckAccessibleStatusBarItem { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -252,7 +204,7 @@ public class CheckAccessibleStatusBarItem { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -270,7 +222,7 @@ public class CheckAccessibleStatusBarItem { getTestObject(); } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } runAllInterfaceTests(); @@ -280,7 +232,7 @@ public class CheckAccessibleStatusBarItem { xClose.close(false); } catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } } } @@ -297,35 +249,25 @@ public class CheckAccessibleStatusBarItem { XWindow.class,tk.getActiveTopWindow()); shortWait(); - AccessibilityTools at = new AccessibilityTools(); - XAccessible xRoot = at.getAccessibleObject(xWindow); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); XAccessibleContext parentContext = null; System.out.println("Get the accessible status bar."); - parentContext = at.getAccessibleObjectForRole( + parentContext = AccessibilityTools.getAccessibleObjectForRole( xRoot, AccessibleRole.STATUS_BAR, ""); shortWait(); if ( parentContext == null ) { - System.out.println("Could not get the test object: set the correct focus in the next 30 seconds."); - shortWait(30000); - parentContext = at.getAccessibleObjectForRole( - xRoot, AccessibleRole.STATUS_BAR, ""); - - if ( parentContext == null ) - { - fail("Could not create a test object."); - } + fail("Could not create a test object."); } System.out.println("...OK."); testObject=parentContext; } catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); } catch(Throwable t) { - System.out.println("Got throwable:"); - t.printStackTrace(); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", t ); } } @@ -391,7 +333,7 @@ public class CheckAccessibleStatusBarItem { System.out.println("*** Now testing XAccessibleEventBroadcaster ***"); _XAccessibleEventBroadcaster _xAccEvBcast = - new _XAccessibleEventBroadcaster(object, "Pfff", xWindow); + new _XAccessibleEventBroadcaster(object, xWindow); assertTrue("failed: "+accName+" - XAccessibleEventBroadcaster::addEventListener", _xAccEvBcast._addEventListener()); assertTrue("failed: "+accName+" - XAccessibleEventBroadcaster::removeEventListener", _xAccEvBcast._removeEventListener()); diff --git a/toolkit/qa/complex/toolkit/CallbackClass.java b/toolkit/qa/complex/toolkit/CallbackClass.java deleted file mode 100644 index 1c9eb68a6d34..000000000000 --- a/toolkit/qa/complex/toolkit/CallbackClass.java +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package complex.toolkit; - -import com.sun.star.awt.XCallback; -// import lib.MultiMethodTest; -import com.sun.star.lang.XMultiServiceFactory; -// import com.sun.star.uno.XInterface; -// import com.sun.star.uno.UnoRuntime; -// import share.LogWriter; - -/** - * Testing <code>com.sun.star.awt.XRequestCallback</code> - * interface methods : - * <ul> - * <li><code> addCallback()</code></li> - * </ul> <p> - * @see com.sun.star.awt.XRequestCallback - */ -public class CallbackClass implements XCallback{ - - // private LogWriter log; - - private XMultiServiceFactory xMSF; - - - public CallbackClass(XMultiServiceFactory xMSF ) { - - this.xMSF = xMSF; - // this.log = log; - } - - - /** - * Callback method which will be called by the asynchronous - * service where we have added our request before. - */ - public void notify( Object aData ) { - - System.out.println("callback called successfully" ); - } -} diff --git a/toolkit/qa/complex/toolkit/CheckAsyncCallback.java b/toolkit/qa/complex/toolkit/CheckAsyncCallback.java deleted file mode 100644 index 3a1e51729f11..000000000000 --- a/toolkit/qa/complex/toolkit/CheckAsyncCallback.java +++ /dev/null @@ -1,156 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package complex.toolkit; - -// import complexlib.ComplexTestCase; -import util.SOfficeFactory; -// import complex.toolkit.CallbackClass; -import com.sun.star.awt.XRequestCallback; -import com.sun.star.lang.XMultiServiceFactory; -// import com.sun.star.lang.XComponent; -// import com.sun.star.lang.XServiceInfo; -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -// import com.sun.star.awt.XExtendedToolkit; -// import java.io.PrintWriter; - -// import org.junit.After; -import org.junit.AfterClass; -// import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openoffice.test.OfficeConnection; -import static org.junit.Assert.*; - -/** - * - */ -public class CheckAsyncCallback /* extends ComplexTestCase*/ { - - - XInterface testObject = null; - XMultiServiceFactory xMSF = null; - -// public String[] getTestMethodNames() { -// return new String[]{"checkService"}; -// } - -/* public String getTestObjectName() { - return "com.sun.star.awt.AccessibleStatusBar"; - } -*/ - private XMultiServiceFactory getMSF() - { - final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); - return xMSF1; - } - - /** - * Sleeps for 0.5 sec. to allow StarOffice to react on <code> - * reset</code> call. - */ - private void shortWait() { - try { - Thread.sleep(500) ; - } catch (InterruptedException e) { - System.out.println("While waiting :" + e) ; - } - } - - /** - * Check services - */ - @Test public void checkService() { - checkAsyncCallbackService(); - - } - - /** - * Test the interfaces - */ - public void checkAsyncCallbackService() { - runAllInterfaceTests(); - } - - public void getTestObject() { - try { - xMSF = getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - - XRequestCallback xAsyncCallback = null; - - XInterface xIfc = (XInterface)xMSF.createInstance( - "com.sun.star.awt.AsyncCallback" ); - xAsyncCallback = UnoRuntime.queryInterface(XRequestCallback.class, xIfc); - - testObject=xAsyncCallback; - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - catch(Throwable t) { - System.out.println("Got throwable:"); - t.printStackTrace(); - } - } - - public void runAllInterfaceTests() { - getTestObject(); - System.out.println("*** Now testing XRequestCallback ***"); - _XRequestCallback _xRequestCallback = - new _XRequestCallback(testObject, xMSF ); - assertTrue("failed: XRequestCallback::addCallback", _xRequestCallback._addCallback()); - } - - public void checkCallback() { - getTestObject(); - System.out.println("*** Now testing asynchronous callback service ***"); - XRequestCallback xAsyncCallback = null; - xAsyncCallback = UnoRuntime.queryInterface(XRequestCallback.class, testObject); - CallbackClass aCallbackClass = new CallbackClass( xMSF ); - xAsyncCallback.addCallback( aCallbackClass, null ); - } - - - - @BeforeClass public static void setUpConnection() throws Exception { - System.out.println("setUpConnection()"); - connection.setUp(); - } - - @AfterClass public static void tearDownConnection() - throws InterruptedException, com.sun.star.uno.Exception - { - System.out.println("tearDownConnection()"); - connection.tearDown(); - } - - private static final OfficeConnection connection = new OfficeConnection(); - - -} diff --git a/toolkit/qa/complex/toolkit/UnitConversion.java b/toolkit/qa/complex/toolkit/UnitConversion.java new file mode 100644 index 000000000000..6441a7ecb4ff --- /dev/null +++ b/toolkit/qa/complex/toolkit/UnitConversion.java @@ -0,0 +1,244 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package complex.toolkit; + +import com.sun.star.awt.XUnitConversion; +import com.sun.star.uno.UnoRuntime; + +import com.sun.star.awt.XWindow; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.awt.XWindowPeer; + +import util.DesktopTools; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + +/** + * This complex test is only for testing the com.sun.star.awt.XUnitConversion methods + * These are converter methods to get the size of a well known awt component + * in a com.sun.star.util.MeasureUnit you want. + * You don't need to know the factors to calculate by hand. + * + * @author ll93751 + */ +public class UnitConversion +{ + /** + * returns the delta value between a and b + * @param a + * @param b + * @return + */ + private int delta(int a, int b) + { + final int n = Math.abs(a - b); + return n; + } + + private XUnitConversion m_xConversion = null; + + /** + * Not really a check, + * only a simple test call to convertSizeToLogic(...) with different parameters + * @param _aSize + * @param _aMeasureUnit + * @param _sEinheit + */ + private void checkSize(com.sun.star.awt.Size _aSize, short _aMeasureUnit, String _sEinheit) + { + try + { + com.sun.star.awt.Size aSizeIn = m_xConversion.convertSizeToLogic(_aSize, _aMeasureUnit); + System.out.println("Window size:"); + System.out.println("Width:" + aSizeIn.Width + " " + _sEinheit); + System.out.println("Height:" + aSizeIn.Height + " " + _sEinheit); + System.out.println(""); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + System.out.println("Caught IllegalArgumentException in convertSizeToLogic with '" + _sEinheit + "' " + e.getMessage()); + } + } + + /** + * The real test function + * 1. try to get the XMultiServiceFactory of an already running office. Therefore make sure an (open|star)office is running with + * parameters like -accept="socket,host=localhost,port=8100;urp;" + * 2. try to create an empty window + * 3. try to convert the WindowPeer to an XWindow + * 4. try to resize and move the window to an other position, so we get a well knowing position and size. + * 5. run some more tests + * + * If no test fails, the test is well done and returns with 'PASSED, OK' + * + */ + @Test + public void testXUnitConversion() + { + final XMultiServiceFactory xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + + assertNotNull("failed: There is no office.", xMSF); + + // create a window + XWindowPeer xWindowPeer = DesktopTools.createFloatingWindow(xMSF); + assertNotNull("failed: there is no window peer", xWindowPeer); + + + // resize and move the window to a well known position and size + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xWindowPeer); + assertNotNull("failed: there is no window, cast wrong?", xWindow); + + xWindow.setVisible(Boolean.TRUE); + + int x = 100; + int y = 100; + int width = 640; + int height = 480; + xWindow.setPosSize(x, y, width, height, com.sun.star.awt.PosSize.POSSIZE); + + com.sun.star.awt.Rectangle aRect = xWindow.getPosSize(); + com.sun.star.awt.Point aPoint = new com.sun.star.awt.Point(aRect.X, aRect.Y); + com.sun.star.awt.Size aSize = new com.sun.star.awt.Size(aRect.Width, aRect.Height); + + System.out.println("Window position and size in pixel:"); + System.out.println("X:" + aPoint.X); + System.out.println("Y:" + aPoint.Y); + System.out.println("Width:" + aSize.Width); + System.out.println("Height:" + aSize.Height); + System.out.println(""); + + assertTrue("Window pos size wrong", aSize.Width == width && aSize.Height == height && aPoint.X == x && aPoint.Y == y); + + m_xConversion = UnoRuntime.queryInterface(XUnitConversion.class, xWindowPeer); + + // try to get the position of the window in 1/100mm with the XUnitConversion method + try + { + com.sun.star.awt.Point aPointInMM_100TH = m_xConversion.convertPointToLogic(aPoint, com.sun.star.util.MeasureUnit.MM_100TH); + System.out.println("Window position:"); + System.out.println("X:" + aPointInMM_100TH.X + " 1/100mm"); + System.out.println("Y:" + aPointInMM_100TH.Y + " 1/100mm"); + System.out.println(""); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + fail("failed: IllegalArgumentException caught in convertPointToLogic " + e.getMessage()); + } + + // try to get the size of the window in 1/100mm with the XUnitConversion method + com.sun.star.awt.Size aSizeInMM_100TH = null; + com.sun.star.awt.Size aSizeInMM_10TH = null; + try + { + aSizeInMM_100TH = m_xConversion.convertSizeToLogic(aSize, com.sun.star.util.MeasureUnit.MM_100TH); + System.out.println("Window size:"); + System.out.println("Width:" + aSizeInMM_100TH.Width + " 1/100mm"); + System.out.println("Height:" + aSizeInMM_100TH.Height + " 1/100mm"); + System.out.println(""); + + // try to get the size of the window in 1/10mm with the XUnitConversion method + + aSizeInMM_10TH = m_xConversion.convertSizeToLogic(aSize, com.sun.star.util.MeasureUnit.MM_10TH); + System.out.println("Window size:"); + System.out.println("Width:" + aSizeInMM_10TH.Width + " 1/10mm"); + System.out.println("Height:" + aSizeInMM_10TH.Height + " 1/10mm"); + System.out.println(""); + + // check the size with a delta which must be smaller a given difference + assertTrue("Size.Width not correct", delta(aSizeInMM_100TH.Width, aSizeInMM_10TH.Width * 10) < 10); + assertTrue("Size.Height not correct", delta(aSizeInMM_100TH.Height, aSizeInMM_10TH.Height * 10) < 10); + + // new + checkSize(aSize, com.sun.star.util.MeasureUnit.PIXEL, "pixel"); + checkSize(aSize, com.sun.star.util.MeasureUnit.APPFONT, "appfont"); + checkSize(aSize, com.sun.star.util.MeasureUnit.SYSFONT, "sysfont"); + + // simply check some more parameters + checkSize(aSize, com.sun.star.util.MeasureUnit.MM, "mm"); + checkSize(aSize, com.sun.star.util.MeasureUnit.CM, "cm"); + checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_1000TH, "1/1000inch"); + checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_100TH, "1/100inch"); + checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_10TH, "1/10inch"); + checkSize(aSize, com.sun.star.util.MeasureUnit.INCH, "inch"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.M, "m"); + checkSize(aSize, com.sun.star.util.MeasureUnit.POINT, "point"); + checkSize(aSize, com.sun.star.util.MeasureUnit.TWIP, "twip"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.KM, "km"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.PICA, "pica"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.FOOT, "foot"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.MILE, "mile"); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + fail("failed: IllegalArgumentException caught in convertSizeToLogic " + e.getMessage()); + } + + // convert the 1/100mm window size back to pixel + try + { + com.sun.star.awt.Size aNewSize = m_xConversion.convertSizeToPixel(aSizeInMM_100TH, com.sun.star.util.MeasureUnit.MM_100TH); + System.out.println("Window size:"); + System.out.println("Width:" + aNewSize.Width + " pixel"); + System.out.println("Height:" + aNewSize.Height + " pixel"); + + // assure the pixels are the same as we already know + assertTrue("failed: Size from pixel to 1/100mm to pixel", aSize.Width == aNewSize.Width && aSize.Height == aNewSize.Height); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + fail("failed: IllegalArgumentException caught in convertSizeToPixel " + e.getMessage()); + } + + // close the window. + // IMHO a little bit stupid, but the XWindow doesn't support a XCloseable interface + xWindow.dispose(); + } + + + + @BeforeClass + public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass + public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); + +} diff --git a/toolkit/qa/complex/toolkit/_XRequestCallback.java b/toolkit/qa/complex/toolkit/_XRequestCallback.java deleted file mode 100644 index b9486c04c80a..000000000000 --- a/toolkit/qa/complex/toolkit/_XRequestCallback.java +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package complex.toolkit; - -import com.sun.star.awt.XRequestCallback; -// import lib.MultiMethodTest; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -// import share.LogWriter; - -/** - * Testing <code>com.sun.star.awt.XRequestCallback</code> - * interface methods : - * <ul> - * <li><code> addCallback()</code></li> - * </ul> <p> - * @see com.sun.star.awt.XRequestCallback - */ -public class _XRequestCallback { - - // private LogWriter log; - - private static final String className = - "com.sun.star.awt.XRequestCallback" ; - - public XRequestCallback oObj = null; - private XMultiServiceFactory xMSF; - - String text = null; - - - public _XRequestCallback(XInterface object, XMultiServiceFactory xMSF ) { - oObj = UnoRuntime.queryInterface(XRequestCallback.class, object); - this.xMSF = xMSF; - // this.log = log; - } - - - /** - * Calls the method and checks returned value. - * Has OK status if returned value is equal to <code>chCount - 1</code>. - * The following method tests are to be executed before: - * <ul> - * <li> <code>addCallback()</code> </li> - * </ul> - * @return - */ - public boolean _addCallback() { - - boolean res = true; - try { - Object a = new Object(); - oObj.addCallback( null, a ); - } catch (com.sun.star.uno.RuntimeException ie) { - res = false; - } - System.out.println("addCallback called" ); - - return res; - } - -} diff --git a/toolkit/qa/complex/toolkit/_XAccessibleComponent.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent.java index ae3e293e50fc..7dca37ce18b7 100755 --- a/toolkit/qa/complex/toolkit/_XAccessibleComponent.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent.java @@ -25,9 +25,8 @@ * ************************************************************************/ -package complex.toolkit; +package complex.toolkit.accessibility; -// import share.LogWriter; import com.sun.star.awt.Point; import com.sun.star.awt.Rectangle; import com.sun.star.awt.Size; diff --git a/toolkit/qa/complex/toolkit/_XAccessibleContext.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleContext.java index de2928fdabe3..14debda92cd8 100755 --- a/toolkit/qa/complex/toolkit/_XAccessibleContext.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleContext.java @@ -25,7 +25,7 @@ * ************************************************************************/ -package complex.toolkit; +package complex.toolkit.accessibility; import com.sun.star.lang.Locale; import com.sun.star.uno.XInterface; diff --git a/toolkit/qa/complex/toolkit/_XAccessibleEventBroadcaster.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleEventBroadcaster.java index 899028daec87..535c7ce36c68 100755 --- a/toolkit/qa/complex/toolkit/_XAccessibleEventBroadcaster.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleEventBroadcaster.java @@ -25,7 +25,7 @@ * ************************************************************************/ -package complex.toolkit; +package complex.toolkit.accessibility; import com.sun.star.lang.EventObject; import com.sun.star.awt.Rectangle; @@ -33,13 +33,11 @@ import com.sun.star.awt.PosSize; import com.sun.star.awt.XWindow; import com.sun.star.accessibility.AccessibleEventObject; import com.sun.star.accessibility.XAccessible; -// import com.sun.star.accessibility.XAccessibleComponent; import com.sun.star.accessibility.XAccessibleEventBroadcaster; import com.sun.star.accessibility.XAccessibleEventListener; import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.uno.XInterface; import com.sun.star.uno.UnoRuntime; -// import share.LogWriter; /** * Testing <code> @@ -62,12 +60,7 @@ import com.sun.star.uno.UnoRuntime; */ public class _XAccessibleEventBroadcaster { - // private LogWriter log; - private static final String className = - "com.sun.star.accessibility.XAccessibleEventBroadcaster" ; - public XAccessibleEventBroadcaster oObj = null; - public String EventMsg = ""; EventProducer prod = null ; EvListener list = new EvListener(); @@ -120,11 +113,9 @@ public class _XAccessibleEventBroadcaster { * @param eventMessage * @param window */ - public _XAccessibleEventBroadcaster(XInterface object, String eventMessage, XWindow window) { + public _XAccessibleEventBroadcaster(XInterface object, XWindow window) { oObj = UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, object); - // this.log = log; prod = new EventProducer(window); - EventMsg = eventMessage; } /** @@ -157,7 +148,6 @@ public class _XAccessibleEventBroadcaster { oObj.removeEventListener(list); } -// System.out.println(EventMsg); return works; } diff --git a/toolkit/qa/complex/toolkit/_XAccessibleExtendedComponent.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleExtendedComponent.java index 2ba5c190cf31..551b00acada7 100755 --- a/toolkit/qa/complex/toolkit/_XAccessibleExtendedComponent.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleExtendedComponent.java @@ -25,7 +25,7 @@ * ************************************************************************/ -package complex.toolkit; +package complex.toolkit.accessibility; // import lib.MultiMethodTest; import com.sun.star.accessibility.XAccessibleExtendedComponent; diff --git a/toolkit/qa/complex/toolkit/_XAccessibleText.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleText.java index 151e6b3f7d0b..a12d93a2d9e2 100755 --- a/toolkit/qa/complex/toolkit/_XAccessibleText.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleText.java @@ -25,7 +25,7 @@ * ************************************************************************/ -package complex.toolkit; +package complex.toolkit.accessibility; import com.sun.star.accessibility.XAccessibleText; // import lib.MultiMethodTest; diff --git a/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java b/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java deleted file mode 100644 index f9840e4bde6f..000000000000 --- a/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java +++ /dev/null @@ -1,250 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package complex.xunitconversion; - -import com.sun.star.awt.XUnitConversion; -import com.sun.star.uno.UnoRuntime; - -import com.sun.star.awt.XWindow; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.awt.XWindowPeer; - -import util.DesktopTools; - -// import org.junit.After; -import org.junit.AfterClass; -// import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openoffice.test.OfficeConnection; -import static org.junit.Assert.*; - -/** - * This complex test is only for testing the com.sun.star.awt.XUnitConversion methods - * These are converter methods to get the size of a well known awt component - * in a com.sun.star.util.MeasureUnit you want. - * You don't need to know the factors to calculate by hand. - * - * @author ll93751 - */ -public class XUnitConversionTest -{ -// public String[] getTestMethodNames() -// { -// return new String[]{"testXUnitConversion"}; // function name of the test method -// } - - /** - * returns the delta value between a and b - * @param a - * @param b - * @return - */ - private int delta(int a, int b) - { - final int n = Math.abs(a - b); - return n; - } - - private XUnitConversion m_xConversion = null; - - /** - * Not really a check, - * only a simple test call to convertSizeToLogic(...) with different parameters - * @param _aSize - * @param _aMeasureUnit - * @param _sEinheit - */ - private void checkSize(com.sun.star.awt.Size _aSize, short _aMeasureUnit, String _sEinheit) - { - try - { - com.sun.star.awt.Size aSizeIn = m_xConversion.convertSizeToLogic(_aSize, _aMeasureUnit); - System.out.println("Window size:"); - System.out.println("Width:" + aSizeIn.Width + " " + _sEinheit); - System.out.println("Height:" + aSizeIn.Height + " " + _sEinheit); - System.out.println(""); - } - catch (com.sun.star.lang.IllegalArgumentException e) - { - System.out.println("Caught IllegalArgumentException in convertSizeToLogic with '" + _sEinheit + "' " + e.getMessage()); - } - } - -/** - * The real test function - * 1. try to get the XMultiServiceFactory of an already running office. Therefore make sure an (open|star)office is running with - * parameters like -accept="socket,host=localhost,port=8100;urp;" - * 2. try to create an empty window - * 3. try to convert the WindowPeer to an XWindow - * 4. try to resize and move the window to an other position, so we get a well knowing position and size. - * 5. run some more tests - * - * If no test fails, the test is well done and returns with 'PASSED, OK' - * - */ - @Test public void testXUnitConversion() - { - // XMultiServiceFactory xMSF = (XMultiServiceFactory) param.getMSF(); - final XMultiServiceFactory xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); - - assertNotNull("failed: There is no office.", xMSF); - - // create a window - XWindowPeer xWindowPeer = DesktopTools.createFloatingWindow(xMSF); - assertNotNull("failed: there is no window peer", xWindowPeer); - - - // resize and move the window to a well known position and size - XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xWindowPeer); - assertNotNull("failed: there is no window, cast wrong?", xWindow); - - xWindow.setVisible(Boolean.TRUE); - - int x = 100; - int y = 100; - int width = 640; - int height = 480; - xWindow.setPosSize(x, y, width, height, com.sun.star.awt.PosSize.POSSIZE); - - com.sun.star.awt.Rectangle aRect = xWindow.getPosSize(); - com.sun.star.awt.Point aPoint = new com.sun.star.awt.Point(aRect.X, aRect.Y); - com.sun.star.awt.Size aSize = new com.sun.star.awt.Size(aRect.Width, aRect.Height); - - System.out.println("Window position and size in pixel:"); - System.out.println("X:" + aPoint.X); - System.out.println("Y:" + aPoint.Y); - System.out.println("Width:" + aSize.Width); - System.out.println("Height:" + aSize.Height); - System.out.println(""); - - assertTrue("Window pos size wrong", aSize.Width == width && aSize.Height == height && aPoint.X == x && aPoint.Y == y); - - // XToolkit aToolkit = xWindowPeer.getToolkit(); - m_xConversion = UnoRuntime.queryInterface(XUnitConversion.class, xWindowPeer); - - // try to get the position of the window in 1/100mm with the XUnitConversion method - try - { - com.sun.star.awt.Point aPointInMM_100TH = m_xConversion.convertPointToLogic(aPoint, com.sun.star.util.MeasureUnit.MM_100TH); - System.out.println("Window position:"); - System.out.println("X:" + aPointInMM_100TH.X + " 1/100mm"); - System.out.println("Y:" + aPointInMM_100TH.Y + " 1/100mm"); - System.out.println(""); - } - catch (com.sun.star.lang.IllegalArgumentException e) - { - fail("failed: IllegalArgumentException caught in convertPointToLogic " + e.getMessage()); - } - - // try to get the size of the window in 1/100mm with the XUnitConversion method - com.sun.star.awt.Size aSizeInMM_100TH = null; - com.sun.star.awt.Size aSizeInMM_10TH = null; - try - { - aSizeInMM_100TH = m_xConversion.convertSizeToLogic(aSize, com.sun.star.util.MeasureUnit.MM_100TH); - System.out.println("Window size:"); - System.out.println("Width:" + aSizeInMM_100TH.Width + " 1/100mm"); - System.out.println("Height:" + aSizeInMM_100TH.Height + " 1/100mm"); - System.out.println(""); - - // try to get the size of the window in 1/10mm with the XUnitConversion method - - aSizeInMM_10TH = m_xConversion.convertSizeToLogic(aSize, com.sun.star.util.MeasureUnit.MM_10TH); - System.out.println("Window size:"); - System.out.println("Width:" + aSizeInMM_10TH.Width + " 1/10mm"); - System.out.println("Height:" + aSizeInMM_10TH.Height + " 1/10mm"); - System.out.println(""); - - // check the size with a delta which must be smaller a given difference - assertTrue("Size.Width not correct", delta(aSizeInMM_100TH.Width, aSizeInMM_10TH.Width * 10) < 10); - assertTrue("Size.Height not correct", delta(aSizeInMM_100TH.Height, aSizeInMM_10TH.Height * 10) < 10); - - // new - checkSize(aSize, com.sun.star.util.MeasureUnit.PIXEL, "pixel"); - checkSize(aSize, com.sun.star.util.MeasureUnit.APPFONT, "appfont"); - checkSize(aSize, com.sun.star.util.MeasureUnit.SYSFONT, "sysfont"); - - // simply check some more parameters - checkSize(aSize, com.sun.star.util.MeasureUnit.MM, "mm"); - checkSize(aSize, com.sun.star.util.MeasureUnit.CM, "cm"); - checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_1000TH, "1/1000inch"); - checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_100TH, "1/100inch"); - checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_10TH, "1/10inch"); - checkSize(aSize, com.sun.star.util.MeasureUnit.INCH, "inch"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.M, "m"); - checkSize(aSize, com.sun.star.util.MeasureUnit.POINT, "point"); - checkSize(aSize, com.sun.star.util.MeasureUnit.TWIP, "twip"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.KM, "km"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.PICA, "pica"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.FOOT, "foot"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.MILE, "mile"); - } - catch (com.sun.star.lang.IllegalArgumentException e) - { - fail("failed: IllegalArgumentException caught in convertSizeToLogic " + e.getMessage()); - } - - // convert the 1/100mm window size back to pixel - try - { - com.sun.star.awt.Size aNewSize = m_xConversion.convertSizeToPixel(aSizeInMM_100TH, com.sun.star.util.MeasureUnit.MM_100TH); - System.out.println("Window size:"); - System.out.println("Width:" + aNewSize.Width + " pixel"); - System.out.println("Height:" + aNewSize.Height + " pixel"); - - // assure the pixels are the same as we already know - assertTrue("failed: Size from pixel to 1/100mm to pixel", aSize.Width == aNewSize.Width && aSize.Height == aNewSize.Height); - } - catch (com.sun.star.lang.IllegalArgumentException e) - { - fail("failed: IllegalArgumentException caught in convertSizeToPixel " + e.getMessage()); - } - - // close the window. - // IMHO a little bit stupid, but the XWindow doesn't support a XCloseable interface - xWindow.dispose(); - } - - - - @BeforeClass public static void setUpConnection() throws Exception { - System.out.println("setUpConnection()"); - connection.setUp(); - } - - @AfterClass public static void tearDownConnection() - throws InterruptedException, com.sun.star.uno.Exception - { - System.out.println("tearDownConnection()"); - connection.tearDown(); - } - - private static final OfficeConnection connection = new OfficeConnection(); - -} |