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' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32*****
33'*************************************************************************
34
35
36
37'*************************************************************************
38' This Interface/Service test depends on the following GLOBAL variables,
39' which must be specified in the object creation:
40
41'     - Global oFrameToAttach As Object
42'     - Global oModelToAttach As Object
43'     - Global bHasNoViewData As Boolean
44'     - Global oObjToSuspend As Object
45'     - Global bHasNoModel As Boolean
46
47'*************************************************************************
48
49
50
51
52
53Sub RunTest()
54
55'*************************************************************************
56' INTERFACE:
57' com.sun.star.frame.XController
58'*************************************************************************
59On Error Goto ErrHndl
60    Dim bOK As Boolean
61
62    Test.StartMethod("getViewData()")
63    bOK = true
64    if (bHasNoViewData) then
65    	Out.Log("This object has no ViewData - nothing to test")
66    else
67    	oViewData = oObj.getViewData()
68    	bOK = bOK AND NOT isNULL(oViewData)
69    end if
70    Test.MethodTested("getViewData()", bOK)
71
72    Test.StartMethod("restoreViewData()")
73    bOK = true
74    if (bHasNoViewData) then
75    	Out.Log("This object has no ViewData - nothing to test")
76    else
77	    oObj.restoreViewData(oViewData)
78    end if
79    Test.MethodTested("restoreViewData()", bOK)
80
81    Test.StartMethod("getFrame()")
82    bOK = true
83    oFrame = oObj.getFrame()
84    bOK = bOK AND hasUnoInterfaces(oFrame, "com.sun.star.frame.XFrame")
85    Test.MethodTested("getFrame()", bOK)
86
87    Test.StartMethod("getModel()")
88    bOK = true
89    oModel = oObj.getModel()
90    if (bHasNoModel) then
91        bOK = bOK AND isNull(oModel)
92        Out.Log("The object has no Model. Retunrned value must be NULL")
93    else
94        bOK = bOK AND NOT isNull(oModel) AND hasUnoInterfaces(oModel, "com.sun.star.frame.XModel")
95    end if
96    Test.MethodTested("getModel()", bOK)
97
98    Test.StartMethod("attachFrame()")
99    bOK = true
100    Dim attachedFrame As Object
101    attachedFrame = oObj.getFrame()
102    oFrameToAttach.Name = "XController"
103    oObj.attachFrame(oFrameToAttach)
104    bOK = bOK AND oObj.getFrame.Name = oFrameToAttach.Name
105    ' return previous frame.
106    oObj.attachFrame(attachedFrame)
107    Test.MethodTested("attachFrame()", bOK)
108
109    Test.StartMethod("attachModel()")
110    bOK = true
111    if bHasNoModel then
112        Out.Log("The object has no Model. Nothing to test.")
113    else
114        oObj.attachModel(oModelToAttach)
115        if isNull(oObj.getModel()) then
116           Out.Log("The model is NULL after setModel() call")
117           bOK = false
118        else
119            bOK = bOK AND oModelToAttach.location = oObj.getModel.location
120        end if
121    end if
122    Test.MethodTested("attachModel()", bOK)
123
124    Test.StartMethod("suspend()")
125    bOK = true
126    bOK = bOK AND oObjToSuspend.suspend(true)
127    Test.MethodTested("suspend()", bOK)
128
129Exit Sub
130ErrHndl:
131    Test.Exception()
132    bOK = false
133    resume next
134End Sub
135</script:module>
136