1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="frame_XController" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31'*************************************************************************
32' This Interface/Service test depends on the following GLOBAL variables,
33' which must be specified in the object creation:
34
35'     - Global oFrameToAttach As Object
36'     - Global oModelToAttach As Object
37'     - Global bHasNoViewData As Boolean
38'     - Global oObjToSuspend As Object
39'     - Global bHasNoModel As Boolean
40
41'*************************************************************************
42
43
44
45
46
47Sub RunTest()
48
49'*************************************************************************
50' INTERFACE:
51' com.sun.star.frame.XController
52'*************************************************************************
53On Error Goto ErrHndl
54    Dim bOK As Boolean
55
56    Test.StartMethod("getViewData()")
57    bOK = true
58    if (bHasNoViewData) then
59    	Out.Log("This object has no ViewData - nothing to test")
60    else
61    	oViewData = oObj.getViewData()
62    	bOK = bOK AND NOT isNULL(oViewData)
63    end if
64    Test.MethodTested("getViewData()", bOK)
65
66    Test.StartMethod("restoreViewData()")
67    bOK = true
68    if (bHasNoViewData) then
69    	Out.Log("This object has no ViewData - nothing to test")
70    else
71	    oObj.restoreViewData(oViewData)
72    end if
73    Test.MethodTested("restoreViewData()", bOK)
74
75    Test.StartMethod("getFrame()")
76    bOK = true
77    oFrame = oObj.getFrame()
78    bOK = bOK AND hasUnoInterfaces(oFrame, "com.sun.star.frame.XFrame")
79    Test.MethodTested("getFrame()", bOK)
80
81    Test.StartMethod("getModel()")
82    bOK = true
83    oModel = oObj.getModel()
84    if (bHasNoModel) then
85        bOK = bOK AND isNull(oModel)
86        Out.Log("The object has no Model. Retunrned value must be NULL")
87    else
88        bOK = bOK AND NOT isNull(oModel) AND hasUnoInterfaces(oModel, "com.sun.star.frame.XModel")
89    end if
90    Test.MethodTested("getModel()", bOK)
91
92    Test.StartMethod("attachFrame()")
93    bOK = true
94    Dim attachedFrame As Object
95    attachedFrame = oObj.getFrame()
96    oFrameToAttach.Name = "XController"
97    oObj.attachFrame(oFrameToAttach)
98    bOK = bOK AND oObj.getFrame.Name = oFrameToAttach.Name
99    ' return previous frame.
100    oObj.attachFrame(attachedFrame)
101    Test.MethodTested("attachFrame()", bOK)
102
103    Test.StartMethod("attachModel()")
104    bOK = true
105    if bHasNoModel then
106        Out.Log("The object has no Model. Nothing to test.")
107    else
108        oObj.attachModel(oModelToAttach)
109        if isNull(oObj.getModel()) then
110           Out.Log("The model is NULL after setModel() call")
111           bOK = false
112        else
113            bOK = bOK AND oModelToAttach.location = oObj.getModel.location
114        end if
115    end if
116    Test.MethodTested("attachModel()", bOK)
117
118    Test.StartMethod("suspend()")
119    bOK = true
120    bOK = bOK AND oObjToSuspend.suspend(true)
121    Test.MethodTested("suspend()", bOK)
122
123Exit Sub
124ErrHndl:
125    Test.Exception()
126    bOK = false
127    resume next
128End Sub
129</script:module>
130