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' This Interface/Service test depends on the following GLOBAL variables,
38' which must be specified in the object creation:
39
40'     - Global oFrameToAttach As Object
41'     - Global oModelToAttach As Object
42'     - Global bHasNoViewData As Boolean
43'     - Global oObjToSuspend As Object
44'     - Global bHasNoModel As Boolean
45
46'*************************************************************************
47
48
49
50
51
52Sub RunTest()
53
54'*************************************************************************
55' INTERFACE:
56' com.sun.star.frame.XController
57'*************************************************************************
58On Error Goto ErrHndl
59    Dim bOK As Boolean
60
61    Test.StartMethod("getViewData()")
62    bOK = true
63    if (bHasNoViewData) then
64    	Out.Log("This object has no ViewData - nothing to test")
65    else
66    	oViewData = oObj.getViewData()
67    	bOK = bOK AND NOT isNULL(oViewData)
68    end if
69    Test.MethodTested("getViewData()", bOK)
70
71    Test.StartMethod("restoreViewData()")
72    bOK = true
73    if (bHasNoViewData) then
74    	Out.Log("This object has no ViewData - nothing to test")
75    else
76	    oObj.restoreViewData(oViewData)
77    end if
78    Test.MethodTested("restoreViewData()", bOK)
79
80    Test.StartMethod("getFrame()")
81    bOK = true
82    oFrame = oObj.getFrame()
83    bOK = bOK AND hasUnoInterfaces(oFrame, "com.sun.star.frame.XFrame")
84    Test.MethodTested("getFrame()", bOK)
85
86    Test.StartMethod("getModel()")
87    bOK = true
88    oModel = oObj.getModel()
89    if (bHasNoModel) then
90        bOK = bOK AND isNull(oModel)
91        Out.Log("The object has no Model. Retunrned value must be NULL")
92    else
93        bOK = bOK AND NOT isNull(oModel) AND hasUnoInterfaces(oModel, "com.sun.star.frame.XModel")
94    end if
95    Test.MethodTested("getModel()", bOK)
96
97    Test.StartMethod("attachFrame()")
98    bOK = true
99    Dim attachedFrame As Object
100    attachedFrame = oObj.getFrame()
101    oFrameToAttach.Name = "XController"
102    oObj.attachFrame(oFrameToAttach)
103    bOK = bOK AND oObj.getFrame.Name = oFrameToAttach.Name
104    ' return previous frame.
105    oObj.attachFrame(attachedFrame)
106    Test.MethodTested("attachFrame()", bOK)
107
108    Test.StartMethod("attachModel()")
109    bOK = true
110    if bHasNoModel then
111        Out.Log("The object has no Model. Nothing to test.")
112    else
113        oObj.attachModel(oModelToAttach)
114        if isNull(oObj.getModel()) then
115           Out.Log("The model is NULL after setModel() call")
116           bOK = false
117        else
118            bOK = bOK AND oModelToAttach.location = oObj.getModel.location
119        end if
120    end if
121    Test.MethodTested("attachModel()", bOK)
122
123    Test.StartMethod("suspend()")
124    bOK = true
125    bOK = bOK AND oObjToSuspend.suspend(true)
126    Test.MethodTested("suspend()", bOK)
127
128Exit Sub
129ErrHndl:
130    Test.Exception()
131    bOK = false
132    resume next
133End Sub
134</script:module>
135