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="registry_XSimpleRegistry" 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
36Sub RunTest()
37
38'*************************************************************************
39' INTERFACE:
40' com.sun.star.registry.XSimpleRegistry
41'*************************************************************************
42On Error Goto ErrHndl
43    Dim bOK As Boolean
44    Dim cURL As String
45    Dim cTempURL As String
46    Dim oTempReg As Object
47    Dim oRoot As Object
48    Dim oKey As Object
49    Dim oKey2 As Object
50
51    cURL = utils.getTempFileURL("BASReg.rdb", true)
52
53    Test.StartMethod("open()")
54    bOK = true
55    if (cObjectName &lt;&gt; "defreg.NestedRegistry") then
56        oObj.open(cURL, false, true)
57        bOK = bOK AND FileExists(cURL)
58    end if
59    Test.MethodTested("open()", bOK)
60
61    Test.StartMethod("isValid()")
62    bOK = true
63    bOK = bOK AND oObj.isValid()
64    Test.MethodTested("isValid()", bOK)
65
66    Test.StartMethod("getRootKey()")
67    bOK = true
68    oKey = oObj.getRootKey()
69    bOK = bOK AND hasUnoInterfaces(oKey, "com.sun.star.registry.XRegistryKey")
70    Test.MethodTested("getRootKey()", bOK)
71
72    Test.StartMethod("isReadOnly()")
73    bOK = true
74    bOK = bOK AND NOT oObj.isReadOnly()
75    Test.MethodTested("isReadOnly()", bOK)
76
77    Test.StartMethod("mergeKey()")
78    bOK = true
79
80    oKey.createKey("Key1").setStringValue("Value of Key1")
81
82    cTempURL = utils.getTempFileURL("BASRegTemp.rdb", true)
83    oTempReg = createUnoService("com.sun.star.registry.SimpleRegistry")
84    oTempReg.open(cTempURL, false, true)
85    oKey2 = oTempReg.getRootKey()
86    oKey2.createKey("Key2").setStringValue("Value of Key2")
87
88    oObj.mergeKey("/", cTempURL)
89
90    oRoot = oObj.RootKey
91    oKey = oRoot.openKey("Key1")
92    bOK = bOK AND oKey.getStringValue = "Value of Key1"
93    oKey = oRoot.openKey("Key2")
94    bOK = bOK AND oKey.getStringValue = "Value of Key2"
95    oTempReg.close()
96
97    Test.MethodTested("mergeKey()", bOK)
98
99    Test.StartMethod("getURL()")
100    bOK = true
101    Out.Log("Returned URL is " &amp; oObj.URL)
102    bOK = bOK AND inStr(1, oObj.URL, ".rdb") &gt; 0
103    Test.MethodTested("getURL()", bOK)
104
105    Test.StartMethod("destroy()")
106    bOK = true
107    if (cObjectName &lt;&gt; "defreg.NestedRegistry") then
108        oObj.open(cURL, false, true)
109        oObj.destroy()
110    end if
111    Test.MethodTested("destroy()", bOK)
112
113    Test.StartMethod("close()")
114    bOK = true
115    if (cObjectName &lt;&gt; "defreg.NestedRegistry") then
116        oObj.open(cURL, false, true)
117        oObj.close()
118    end if
119    Test.MethodTested("close()", bOK)
120
121Exit Sub
122ErrHndl:
123    Test.Exception()
124    bOK = false
125    resume next
126End Sub
127</script:module>
128