/**************************************************************
*
* 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 ifc.frame;
import lib.MultiMethodTest;
import com.sun.star.frame.XController;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.XModel;
import com.sun.star.util.XModifiable;
/**
* Testing com.sun.star.frame.XController
* interface methods:
*
getFrame()
attachFrame()
getModel()
attachModel()
getViewData()
restoreViewData()
suspend()
* This test needs the following object relations : *
'Frame'
(of type XFrame
):
* any other frame, used for tests'FirstModel'
(of type XModel
):
* model of a controller tested'SecondModel'
(of type XModel
):
* other model, used for tests 'HasViewData'
(of type Boolean
):
* (optional relation) if it exsists, so controller has no view data'SecondController'
(of type XController
):
* other controller, used for tests * Test is NOT multithread compilant.
* @see com.sun.star.frame.XController */ public class _XController extends MultiMethodTest { public XController oObj = null; public XModel firstModel = null; public XModel secondModel = null; public XFrame frame = null; public Object ViewData = null; /** * Test calls the method.
* Has OK status if the method returns object, that's equal to * previously obtained object relation 'Frame'. * The following method tests are to be completed successfully before: *
attachFrame()
: attachs frame obtained object
* relation 'Frame' */ public void _attachFrame() { frame = (XFrame) tEnv.getObjRelation("Frame"); oObj.attachFrame(frame); tRes.tested("attachFrame()", true); } /** * At first object relation 'FirstModel' is gotten. Then test calls the * method.
* Has OK status if string repersentation of an object, returned by * the method is equal to string representation of corresponding object * relation. */ public void _getModel() { firstModel = (XModel) tEnv.getObjRelation("FirstModel"); XModel getting = oObj.getModel(); String out1 = ""; String out2 = ""; if ( (firstModel == null) ) out1="none"; else out1 = firstModel.toString(); if ( (getting == null) ) out2="none"; else out2 = getting.toString(); boolean eq = out1.equals(out2); if ( !eq ) { log.println("Getting: " + out2); log.println("Expected: " + out1); } tRes.tested("getModel()", eq); } /** * At first, we obtain an object relation 'SecondModel'. Then test calls * the method and check result.
* Has OK status if method returns true and attached model is * equal to a model 'SecondModel' obtained before. *
* The following method tests are to be completed successfully before : *
getModel()
: returns model (XModel) of the
* XController object* Has OK status if obtained object relation is not null, or if * the method does not return null. */ public void _getViewData() { if (tEnv.getObjRelation("HasViewData") != null) { log.println("This Object has no View Data"); tRes.tested("getViewData()", true); return; } ViewData = oObj.getViewData(); tRes.tested( "getViewData()", ViewData != null ); } /** * If obtained object relation 'HasViewData' is null, test calls the method. *
Has OK status if obtained object relation is not null, or * if no exceptions were thrown while method call.
* The following method tests are to be completed successfully before : *
getViewData()
: gets view data of an object. * The following method tests are to be completed successfully before : *
restoreViewData()
: restores view status of an
* object