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