}
@Test public void checkWriter() {
System.out.println("-- Checking Writer --");
WriterHelper wHelper = new WriterHelper(m_xMSF);
String[] expected;
System.out.println("opening an empty writer doc");
notifyEvents.clear();
{
XTextDocument xTextDoc = wHelper.openEmptyDoc();
shortWait();
expected = new String[] { "OnUnfocus", "OnCreate", "OnViewCreated", "OnFocus" };
assertTrue("Wrong events fired when opening empty doc",
proveExpectation(expected));
System.out.println("... done");
System.out.println("changing the writer doc");
notifyEvents.clear();
xTextDoc.getText().setString("GlobalEventBroadcaster");
shortWait();
expected = new String[] { "OnModifyChanged" };
assertTrue("Wrong events fired when changing doc",
proveExpectation(expected));
System.out.println("... done");
System.out.println("closing the empty writer doc");
notifyEvents.clear();
wHelper.closeDoc(xTextDoc);
shortWait();
}
expected = new String[] { "OnUnfocus", "OnFocus", "OnViewClosed", "OnUnload" };
assertTrue("Wrong events fired when closing empty doc",
proveExpectation(expected));
System.out.println("... done");
System.out.println("opening an writer doc via Window-New Window");
notifyEvents.clear();
{
XTextDocument xTextDoc = wHelper.openFromDialog(".uno:NewWindow", "", false);
shortWait();
expected = new String[] { "OnUnfocus", "OnCreate", "OnViewCreated", "OnFocus", "OnUnfocus", "OnViewCreated", "OnFocus", };
assertTrue("Wrong events fired when opening an writer doc via Window-New Window",
proveExpectation(expected));
System.out.println("... done");
System.out.println("closing the created writer doc");
notifyEvents.clear();
wHelper.closeDoc(xTextDoc);
shortWait();
}
expected = new String[] { "OnViewClosed", "OnUnfocus", "OnFocus", "OnViewClosed", "OnUnload" };
assertTrue("Wrong events fired when closing Window-New Window",
proveExpectation(expected));
System.out.println("... done");
// TODO: It seems not possible to close the document without interactiv question
// there the follow test will not be execute
if (false) {
System.out.println("Opening document with label wizard");
XTextDocument xTextDoc = wHelper.openFromDialog("private:factory/swriter?slot=21051", "", false);
shortWait();
XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, wHelper.getToolkit().getActiveTopWindow());
UITools ut = new UITools(m_xMSF,xWindow);
notifyEvents.clear();
System.out.println("pressing button 'New Document'");
try{
ut.clickButton ("New Document");
} catch (Exception e) {
System.out.println("Couldn't press Button");
}
System.out.println("... done");
shortWait();
shortWait();
shortWait();
expected = new String[] { "OnViewClosed", "OnCreate", "OnFocus", "OnModifyChanged" };
assertTrue("Wrong events fired when starting labels wizard",
proveExpectation(expected));
System.out.println("Try to close document...");
wHelper.closeDoc(xTextDoc);
shortWait();
wHelper.closeFromDialog();
shortWait();
xTextDoc = null;
}
System.out.println("-- Done Writer --");