Exemplo n.º 1
0
  @Override
  protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
    SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF());

    log.println("creating a textdocument");
    xTextDoc = SOF.createTextDoc(null);

    log.println("maximize the window size");
    XModel xModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
    XFrame xFrame = xModel.getCurrentController().getFrame();
    XWindow xWin = xFrame.getContainerWindow();

    Toolkit.getDefaultToolkit();
    Dimension dim = new Dimension(800, 600);

    Rectangle newPosSize = xWin.getPosSize();
    newPosSize.Width = new Double(dim.getWidth()).intValue();
    newPosSize.Height = new Double(dim.getHeight()).intValue();
    newPosSize.X = 0;
    newPosSize.Y = 0;

    xWin.setPosSize(
        newPosSize.X,
        newPosSize.Y,
        newPosSize.Width,
        newPosSize.Height,
        com.sun.star.awt.PosSize.POSSIZE);
  }
  /** Creates Spreadsheet document. */
  @Override
  protected void initialize(TestParameters tParam, PrintWriter log) throws Exception {
    SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF());

    log.println("creating a Spreadsheet document");
    xSheetDoc = SOF.createCalcDoc(null);
  }
Exemplo n.º 3
0
  /**
   * Retrieves all relations. If optional ones are not found creates their default values.
   *
   * <p>
   *
   * @throws StatusException If one of required relations not found.
   */
  public void before() {
    url = (String) tEnv.getObjRelation("FrameLoader.URL");
    frame = (XFrame) tEnv.getObjRelation("FrameLoader.Frame");

    if (frame == null) {
      SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) tParam.getMSF());

      try {
        log.println("creating a textdocument");
        frameSup = SOF.createTextDoc(null);

        Object oDsk =
            ((XMultiServiceFactory) tParam.getMSF()).createInstance("com.sun.star.frame.Desktop");
        XDesktop dsk = UnoRuntime.queryInterface(XDesktop.class, oDsk);

        shortWait();
        frame = dsk.getCurrentFrame();
      } catch (com.sun.star.uno.Exception e) {
        // Some exception occurs.FAILED
        e.printStackTrace(log);
        throw new StatusException("Couldn't create a frame.", e);
      }
    }

    Object args = tEnv.getObjRelation("FrameLoader.args");
    if (args != null) this.args = (PropertyValue[]) args;

    if (url == null /*|| frame == null*/) {
      throw new StatusException(Status.failed("Some relations not found"));
    }
  }
Exemplo n.º 4
0
  /** New text document created. */
  @Override
  protected void initialize(TestParameters tParam, PrintWriter log) throws Exception {

    // get a soffice factory object
    SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF());

    log.println("creating a chartdocument");
    xChartDoc = SOF.createChartDoc();
  }
Exemplo n.º 5
0
 /** Creates text document. */
 protected void initialize(TestParameters tParam, PrintWriter log) {
   SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) tParam.getMSF());
   try {
     log.println("creating a textdocument");
     xTextDoc = SOF.createTextDoc(null);
   } catch (com.sun.star.uno.Exception e) {
     e.printStackTrace(log);
     throw new StatusException("Couldn't create document", e);
   }
 }
  /** Creates Spreadsheet document. */
  protected void initialize(TestParameters tParam, PrintWriter log) {
    SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF());

    try {
      log.println("creating a Spreadsheet document");
      xSpreadsheetDoc = SOF.createCalcDoc(null);
    } catch (com.sun.star.uno.Exception e) {
      // Some exception occurs.FAILED
      e.printStackTrace(log);
      throw new StatusException("Couldn't create document", e);
    }
  }
  /** New spreadsheet document created. */
  protected void initialize(TestParameters tParam, PrintWriter log) {
    SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) tParam.getMSF());

    try {
      log.println("creating a Spreadsheet document");
      xSheetDoc = SOF.createCalcDoc(null);
      comp = UnoRuntime.queryInterface(XComponent.class, xSheetDoc);
    } catch (com.sun.star.uno.Exception e) {
      // Some exception occurs.FAILED
      e.printStackTrace(log);
      throw new StatusException("Couldn't create document", e);
    }
  }
