Kaydet (Commit) 87e2b468 authored tarafından Liu Zhe's avatar Liu Zhe

fix two test class have errors when running

üst c312cc6e
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
<booleanAttribute key="org.eclipse.ant.uiSET_INPUTHANDLER" value="false"/> <booleanAttribute key="org.eclipse.ant.uiSET_INPUTHANDLER" value="false"/>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/> <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/testuno"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/> <booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/> <booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
......
package testcase.uno; package testcase.mix;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.uno.UnoApp; import org.openoffice.test.uno.UnoApp;
import org.openoffice.test.vcl.widgets.VclApp;
import org.openoffice.test.vcl.widgets.VclListBox; import org.openoffice.test.vcl.widgets.VclListBox;
import org.openoffice.test.vcl.widgets.VclTabPage; import org.openoffice.test.vcl.widgets.VclTabPage;
import org.openoffice.test.vcl.widgets.VclWindow; import org.openoffice.test.vcl.widgets.VclWindow;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.text.XText; import com.sun.star.text.XText;
import com.sun.star.text.XTextCursor; import com.sun.star.text.XTextCursor;
import com.sun.star.text.XTextDocument; import com.sun.star.text.XTextDocument;
...@@ -24,6 +23,7 @@ import com.sun.star.uno.UnoRuntime; ...@@ -24,6 +23,7 @@ import com.sun.star.uno.UnoRuntime;
*/ */
public class MixedTest { public class MixedTest {
UnoApp unoApp = new UnoApp(); UnoApp unoApp = new UnoApp();
VclApp vclApp = new VclApp();
VclWindow writer = new VclWindow("SW_HID_EDIT_WIN"); VclWindow writer = new VclWindow("SW_HID_EDIT_WIN");
VclTabPage effectsPage = new VclTabPage("CUI_HID_SVXPAGE_CHAR_EFFECTS"); VclTabPage effectsPage = new VclTabPage("CUI_HID_SVXPAGE_CHAR_EFFECTS");
VclListBox colorList = new VclListBox("cui:ListBox:RID_SVXPAGE_CHAR_EFFECTS:LB_FONTCOLOR"); VclListBox colorList = new VclListBox("cui:ListBox:RID_SVXPAGE_CHAR_EFFECTS:LB_FONTCOLOR");
......
...@@ -25,7 +25,7 @@ import org.openoffice.test.common.FileUtil; ...@@ -25,7 +25,7 @@ import org.openoffice.test.common.FileUtil;
import org.openoffice.test.common.Testspace; import org.openoffice.test.common.Testspace;
import org.openoffice.test.uno.UnoApp; import org.openoffice.test.uno.UnoApp;
import testlib.uno.SDUnoUtil; import testlib.uno.SDUtil;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
...@@ -48,7 +48,7 @@ import com.sun.star.uno.UnoRuntime; ...@@ -48,7 +48,7 @@ import com.sun.star.uno.UnoRuntime;
public class CheckCharacterStyle { public class CheckCharacterStyle {
private static final UnoApp app = new UnoApp(); private static final UnoApp app = new UnoApp();
private static final SDUnoUtil SDUtil = new SDUnoUtil(); private static final SDUtil SDUtil = new SDUtil();
private XComponent m_xSDComponent = null; private XComponent m_xSDComponent = null;
private XText xShapeText = null; private XText xShapeText = null;
private String filePath = null; private String filePath = null;
......
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
package testcase.uno.sw;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Collection;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openoffice.test.common.Testspace;
import org.openoffice.test.uno.UnoApp;
import com.sun.star.text.XTextDocument;
import com.sun.star.uno.UnoRuntime;
public class CheckFlies {
@Test
public void checkFlies() throws Exception {
com.sun.star.text.XTextFramesSupplier xTFS = (com.sun.star.text.XTextFramesSupplier) UnoRuntime.queryInterface(
com.sun.star.text.XTextFramesSupplier.class, document);
checkTextFrames(xTFS);
com.sun.star.text.XTextGraphicObjectsSupplier xTGOS = (com.sun.star.text.XTextGraphicObjectsSupplier) UnoRuntime.queryInterface(
com.sun.star.text.XTextGraphicObjectsSupplier.class, document);
checkGraphicFrames(xTGOS);
com.sun.star.text.XTextEmbeddedObjectsSupplier xTEOS = (com.sun.star.text.XTextEmbeddedObjectsSupplier) UnoRuntime.queryInterface(
com.sun.star.text.XTextEmbeddedObjectsSupplier.class, document);
checkEmbeddedFrames(xTEOS);
}
private void checkEmbeddedFrames(com.sun.star.text.XTextEmbeddedObjectsSupplier xTGOS) throws Exception {
Collection<String> vExpectedEmbeddedFrames = new ArrayList<String>();
vExpectedEmbeddedFrames.add("Object1");
int nEmbeddedFrames = vExpectedEmbeddedFrames.size();
com.sun.star.container.XNameAccess xEmbeddedFrames = xTGOS.getEmbeddedObjects();
for (String sFrameName : xEmbeddedFrames.getElementNames()) {
assertTrue("Unexpected frame name", vExpectedEmbeddedFrames.remove(sFrameName));
xEmbeddedFrames.getByName(sFrameName);
assertTrue("Could not find embedded frame by name.", xEmbeddedFrames.hasByName(sFrameName));
}
assertTrue("Missing expected embedded frames.", vExpectedEmbeddedFrames.isEmpty());
try {
xEmbeddedFrames.getByName("Nonexisting embedded frame");
fail("Got nonexisting embedded frame");
} catch (com.sun.star.container.NoSuchElementException e) {
}
assertFalse("Has nonexisting embedded frame", xEmbeddedFrames.hasByName("Nonexisting embedded frame"));
com.sun.star.container.XIndexAccess xEmbeddedFramesIdx = (com.sun.star.container.XIndexAccess) UnoRuntime.queryInterface(
com.sun.star.container.XIndexAccess.class, xEmbeddedFrames);
assertEquals("Unexpected number of embedded frames reported.", nEmbeddedFrames, xEmbeddedFramesIdx.getCount());
for (int nCurrentFrameIdx = 0; nCurrentFrameIdx < xEmbeddedFramesIdx.getCount(); nCurrentFrameIdx++) {
xEmbeddedFramesIdx.getByIndex(nCurrentFrameIdx);
}
}
private void checkGraphicFrames(com.sun.star.text.XTextGraphicObjectsSupplier xTGOS) throws Exception {
Collection<String> vExpectedGraphicFrames = new ArrayList<String>();
vExpectedGraphicFrames.add("graphics1");
int nGraphicFrames = vExpectedGraphicFrames.size();
com.sun.star.container.XNameAccess xGraphicFrames = xTGOS.getGraphicObjects();
for (String sFrameName : xGraphicFrames.getElementNames()) {
assertTrue("Unexpected frame name", vExpectedGraphicFrames.remove(sFrameName));
xGraphicFrames.getByName(sFrameName);
assertTrue("Could not find graphics frame by name.", xGraphicFrames.hasByName(sFrameName));
}
assertTrue("Missing expected graphics frames.", vExpectedGraphicFrames.isEmpty());
try {
xGraphicFrames.getByName("Nonexisting graphics frame");
fail("Got nonexisting graphics frame");
} catch (com.sun.star.container.NoSuchElementException e) {
}
assertFalse("Has nonexisting graphics frame", xGraphicFrames.hasByName("Nonexisting graphics frame"));
com.sun.star.container.XIndexAccess xGraphicFramesIdx = (com.sun.star.container.XIndexAccess) UnoRuntime.queryInterface(
com.sun.star.container.XIndexAccess.class, xGraphicFrames);
assertEquals("Unexpected number of graphics frames reported.", nGraphicFrames, xGraphicFramesIdx.getCount());
for (int nCurrentFrameIdx = 0; nCurrentFrameIdx < xGraphicFramesIdx.getCount(); nCurrentFrameIdx++) {
xGraphicFramesIdx.getByIndex(nCurrentFrameIdx);
}
}
private void checkTextFrames(com.sun.star.text.XTextFramesSupplier xTFS) throws Exception {
Collection<String> vExpectedTextFrames = new ArrayList<String>();
vExpectedTextFrames.add("Frame1");
vExpectedTextFrames.add("Frame2");
int nTextFrames = vExpectedTextFrames.size();
com.sun.star.container.XNameAccess xTextFrames = xTFS.getTextFrames();
for (String sFrameName : xTextFrames.getElementNames()) {
assertTrue("Unexpected frame name", vExpectedTextFrames.remove(sFrameName));
xTextFrames.getByName(sFrameName);
assertTrue("Could not find text frame by name.", xTextFrames.hasByName(sFrameName));
}
assertTrue("Missing expected text frames.", vExpectedTextFrames.isEmpty());
try {
xTextFrames.getByName("Nonexisting Textframe");
fail("Got nonexisting text frame.");
} catch (com.sun.star.container.NoSuchElementException e) {
}
assertFalse("Has nonexisting text frame.", xTextFrames.hasByName("Nonexisting text frame"));
com.sun.star.container.XIndexAccess xTextFramesIdx = (com.sun.star.container.XIndexAccess) UnoRuntime.queryInterface(
com.sun.star.container.XIndexAccess.class, xTextFrames);
assertEquals("Unexpected number of text frames reported.", nTextFrames, xTextFramesIdx.getCount());
for (int nCurrentFrameIdx = 0; nCurrentFrameIdx < xTextFramesIdx.getCount(); nCurrentFrameIdx++) {
xTextFramesIdx.getByIndex(nCurrentFrameIdx);
}
}
@Before
public void setUpDocument() throws Exception {
document = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.prepareData("testcase/uno/sw/CheckFlies.odt")));
}
@After
public void tearDownDocument() {
app.closeDocument(document);
}
private XTextDocument document = null;
@BeforeClass
public static void setUpConnection() throws Exception {
app.start();
}
@AfterClass
public static void tearDownConnection() throws InterruptedException, Exception {
app.close();
}
private static final UnoApp app = new UnoApp();
}
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
package testcase.uno.sw.bookmark; package testcase.uno.sw.bookmark;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static testlib.uno.sw.SWUtil.insertBookmark; import static testlib.uno.SWUtil.insertBookmark;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
...@@ -106,7 +106,7 @@ public class CheckBookmarks { ...@@ -106,7 +106,7 @@ public class CheckBookmarks {
XTextCursor xTextCursor = xText.createTextCursor(); XTextCursor xTextCursor = xText.createTextCursor();
xTextCursor.gotoEnd(false); xTextCursor.gotoEnd(false);
xTextCursor.goLeft((short)10, true); xTextCursor.goLeft((short)10, true);
xTextCursor.setString(""); xTextCursor.setString("new");
// Let's see the bookmarks // Let's see the bookmarks
XNameAccess xBookmarks = UnoRuntime.queryInterface(XBookmarksSupplier.class, document).getBookmarks(); XNameAccess xBookmarks = UnoRuntime.queryInterface(XBookmarksSupplier.class, document).getBookmarks();
......
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
package testcase.uno.sw.frame;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.openoffice.test.common.Testspace;
import org.openoffice.test.uno.UnoApp;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XNameAccess;
import com.sun.star.text.XTextDocument;
import com.sun.star.text.XTextFrame;
import com.sun.star.text.XTextFramesSupplier;
import com.sun.star.uno.UnoRuntime;
public class CheckFrames {
private static final UnoApp app = new UnoApp();
private XTextDocument document = null;
@Test(expected = NoSuchElementException.class)
public void testLoadTextFrame() throws Exception {
document = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.prepareData("testcase/uno/sw/CheckFlies.odt")));
XTextFramesSupplier xTFS = UnoRuntime.queryInterface(XTextFramesSupplier.class, document);
String[] expectedNames = { "Frame1", "Frame2" };
String[] expectedContents = { "PageBoundFrame", "ParaBoundFrame" };
XNameAccess xTextFrames = xTFS.getTextFrames();
assertArrayEquals("Text frame names", expectedNames, xTextFrames.getElementNames());
assertTrue("Has text frame named Frame1", xTextFrames.hasByName(expectedNames[0]));
assertFalse("Has nonexisting text frame.", xTextFrames.hasByName("Nonexisting text frame"));
XIndexAccess xTextFramesIdx = UnoRuntime.queryInterface(XIndexAccess.class, xTextFrames);
assertEquals("Text frame count", expectedNames.length, xTextFramesIdx.getCount());
String[] contents = new String[expectedNames.length];
for (int i = 0; i < xTextFramesIdx.getCount(); i++) {
Object obj = xTextFramesIdx.getByIndex(i);
XTextFrame frame = UnoRuntime.queryInterface(XTextFrame.class, obj);
contents[i] = frame.getText().getString();
}
assertArrayEquals("Text frame contents", expectedContents, contents);
xTextFrames.getByName("Nonexisting Textframe");
}
@Before
public void setUp() throws Exception {
app.start();
}
@After
public void tearDown() {
app.closeDocument(document);
}
@AfterClass
public static void tearDownConnection() throws InterruptedException, Exception {
app.close();
}
}
...@@ -17,14 +17,14 @@ import com.sun.star.uno.UnoRuntime; ...@@ -17,14 +17,14 @@ import com.sun.star.uno.UnoRuntime;
* *
* *
*/ */
public class SDUnoUtil { public class SDUtil {
/** /**
* @throws WrappedTargetException * @throws WrappedTargetException
* @throws * @throws
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
public SDUnoUtil(){ public SDUtil(){
} }
......
package testlib.uno.sw; package testlib.uno;
import org.openoffice.test.uno.UnoApp; import org.openoffice.test.uno.UnoApp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment