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