Exemplo n.º 8
0
  // create a calc document with content, which needs some time for saving
  private XInterface createBigCalcDoc() {
    m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "createBigCalcDoc() started ...");
    try {
      m_aLog.log("Create empty calc document for testing.");
      XSpreadsheetDocument xSheetDoc = m_aSOF.createCalcDoc("_default");
      m_aLog.log("Retrieve first sheet from calc document.");
      XSpreadsheets xSheets = xSheetDoc.getSheets();
      XSpreadsheet xSheet =
          (XSpreadsheet)
              AnyConverter.toObject(
                  new Type(XSpreadsheet.class), xSheets.getByName(xSheets.getElementNames()[0]));
      m_aLog.log("Fill two cells with value and formula.");
      xSheet.getCellByPosition(0, 0).setValue(1);
      xSheet.getCellByPosition(0, 1).setFormula("=a1+1");
      m_aLog.log("Retrieve big range.");
      XCellRange xRange = xSheet.getCellRangeByName("A1:Z9999");
      XCellSeries xSeries = UnoRuntime.queryInterface(XCellSeries.class, xRange);
      m_aLog.log("Duplicate cells from top to bottom inside range.");
      xSeries.fillAuto(FillDirection.TO_BOTTOM, 2);
      m_aLog.log("Duplicate cells from left to right inside range.");
      xSeries.fillAuto(FillDirection.TO_RIGHT, 1);

      m_aLog.log(Protocol.TYPE_SCOPE_CLOSE | Protocol.TYPE_OK, "createBigCalcDoc() finished.");
      return xSheetDoc;
    } catch (Throwable ex) {
      m_aLog.log(ex);
    }

    m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "createBigCalcDoc() finished.");
    return null;
  }
  /**
   * creating a TestEnvironment for the interfaces to be tested
   *
   * @param tParam class which contains additional test parameters
   * @param log class to log the test state and result
   * @return Status class
   * @see TestParameters
   * @see PrintWriter
   */
  @Override
  protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {

    XInterface oObj = null;
    // create testobject here

    XEnumerationAccess xEA = null;
    try {
      SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF());
      XShape oShape = SOF.createShape(xDrawDoc, 5000, 3500, 7500, 5000, "Text");
      DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc, 0)).add(oShape);

      XSimpleText text = UnoRuntime.queryInterface(XSimpleText.class, oShape);

      XTextCursor cursor = text.createTextCursor();

      text.insertString(cursor, "Paragraph 1", false);
      text.insertControlCharacter(cursor, ControlCharacter.PARAGRAPH_BREAK, false);
      text.insertString(cursor, "Paragraph 2", false);
      text.insertControlCharacter(cursor, ControlCharacter.PARAGRAPH_BREAK, false);
      text.insertString(cursor, "Paragraph 3", false);
      text.insertControlCharacter(cursor, ControlCharacter.PARAGRAPH_BREAK, false);

      xEA = UnoRuntime.queryInterface(XEnumerationAccess.class, text);

      XInterface oTextContent =
          (XInterface)
              AnyConverter.toObject(
                  new Type(XInterface.class), xEA.createEnumeration().nextElement());

      xEA = UnoRuntime.queryInterface(XEnumerationAccess.class, oTextContent);

      oObj = xEA.createEnumeration();

    } catch (Exception e) {
      log.println("Can't create test object");
      e.printStackTrace(log);
    }

    // create test environment here
    TestEnvironment tEnv = new TestEnvironment(oObj);

    tEnv.addObjRelation("ENUM", xEA);

    return tEnv;
  } // finish method getTestEnvironment
Exemplo n.º 10
0
  /**
   * creates the member <CODE>m_xMSF</CODE> and <CODE>m_SOF</CODE>
   *
   * @short Create the environment for following tests.
   * @descr create an empty test frame, where we can load different components inside.
   */
  @Before
  public void before() {
    // create frame instance
    try {
      // get a soffice factory object
      m_SOF = SOfficeFactory.getFactory(getMSF());

    } catch (java.lang.Throwable ex) {
      fail("Could not create the XUserInputInterception instance.");
    }
  }
Exemplo n.º 11
0
  /**
   * creates a calc document and check the <CODE>XMouseClickHandler</CODE> and <CODE>XKeyHandler
   * </CODE>
   *
   * @see com.sun.star.awt.XKeyHandler
   * @see com.sun.star.awt.XMouseClickHandler
   */
  @Test
  public void checkCalcDocument() {

    XSpreadsheetDocument xDoc = null;

    try {
      xDoc = m_SOF.createCalcDoc("CalcTest");
    } catch (com.sun.star.uno.Exception e) {
      fail("Could not create a calc document: " + e.toString());
    }

    checkListener(xDoc);
    closeDoc(xDoc);
  }
