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