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_XModel" 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' Be sure that all variables are dimensioned:
38option explicit
39
40'*************************************************************************
41' This Interface/Service test depends on the following GLOBAL variables,
42' which must be specified in the object creation:
43
44'     - Global oXModelController as Object
45'     - Global oXModelSel as Object
46'     - Global oXModelToSel as Object
47
48'*************************************************************************
49
50
51
52
53
54
55Sub RunTest()
56
57'*************************************************************************
58' INTERFACE:
59' com.sun.star.frame.XModel
60'*************************************************************************
61On Error Goto ErrHndl
62    Dim bOK As Boolean
63
64    Dim oController As Object
65    Dim oSelection As Object
66    Dim aArgs(0 to 0) As Variant
67    Dim oCursor As Object
68    Dim cURL As String
69    Dim i As Integer
70	Dim args1(0) As New com.sun.star.beans.PropertyValue
71
72    Test.StartMethod("attachResource()")
73    args1(0).Name = "XModel"
74    bOK = oObj.attachResource(".component:DB/DataSourceBrowser", args1())
75    Test.MethodTested("attachResource()", bOK)
76
77    Test.StartMethod("getURL()")
78    bOK = true
79    cURL = oObj.getURL()
80    bOK = bOK AND (cURL = ".component:DB/DataSourceBrowser")
81    Test.MethodTested("getURL()", bOK)
82
83    Test.StartMethod("getArgs()")
84    bOK = true
85    aArgs() = oObj.Args
86    bOK = bOK AND NOT isNull(aArgs()) '(0).Name = "XModel"
87    Test.MethodTested("getArgs()", bOK)
88
89    Test.StartMethod("getCurrentController()")
90    bOK = true
91    Dim oCurrCtrl As Object
92    oCurrCtrl = oObj.getCurrentController()
93    bOK = bOK AND isObject(oCurrCtrl)
94    bOK = bOK AND hasUnoInterfaces(oCurrCtrl, "com.sun.star.frame.XController")
95    Test.MethodTested("getCurrentController()", bOK)
96
97    Test.StartMethod("getCurrentSelection()")
98    bOK = true
99    Dim oCurrSelection As Object
100    oXModelSel.select(oXModelToSel)
101    oCurrSelection = oObj.getCurrentSelection()
102    bOK = bOK AND hasUnoInterfaces(oCurrSelection, "com.sun.star.uno.XInterface")
103    Test.MethodTested("getCurrentSelection()", bOK)
104
105    Test.StartMethod("hasControllersLocked()")
106    bOK = true
107    ' there should no controllers be locked
108    bOK = bOK AND NOT oObj.hasControllersLocked()
109    Test.MethodTested("hasControllersLocked()", bOK)
110
111    ' now lock controllers
112    Test.StartMethod("lockControllers()")
113    bOK = true
114    oObj.lockControllers()
115    ' controllers should be locked
116    bOK = bOK AND oObj.hasControllersLocked()
117    Test.MethodTested("lockControllers()", bOK)
118
119    ' unlock controllers and check success
120    Test.StartMethod("unlockControllers()")
121    bOK = true
122    oObj.unlockControllers()
123    bOK = bOK AND NOT oObj.hasControllersLocked()
124    Test.MethodTested("unlockControllers()", bOK)
125
126    Test.StartMethod("connectController()")
127    oObj.connectController(oXModelController)
128    Test.MethodTested("connectController()", bOK)
129
130    Test.StartMethod("disconnectController()")
131    oObj.disconnectController(oXModelController)
132    oObj.connectController(oCurrCtrl)
133    Test.MethodTested("disconnectController()", bOK)
134
135    Test.StartMethod("setCurrentController()")
136    oObj.setCurrentController(oCurrCtrl)
137    Test.MethodTested("setCurrentController()", bOK)
138
139
140Exit Sub
141ErrHndl:
142    Test.Exception()
143    bOK = false
144    resume next
145End Sub
146</script:module>
147