Exemplo n.º 12
0
  /**
   * creates a draw document and check the <CODE>XMouseClickHandler</CODE> and <CODE>XKeyHandler
   * </CODE>
   *
   * @see com.sun.star.awt.XKeyHandler
   * @see com.sun.star.awt.XMouseClickHandler
   */
  @Test
  public void checkDrawDocument() {

    XComponent xDoc = null;

    try {
      xDoc = m_SOF.createDrawDoc("DrawTest");
    } catch (com.sun.star.uno.Exception e) {
      fail("Could not create a draw document: " + e.toString());
    }

    checkListener(xDoc);

    closeDoc(xDoc);
  }
Exemplo n.º 13
0
  /**
   * creates a text document and check the <CODE>XMouseClickHandler</CODE> and <CODE>XKeyHandler
   * </CODE>
   *
   * @see com.sun.star.awt.XKeyHandler
   * @see com.sun.star.awt.XMouseClickHandler
   */
  @Test
  public void checkTextDocument() {

    XTextDocument xDoc = null;

    try {
      xDoc = m_SOF.createTextDoc("WriterTest");
    } catch (com.sun.star.uno.Exception e) {
      fail("Could not create a text document: " + e.toString());
    }

    checkListener(xDoc);

    closeDoc(xDoc);
  }
Exemplo n.º 14
0
  /**
   * @short Create the environment for following tests.
   * @descr create an empty test frame, where we can load different components inside.
   */
  @Before
  public void before() {
    m_aLog =
        new Protocol(
            Protocol.MODE_HTML | Protocol.MODE_STDOUT,
            Protocol.FILTER_NONE,
            utils.getUsersTempDir() + "/complex_log_ascii_01.html");

    try {
      // get uno service manager from global test environment
      m_xSMGR = getMSF();

      // get another helper to e.g. create test documents
      m_aSOF = SOfficeFactory.getFactory(m_xSMGR);

      // create AutoSave instance
      m_xAutoSave = theAutoRecovery.get(connection.getComponentContext());

      // prepare AutoSave
      // make sure it will be started every 1 min
      ConfigHelper aConfig =
          new ConfigHelper(
              connection.getComponentContext(), "org.openoffice.Office.Recovery", false);
      aConfig.writeRelativeKey("AutoSave", "Enabled", Boolean.TRUE);
      aConfig.writeRelativeKey("AutoSave", "TimeIntervall", Integer.valueOf(1)); // 1 min
      aConfig.flush();
      aConfig = null;

      // is needed to parse dispatch commands
      m_xURLParser =
          UnoRuntime.queryInterface(
              XURLTransformer.class, m_xSMGR.createInstance("com.sun.star.util.URLTransformer"));

    } catch (java.lang.Throwable ex) {
      m_aLog.log(ex);
      fail("Couldn't create test environment");
    }
  }
Exemplo n.º 15
0
  /**
   * Called to create an instance of <code>TestEnvironment</code> with an object to test and related
   * objects. Subclasses should implement this method to provide the implementation and related
   * objects. The method is called from <code>getTestEnvironment()</code>.
   *
   * @param tParam test parameters
   * @param log writer to log information while testing
   * @see TestEnvironment
   * @see #getTestEnvironment
   */
  @Override
  protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log)
      throws Exception {

    log.println("creating a test environment");

    if (xTextDoc != null) {
      xTextDoc.dispose(); // get a soffice factory object
    }
    SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF());

    log.println("creating a text document");
    xTextDoc = SOF.createTextDoc(null);

    util.utils.waitForEventIdle(tParam.getMSF());

    XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc);

    XController secondController = aModel1.getCurrentController();

    XDispatchProvider aProv = UnoRuntime.queryInterface(XDispatchProvider.class, secondController);

    XDispatch getting = null;

    log.println("opening DatasourceBrowser");
    URL the_url = new URL();
    the_url.Complete = ".component:DB/DataSourceBrowser";
    getting = aProv.queryDispatch(the_url, "_beamer", 12);
    PropertyValue[] noArgs = new PropertyValue[0];
    getting.dispatch(the_url, noArgs);

    util.utils.waitForEventIdle(tParam.getMSF());

    XFrame the_frame1 = the_Desk.getCurrentFrame();

    if (the_frame1 == null) {
      log.println("Current frame was not found !!!");
    }

    XFrame the_frame2 = the_frame1.findFrame("_beamer", 4);

    the_frame2.setName("DatasourceBrowser");

    XInterface oObj = null;

    final XSelectionSupplier xSelect =
        UnoRuntime.queryInterface(XSelectionSupplier.class, the_frame2.getController());

    PropertyValue[] params =
        new PropertyValue[] {new PropertyValue(), new PropertyValue(), new PropertyValue()};
    params[0].Name = "DataSourceName";
    params[0].Value = "Bibliography";
    params[1].Name = "CommandType";
    params[1].Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE);
    params[2].Name = "Command";
    params[2].Value = "biblio";

    final PropertyValue[] fParams = params;

    util.utils.waitForEventIdle(tParam.getMSF());

    XWindow xWindow = secondController.getFrame().getContainerWindow();

    XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);

    AccessibilityTools.printAccessibleTree(
        log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));

    oObj =
        AccessibilityTools.getAccessibleObjectForRole(
            xRoot, AccessibleRole.PANEL, "", "AccessibleBrowseBox");

    log.println("ImplementationName: " + util.utils.getImplName(oObj));

    TestEnvironment tEnv = new TestEnvironment(oObj);

    tEnv.addObjRelation(
        "EventProducer",
        new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {

          public void fireEvent() {
            try {
              xSelect.select(fParams);
            } catch (com.sun.star.lang.IllegalArgumentException e) {
              e.printStackTrace();
            }
          }
        });

    return tEnv;
  }
  /**
   * Called to create an instance of <code>TestEnvironment</code> with an object to test and related
   * objects. Creates a frame and inserts it into document. Obtains accessible object for the
   * inserted text frame.
   *
   * @param Param test parameters
   * @param log writer to log information while testing
   * @see TestEnvironment
   * @see #getTestEnvironment
   */
  protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {

    XInterface oObj = null;
    XTextFrame oFrame1 = null;
    XPropertySet oPropSet = null;
    XText oText = null;
    XTextCursor oCursor = null;

    // get a soffice factory object
    SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) Param.getMSF());
    // creating Frames
    log.println("creating Frames");
    try {
      oFrame1 = SOfficeFactory.createTextFrame(xTextDoc, 500, 500);
      oPropSet = UnoRuntime.queryInterface(XPropertySet.class, oFrame1);
      oPropSet.setPropertyValue("AnchorType", TextContentAnchorType.AS_CHARACTER);
      oText = xTextDoc.getText();
      oCursor = oText.createTextCursor();

      log.println("inserting Frame1");
      XTextContent the_content = UnoRuntime.queryInterface(XTextContent.class, oFrame1);
      oText.insertTextContent(oCursor, the_content, true);
    } catch (Exception e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't insert TextFrame", e);
    }

    XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);

    AccessibilityTools at = new AccessibilityTools();

    XWindow xWindow =
        AccessibilityTools.getCurrentWindow((XMultiServiceFactory) Param.getMSF(), aModel);
    XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);

    oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT_FRAME);

    log.println("ImplementationName " + utils.getImplName(oObj));
    AccessibilityTools.printAccessibleTree(
        log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));

    TestEnvironment tEnv = new TestEnvironment(oObj);

    XController xController = xTextDoc.getCurrentController();
    XViewSettingsSupplier xViewSetSup =
        UnoRuntime.queryInterface(XViewSettingsSupplier.class, xController);

    final XPropertySet PropSet = xViewSetSup.getViewSettings();

    tEnv.addObjRelation(
        "EventProducer",
        new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
          public void fireEvent() {
            try {
              // change zoom value to 15%
              PropSet.setPropertyValue("ZoomValue", new Short("15"));
              // and back to 100%
              PropSet.setPropertyValue("ZoomValue", new Short("100"));
            } catch (com.sun.star.lang.WrappedTargetException e) {

            } catch (com.sun.star.lang.IllegalArgumentException e) {

            } catch (com.sun.star.beans.PropertyVetoException e) {

            } catch (com.sun.star.beans.UnknownPropertyException e) {

            }
          }
        });

    return tEnv;
  }