1*51134e9eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*51134e9eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*51134e9eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*51134e9eSAndrew Rist * distributed with this work for additional information 6*51134e9eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*51134e9eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*51134e9eSAndrew Rist * "License"); you may not use this file except in compliance 9*51134e9eSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*51134e9eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*51134e9eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*51134e9eSAndrew Rist * software distributed under the License is distributed on an 15*51134e9eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*51134e9eSAndrew Rist * KIND, either express or implied. See the License for the 17*51134e9eSAndrew Rist * specific language governing permissions and limitations 18*51134e9eSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*51134e9eSAndrew Rist *************************************************************/ 21*51134e9eSAndrew Rist 22*51134e9eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_registry.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <iostream> 28cdf0e10cSrcweir #include <stdio.h> 29cdf0e10cSrcweir #include <string.h> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "registry/registry.hxx" 32cdf0e10cSrcweir #include "registry/reflread.hxx" 33cdf0e10cSrcweir #include "registry/reflwrit.hxx" 34cdf0e10cSrcweir #include "regdiagnose.h" 35cdf0e10cSrcweir #include <rtl/alloc.h> 36cdf0e10cSrcweir #include <rtl/ustring.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir using namespace std; 39cdf0e10cSrcweir using namespace rtl; 40cdf0e10cSrcweir 41cdf0e10cSrcweir void test_coreReflection() 42cdf0e10cSrcweir { 43cdf0e10cSrcweir Registry *myRegistry = new Registry(); 44cdf0e10cSrcweir 45cdf0e10cSrcweir RegistryKey rootKey, key1, key2, key3, key4 ,key5, key6, key7, key8; 46cdf0e10cSrcweir 47cdf0e10cSrcweir REG_ENSURE(!myRegistry->create(OUString::createFromAscii("ucrtest.rdb")), "testCoreReflection error 1"); 48cdf0e10cSrcweir REG_ENSURE(!myRegistry->openRootKey(rootKey), "testCoreReflection error 2"); 49cdf0e10cSrcweir 50cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("UCR"), key1), "testCoreReflection error 3"); 51cdf0e10cSrcweir REG_ENSURE(!key1.createKey(OUString::createFromAscii("ModuleA"), key2), "testCoreReflection error 4"); 52cdf0e10cSrcweir REG_ENSURE(!key2.createKey(OUString::createFromAscii("StructA"), key3), "testCoreReflection error 5"); 53cdf0e10cSrcweir REG_ENSURE(!key2.createKey(OUString::createFromAscii("EnumA"), key4), "testCoreReflection error 6"); 54cdf0e10cSrcweir REG_ENSURE(!key2.createKey(OUString::createFromAscii("XInterfaceA"), key5), "testCoreReflection error 7"); 55cdf0e10cSrcweir REG_ENSURE(!key2.createKey(OUString::createFromAscii("ExceptionA"), key6), "testCoreReflection error 8"); 56cdf0e10cSrcweir REG_ENSURE(!key2.createKey(OUString::createFromAscii("ServiceA"), key7), "testCoreReflection error 8a"); 57cdf0e10cSrcweir REG_ENSURE(!key2.createKey(OUString::createFromAscii("ConstantsA"), key8), "testCoreReflection error 8b"); 58cdf0e10cSrcweir 59cdf0e10cSrcweir { 60cdf0e10cSrcweir RegistryTypeWriter writer(RT_TYPE_MODULE, 61cdf0e10cSrcweir OUString::createFromAscii("ModuleA"), 62cdf0e10cSrcweir OUString(), 11, 0, 0); 63cdf0e10cSrcweir 64cdf0e10cSrcweir RTConstValue aConst; 65cdf0e10cSrcweir 66cdf0e10cSrcweir writer.setDoku(OUString::createFromAscii("Hallo ich bin ein Modul")); 67cdf0e10cSrcweir writer.setFileName(OUString::createFromAscii("DummyFile")); 68cdf0e10cSrcweir 69cdf0e10cSrcweir aConst.m_type = RT_TYPE_BOOL; 70cdf0e10cSrcweir aConst.m_value.aBool = sal_True; 71cdf0e10cSrcweir writer.setFieldData(0, OUString::createFromAscii("aConstBool"), 72cdf0e10cSrcweir OUString::createFromAscii("boolean"), 73cdf0e10cSrcweir OUString::createFromAscii("ich bin ein boolean"), 74cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 75cdf0e10cSrcweir aConst.m_type = RT_TYPE_BYTE; 76cdf0e10cSrcweir aConst.m_value.aByte = 127; 77cdf0e10cSrcweir writer.setFieldData(1, OUString::createFromAscii("aConstByte"), 78cdf0e10cSrcweir OUString::createFromAscii("byte"), 79cdf0e10cSrcweir OUString::createFromAscii("ich bin ein byte"), 80cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 81cdf0e10cSrcweir aConst.m_type = RT_TYPE_INT16; 82cdf0e10cSrcweir aConst.m_value.aShort = -10; 83cdf0e10cSrcweir writer.setFieldData(2, OUString::createFromAscii("aConstShort"), 84cdf0e10cSrcweir OUString::createFromAscii("short"), 85cdf0e10cSrcweir OUString::createFromAscii("ich bin ein short"), 86cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 87cdf0e10cSrcweir aConst.m_type = RT_TYPE_UINT16; 88cdf0e10cSrcweir aConst.m_value.aUShort = 10; 89cdf0e10cSrcweir writer.setFieldData(3, OUString::createFromAscii("aConstUShort"), 90cdf0e10cSrcweir OUString::createFromAscii("unsigned short"), 91cdf0e10cSrcweir OUString::createFromAscii("ich bin ein unsigned short"), 92cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 93cdf0e10cSrcweir aConst.m_type = RT_TYPE_INT32; 94cdf0e10cSrcweir aConst.m_value.aLong = -100000; 95cdf0e10cSrcweir writer.setFieldData(4, OUString::createFromAscii("aConstLong"), 96cdf0e10cSrcweir OUString::createFromAscii("long"), 97cdf0e10cSrcweir OUString::createFromAscii("ich bin ein long"), 98cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 99cdf0e10cSrcweir aConst.m_type = RT_TYPE_UINT32; 100cdf0e10cSrcweir aConst.m_value.aULong = 100000; 101cdf0e10cSrcweir writer.setFieldData(5, OUString::createFromAscii("aConstULong"), 102cdf0e10cSrcweir OUString::createFromAscii("unsigned long"), 103cdf0e10cSrcweir OUString::createFromAscii("ich bin ein unsigned long"), 104cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 105cdf0e10cSrcweir aConst.m_type = RT_TYPE_INT64; 106cdf0e10cSrcweir aConst.m_value.aHyper = -100000000; 107cdf0e10cSrcweir writer.setFieldData(6, OUString::createFromAscii("aConstHyper"), 108cdf0e10cSrcweir OUString::createFromAscii("hyper"), 109cdf0e10cSrcweir OUString::createFromAscii("ich bin ein hyper"), 110cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 111cdf0e10cSrcweir aConst.m_type = RT_TYPE_UINT64; 112cdf0e10cSrcweir aConst.m_value.aUHyper = 100000000; 113cdf0e10cSrcweir writer.setFieldData(7, OUString::createFromAscii("aConstULong"), 114cdf0e10cSrcweir OUString::createFromAscii("unsigned long"), 115cdf0e10cSrcweir OUString::createFromAscii("ich bin ein unsigned long"), 116cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 117cdf0e10cSrcweir aConst.m_type = RT_TYPE_FLOAT; 118cdf0e10cSrcweir aConst.m_value.aFloat = -2e-10f; 119cdf0e10cSrcweir writer.setFieldData(8, OUString::createFromAscii("aConstFloat"), 120cdf0e10cSrcweir OUString::createFromAscii("float"), 121cdf0e10cSrcweir OUString::createFromAscii("ich bin ein float"), 122cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 123cdf0e10cSrcweir aConst.m_type = RT_TYPE_DOUBLE; 124cdf0e10cSrcweir aConst.m_value.aDouble = -2e-100; writer.setFieldData(9, OUString::createFromAscii("aConstDouble"), 125cdf0e10cSrcweir OUString::createFromAscii("double"), 126cdf0e10cSrcweir OUString::createFromAscii("ich bin ein double"), 127cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 128cdf0e10cSrcweir aConst.m_type = RT_TYPE_STRING; 129cdf0e10cSrcweir OUString tmpStr(OUString::createFromAscii( "dies ist ein unicode string" )); 130cdf0e10cSrcweir aConst.m_value.aString = tmpStr.getStr(); 131cdf0e10cSrcweir 132cdf0e10cSrcweir writer.setFieldData(10, OUString::createFromAscii("aConstString"), 133cdf0e10cSrcweir OUString::createFromAscii("string"), 134cdf0e10cSrcweir OUString::createFromAscii("ich bin ein string"), 135cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 136cdf0e10cSrcweir 137cdf0e10cSrcweir const sal_uInt8* pBlop = writer.getBlop(); 138cdf0e10cSrcweir sal_uInt32 aBlopSize = writer.getBlopSize(); 139cdf0e10cSrcweir 140cdf0e10cSrcweir REG_ENSURE(!key2.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9"); 141cdf0e10cSrcweir 142cdf0e10cSrcweir sal_uInt8* readBlop = (sal_uInt8*)rtl_allocateMemory(aBlopSize); 143cdf0e10cSrcweir REG_ENSURE(!key2.getValue(OUString(), (void*)readBlop) , "testCoreReflection error 9a"); 144cdf0e10cSrcweir 145cdf0e10cSrcweir RegistryTypeReader reader(readBlop, aBlopSize, sal_True); 146cdf0e10cSrcweir 147cdf0e10cSrcweir if (reader.isValid()) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir REG_ENSURE(reader.getTypeName().equals(OUString::createFromAscii("ModuleA")), "testCoreReflection error 9a2"); 150cdf0e10cSrcweir 151cdf0e10cSrcweir RTConstValue aReadConst = reader.getFieldConstValue(4); 152cdf0e10cSrcweir REG_ENSURE( aReadConst.m_type == RT_TYPE_INT32, "testCoreReflection error 9a3"); 153cdf0e10cSrcweir REG_ENSURE( aReadConst.m_value.aLong == -100000, "testCoreReflection error 9a4"); 154cdf0e10cSrcweir 155cdf0e10cSrcweir aReadConst = reader.getFieldConstValue(6); 156cdf0e10cSrcweir REG_ENSURE( aReadConst.m_type == RT_TYPE_INT64, "testCoreReflection error 9a5"); 157cdf0e10cSrcweir REG_ENSURE( aReadConst.m_value.aHyper == -100000000, "testCoreReflection error 9a6"); 158cdf0e10cSrcweir 159cdf0e10cSrcweir aReadConst = reader.getFieldConstValue(10); 160cdf0e10cSrcweir OString aConstStr = OUStringToOString(aConst.m_value.aString, RTL_TEXTENCODING_ASCII_US); 161cdf0e10cSrcweir REG_ENSURE(aConstStr.equals("dies ist ein unicode string"), "testCoreReflection error 9b"); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir { 167cdf0e10cSrcweir RegistryTypeWriter writer(RT_TYPE_STRUCT, 168cdf0e10cSrcweir OUString::createFromAscii("ModuleA/StructA"), 169cdf0e10cSrcweir OUString(), 3, 0, 0); 170cdf0e10cSrcweir 171cdf0e10cSrcweir writer.setDoku(OUString::createFromAscii("Hallo ich bin eine Struktur")); 172cdf0e10cSrcweir writer.setFileName(OUString::createFromAscii("DummyFile")); 173cdf0e10cSrcweir 174cdf0e10cSrcweir writer.setFieldData(0, OUString::createFromAscii("asal_uInt32"), 175cdf0e10cSrcweir OUString::createFromAscii("unsigned long"), 176cdf0e10cSrcweir OUString(), OUString(), RT_ACCESS_READWRITE); 177cdf0e10cSrcweir writer.setFieldData(1, OUString::createFromAscii("aXInterface"), 178cdf0e10cSrcweir OUString::createFromAscii("stardiv/uno/XInterface"), 179cdf0e10cSrcweir OUString(), OUString(), RT_ACCESS_READWRITE); 180cdf0e10cSrcweir writer.setFieldData(2, OUString::createFromAscii("aSequence"), 181cdf0e10cSrcweir OUString::createFromAscii("[]ModuleA/EnumA"), 182cdf0e10cSrcweir OUString(), OUString(), RT_ACCESS_READWRITE); 183cdf0e10cSrcweir 184cdf0e10cSrcweir const sal_uInt8* pBlop = writer.getBlop(); 185cdf0e10cSrcweir sal_uInt32 aBlopSize = writer.getBlopSize(); 186cdf0e10cSrcweir 187cdf0e10cSrcweir REG_ENSURE(!key3.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9a"); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir { 191cdf0e10cSrcweir RegistryTypeWriter writer(RT_TYPE_ENUM, 192cdf0e10cSrcweir OUString::createFromAscii("ModuleA/EnumA"), 193cdf0e10cSrcweir OUString(), 2, 0, 0); 194cdf0e10cSrcweir 195cdf0e10cSrcweir RTConstValue aConst; 196cdf0e10cSrcweir 197cdf0e10cSrcweir aConst.m_type = RT_TYPE_UINT32; 198cdf0e10cSrcweir aConst.m_value.aULong = 10; 199cdf0e10cSrcweir 200cdf0e10cSrcweir writer.setDoku(OUString::createFromAscii("Hallo ich bin ein Enum")); 201cdf0e10cSrcweir writer.setFileName(OUString::createFromAscii("DummyFile")); 202cdf0e10cSrcweir 203cdf0e10cSrcweir writer.setFieldData(0, OUString::createFromAscii("ENUM_VAL_1"), 204cdf0e10cSrcweir OUString(), OUString::createFromAscii("ich bin ein enum value"), 205cdf0e10cSrcweir OUString(), RT_ACCESS_CONST, aConst); 206cdf0e10cSrcweir 207cdf0e10cSrcweir aConst.m_value.aULong = 10; 208cdf0e10cSrcweir writer.setFieldData(1, OUString::createFromAscii("ENUM_VAL_2"), 209cdf0e10cSrcweir OUString(), OUString(), OUString(), RT_ACCESS_CONST, aConst); 210cdf0e10cSrcweir 211cdf0e10cSrcweir const sal_uInt8* pBlop = writer.getBlop(); 212cdf0e10cSrcweir sal_uInt32 aBlopSize = writer.getBlopSize(); 213cdf0e10cSrcweir 214cdf0e10cSrcweir REG_ENSURE(!key4.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9b"); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir { 218cdf0e10cSrcweir RegistryTypeWriter writer(RT_TYPE_INTERFACE, 219cdf0e10cSrcweir OUString::createFromAscii("ModuleA/XInterfaceA"), 220cdf0e10cSrcweir OUString::createFromAscii("stardiv/uno/XInterface"), 221cdf0e10cSrcweir 4, 1, 0); 222cdf0e10cSrcweir RTConstValue aConst; 223cdf0e10cSrcweir 224cdf0e10cSrcweir RTUik aUik = {1,2,3,4,5}; 225cdf0e10cSrcweir 226cdf0e10cSrcweir writer.setUik(aUik); 227cdf0e10cSrcweir writer.setDoku(OUString::createFromAscii("Hallo ich bin ein Interface")); 228cdf0e10cSrcweir writer.setFileName(OUString::createFromAscii("DummyFile")); 229cdf0e10cSrcweir 230cdf0e10cSrcweir writer.setFieldData(0, OUString::createFromAscii("aString"), 231cdf0e10cSrcweir OUString::createFromAscii("string"), OUString(), OUString(), RT_ACCESS_READWRITE); 232cdf0e10cSrcweir writer.setFieldData(1, OUString::createFromAscii("aStruct"), 233cdf0e10cSrcweir OUString::createFromAscii("ModuleA/StructA"), 234cdf0e10cSrcweir OUString(), OUString(), RT_ACCESS_READONLY); 235cdf0e10cSrcweir writer.setFieldData(2, OUString::createFromAscii("aEnum"), 236cdf0e10cSrcweir OUString::createFromAscii("ModuleA/EnumA"), OUString(), OUString(), RT_ACCESS_BOUND); 237cdf0e10cSrcweir aConst.m_type = RT_TYPE_UINT16; 238cdf0e10cSrcweir aConst.m_value.aUShort = 12; 239cdf0e10cSrcweir writer.setFieldData(3, OUString::createFromAscii("aConstUShort"), 240cdf0e10cSrcweir OUString::createFromAscii("unsigned short"), OUString(), 241cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 242cdf0e10cSrcweir 243cdf0e10cSrcweir writer.setMethodData(0, OUString::createFromAscii("methodA"), 244cdf0e10cSrcweir OUString::createFromAscii("double"), RT_MODE_TWOWAY, 2, 1, 245cdf0e10cSrcweir OUString::createFromAscii("Hallo ich bin die methodA")); 246cdf0e10cSrcweir writer.setParamData(0, 0, OUString::createFromAscii("ModuleA/StructA"), 247cdf0e10cSrcweir OUString::createFromAscii("aStruct"), RT_PARAM_IN); 248cdf0e10cSrcweir writer.setParamData(0, 1, OUString::createFromAscii("unsigned short"), 249cdf0e10cSrcweir OUString::createFromAscii("aShort"), RT_PARAM_INOUT); 250cdf0e10cSrcweir writer.setExcData(0, 0, OUString::createFromAscii("ModuleA/ExceptionA")); 251cdf0e10cSrcweir 252cdf0e10cSrcweir const sal_uInt8* pBlop = writer.getBlop(); 253cdf0e10cSrcweir sal_uInt32 aBlopSize = writer.getBlopSize(); 254cdf0e10cSrcweir 255cdf0e10cSrcweir REG_ENSURE(!key5.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9c"); 256cdf0e10cSrcweir 257cdf0e10cSrcweir sal_uInt8* readBlop = (sal_uInt8*)rtl_allocateMemory(aBlopSize); 258cdf0e10cSrcweir REG_ENSURE(!key5.getValue(OUString(), (void*)readBlop) , "testCoreReflection error 9c1"); 259cdf0e10cSrcweir 260cdf0e10cSrcweir RegistryTypeReader reader(readBlop, aBlopSize, sal_True); 261cdf0e10cSrcweir 262cdf0e10cSrcweir if (reader.isValid()) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir REG_ENSURE(reader.getTypeName().equals(OUString::createFromAscii("ModuleA/XInterfaceA")), "testCoreReflection error 9c2"); 265cdf0e10cSrcweir 266cdf0e10cSrcweir RTUik retUik; 267cdf0e10cSrcweir reader.getUik(retUik); 268cdf0e10cSrcweir REG_ENSURE(retUik.m_Data1 = 1, "testCoreReflection error 9c3"); 269cdf0e10cSrcweir REG_ENSURE(retUik.m_Data2 = 2, "testCoreReflection error 9c4"); 270cdf0e10cSrcweir REG_ENSURE(retUik.m_Data3 = 3, "testCoreReflection error 9c5"); 271cdf0e10cSrcweir REG_ENSURE(retUik.m_Data4 = 4, "testCoreReflection error 9c6"); 272cdf0e10cSrcweir REG_ENSURE(retUik.m_Data5 = 5, "testCoreReflection error 9c7"); 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir { 278cdf0e10cSrcweir RegistryTypeWriter writer(RT_TYPE_EXCEPTION, 279cdf0e10cSrcweir OUString::createFromAscii("ModuleA/ExceptionA"), 280cdf0e10cSrcweir OUString(), 1, 0, 0); 281cdf0e10cSrcweir 282cdf0e10cSrcweir writer.setDoku(OUString::createFromAscii("Hallo ich bin eine Exception")); 283cdf0e10cSrcweir 284cdf0e10cSrcweir writer.setFieldData(0, OUString::createFromAscii("aSource"), 285cdf0e10cSrcweir OUString::createFromAscii("stardiv/uno/XInterface"), 286cdf0e10cSrcweir OUString::createFromAscii("ich bin ein interface member"), 287cdf0e10cSrcweir OUString(), RT_ACCESS_READWRITE); 288cdf0e10cSrcweir 289cdf0e10cSrcweir const sal_uInt8* pBlop = writer.getBlop(); 290cdf0e10cSrcweir sal_uInt32 aBlopSize = writer.getBlopSize(); 291cdf0e10cSrcweir 292cdf0e10cSrcweir REG_ENSURE(!key6.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9d"); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir { 296cdf0e10cSrcweir RegistryTypeWriter writer(RT_TYPE_SERVICE, 297cdf0e10cSrcweir OUString::createFromAscii("ModuleA/ServiceA"), 298cdf0e10cSrcweir OUString(), 1, 0, 4); 299cdf0e10cSrcweir 300cdf0e10cSrcweir writer.setDoku(OUString::createFromAscii("Hallo ich bin ein Service")); 301cdf0e10cSrcweir writer.setFileName(OUString::createFromAscii("DummyFile")); 302cdf0e10cSrcweir 303cdf0e10cSrcweir writer.setFieldData(0, OUString::createFromAscii("aProperty"), 304cdf0e10cSrcweir OUString::createFromAscii("stardiv/uno/XInterface"), 305cdf0e10cSrcweir OUString::createFromAscii("ich bin eine property"), 306cdf0e10cSrcweir OUString(), RT_ACCESS_READWRITE); 307cdf0e10cSrcweir 308cdf0e10cSrcweir writer.setReferenceData(0, OUString::createFromAscii("ModuleA/XInterfaceA"), RT_REF_SUPPORTS, 309cdf0e10cSrcweir OUString::createFromAscii("Hallo ich eine Reference auf ein supported interface"), 310cdf0e10cSrcweir RT_ACCESS_OPTIONAL); 311cdf0e10cSrcweir writer.setReferenceData(1, OUString::createFromAscii("ModuleA/XInterfaceA"), RT_REF_OBSERVES, 312cdf0e10cSrcweir OUString::createFromAscii("Hallo ich eine Reference auf ein observed interface")); 313cdf0e10cSrcweir writer.setReferenceData(2, OUString::createFromAscii("ModuleA/ServiceB"), RT_REF_EXPORTS, 314cdf0e10cSrcweir OUString::createFromAscii("Hallo ich eine Reference auf einen exported service")); 315cdf0e10cSrcweir writer.setReferenceData(3, OUString::createFromAscii("ModuleA/ServiceB"), RT_REF_NEEDS, 316cdf0e10cSrcweir OUString::createFromAscii("Hallo ich eine Reference auf einen needed service")); 317cdf0e10cSrcweir 318cdf0e10cSrcweir const sal_uInt8* pBlop = writer.getBlop(); 319cdf0e10cSrcweir sal_uInt32 aBlopSize = writer.getBlopSize(); 320cdf0e10cSrcweir 321cdf0e10cSrcweir REG_ENSURE(!key7.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9e"); 322cdf0e10cSrcweir sal_uInt8* readBlop = (sal_uInt8*)rtl_allocateMemory(aBlopSize); 323cdf0e10cSrcweir REG_ENSURE(!key7.getValue(OUString(), (void*)readBlop) , "testCoreReflection error 9e2"); 324cdf0e10cSrcweir 325cdf0e10cSrcweir RegistryTypeReader reader(readBlop, aBlopSize, sal_True); 326cdf0e10cSrcweir 327cdf0e10cSrcweir if (reader.isValid()) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir REG_ENSURE(reader.getTypeName().equals(OUString::createFromAscii("ModuleA/ServiceA")), "testCoreReflection error 9e3"); 330cdf0e10cSrcweir 331cdf0e10cSrcweir sal_uInt32 referenceCount = reader.getReferenceCount(); 332cdf0e10cSrcweir REG_ENSURE( referenceCount == 4, "testCoreReflection error 9e4"); 333cdf0e10cSrcweir 334cdf0e10cSrcweir OUString refName = reader.getReferenceName(0); 335cdf0e10cSrcweir REG_ENSURE(refName.equals(OUString::createFromAscii("ModuleA/XInterfaceA")), "testCoreReflection error 9e5"); 336cdf0e10cSrcweir } 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir { 340cdf0e10cSrcweir RegistryTypeWriter writer(RT_TYPE_CONSTANTS, 341cdf0e10cSrcweir OUString::createFromAscii("ModuleA/ConstansA"), 342cdf0e10cSrcweir OUString(), 3, 0, 0); 343cdf0e10cSrcweir 344cdf0e10cSrcweir RTConstValue aConst; 345cdf0e10cSrcweir 346cdf0e10cSrcweir writer.setDoku(OUString::createFromAscii("Hallo ich bin eine Constants Group")); 347cdf0e10cSrcweir writer.setFileName(OUString::createFromAscii("DummyFile")); 348cdf0e10cSrcweir 349cdf0e10cSrcweir aConst.m_type = RT_TYPE_BOOL; 350cdf0e10cSrcweir aConst.m_value.aBool = sal_True; 351cdf0e10cSrcweir writer.setFieldData(0, OUString::createFromAscii("ConstantsA_aConstBool"), 352cdf0e10cSrcweir OUString::createFromAscii("boolean"), 353cdf0e10cSrcweir OUString::createFromAscii("ich bin ein boolean"), 354cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 355cdf0e10cSrcweir aConst.m_type = RT_TYPE_BYTE; 356cdf0e10cSrcweir aConst.m_value.aByte = 127; 357cdf0e10cSrcweir writer.setFieldData(1, OUString::createFromAscii("ConstantsA_aConstByte"), 358cdf0e10cSrcweir OUString::createFromAscii("byte"), 359cdf0e10cSrcweir OUString::createFromAscii("ich bin ein byte"), 360cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 361cdf0e10cSrcweir aConst.m_type = RT_TYPE_INT16; 362cdf0e10cSrcweir aConst.m_value.aShort = -10; 363cdf0e10cSrcweir writer.setFieldData(2, OUString::createFromAscii("ConstantsA_aConstShort"), 364cdf0e10cSrcweir OUString::createFromAscii("short"), 365cdf0e10cSrcweir OUString::createFromAscii("ich bin ein short"), 366cdf0e10cSrcweir OUString::createFromAscii("DummyFile"), RT_ACCESS_CONST, aConst); 367cdf0e10cSrcweir 368cdf0e10cSrcweir const sal_uInt8* pBlop = writer.getBlop(); 369cdf0e10cSrcweir sal_uInt32 aBlopSize = writer.getBlopSize(); 370cdf0e10cSrcweir 371cdf0e10cSrcweir REG_ENSURE(!key8.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)pBlop, aBlopSize), "testCoreReflection error 9f"); 372cdf0e10cSrcweir } 373cdf0e10cSrcweir 374cdf0e10cSrcweir // REG_ENSURE(!myRegistry->destroy(NULL), "testCoreReflection error 10"); 375cdf0e10cSrcweir delete myRegistry; 376cdf0e10cSrcweir 377cdf0e10cSrcweir cout << "test_coreReflection() Ok!\n"; 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir void test_registry_CppApi() 381cdf0e10cSrcweir { 382cdf0e10cSrcweir Registry *myRegistry = new Registry(); 383cdf0e10cSrcweir 384cdf0e10cSrcweir RegistryKey rootKey, key1, key2, key3, key4 ,key5, key6, key7, key8, key9; 385cdf0e10cSrcweir 386cdf0e10cSrcweir REG_ENSURE(!myRegistry->create(OUString::createFromAscii("test.rdb")), "test_registry_CppApi error 1"); 387cdf0e10cSrcweir REG_ENSURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 2"); 388cdf0e10cSrcweir 389cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("myFirstKey"), key1), "test_registry_CppApi error 3"); 390cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("mySecondKey"), key2), "test_registry_CppApi error 4"); 391cdf0e10cSrcweir REG_ENSURE(!key1.createKey(OUString::createFromAscii("X"), key3), "test_registry_CppApi error 5"); 392cdf0e10cSrcweir REG_ENSURE(!key1.createKey(OUString::createFromAscii("mySecondSubKey"), key4), "test_registry_CppApi error 6"); 393cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("myThirdKey"), key5), "test_registry_CppApi error 6a"); 394cdf0e10cSrcweir 395cdf0e10cSrcweir REG_ENSURE(!key5.createKey(OUString::createFromAscii("1"), key4), "test_registry_CppApi error 6b"); 396cdf0e10cSrcweir REG_ENSURE(!key4.createKey(OUString::createFromAscii("2"), key3), "test_registry_CppApi error 6c"); 397cdf0e10cSrcweir REG_ENSURE(!key5.openKey(OUString::createFromAscii("1"), key4), "test_registry_CppApi error 6d"); 398cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("/myThirdKey/1"), key4), "test_registry_CppApi error 6e"); 399cdf0e10cSrcweir REG_ENSURE(key4.getName().equals(OUString::createFromAscii("/myThirdKey/1")), "test_registry_CppApi error 6f"); 400cdf0e10cSrcweir 401cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("myFourthKey"), key6), "test_registry_CppApi error 7"); 402cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("myFifthKey"), key6), "test_registry_CppApi error 7a"); 403cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("mySixthKey"), key6), "test_registry_CppApi error 7b"); 404cdf0e10cSrcweir 405cdf0e10cSrcweir // Link Test 406cdf0e10cSrcweir // 407cdf0e10cSrcweir 408cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("/myFourthKey/X"), key7), "test_registry_CppApi error 7c)");; 409cdf0e10cSrcweir REG_ENSURE(!key6.createLink(OUString::createFromAscii("myFirstLink"), OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7d"); 410cdf0e10cSrcweir REG_ENSURE(!key6.createKey(OUString::createFromAscii("mySixthSubKey"), key7), "test_registry_CppApi error 7e"); 411cdf0e10cSrcweir 412cdf0e10cSrcweir OUString linkTarget; 413cdf0e10cSrcweir REG_ENSURE(!key6.getLinkTarget(OUString::createFromAscii("myFirstLink"), linkTarget), "test_registry_CppApi error 7f"); 414cdf0e10cSrcweir REG_ENSURE(linkTarget.equals(OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7g"); 415cdf0e10cSrcweir 416cdf0e10cSrcweir RegistryKeyNames* pSubKeyNames = new RegistryKeyNames(); 417cdf0e10cSrcweir sal_uInt32 nSubKeys=0; 418cdf0e10cSrcweir 419cdf0e10cSrcweir REG_ENSURE(!rootKey.getKeyNames(OUString::createFromAscii("mySixthKey"), *pSubKeyNames), "test_registry_CppApi error 7h)"); 420cdf0e10cSrcweir REG_ENSURE(pSubKeyNames->getLength() == 2, "test_registry_CppApi error 7i)"); 421cdf0e10cSrcweir 422cdf0e10cSrcweir for (sal_uInt32 i=0; i < pSubKeyNames->getLength(); i++) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir if (pSubKeyNames->getElement(i).equals(OUString::createFromAscii("/mySixthKey/myFirstLink"))) 425cdf0e10cSrcweir { 426cdf0e10cSrcweir RegKeyType keyType; 427cdf0e10cSrcweir REG_ENSURE(!rootKey.getKeyType(pSubKeyNames->getElement(i), &keyType), "test_registry_CppApi error 7j"); 428cdf0e10cSrcweir REG_ENSURE(keyType == RG_LINKTYPE, "test_registry_CppApi error 7k"); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir } 431cdf0e10cSrcweir 432cdf0e10cSrcweir REG_ENSURE(!key7.closeKey(), "test_registry_CppApi error 7k1"); 433cdf0e10cSrcweir delete pSubKeyNames; 434cdf0e10cSrcweir 435cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("/mySixthKey/myFirstLink"), key6), "test_registry_CppApi error 7l"); 436cdf0e10cSrcweir // REG_ENSURE(key6.getName().equals(OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7m"); 437cdf0e10cSrcweir 438cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("myFifthKey"), key6), "test_registry_CppApi error 7m1"); 439cdf0e10cSrcweir REG_ENSURE(!key6.createLink(OUString::createFromAscii("mySecondLink"), 440cdf0e10cSrcweir OUString::createFromAscii("/mySixthKey/myFirstLink")), "test_registry_CppApi error 7m2"); 441cdf0e10cSrcweir 442cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("/myFifthKey/mySecondLink"), key6), "test_registry_CppApi error 7m3"); 443cdf0e10cSrcweir // REG_ENSURE(key6.getName().equals(OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7m4"); 444cdf0e10cSrcweir 445cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("/myFifthKey/mySecondLink/myFirstLinkSubKey"), key7), "test_registry_CppApi error 7m5"); 446cdf0e10cSrcweir REG_ENSURE(key7.getName().equals(OUString::createFromAscii("/myFourthKey/X/myFirstLinkSubKey")), "test_registry_CppApi error 7m6"); 447cdf0e10cSrcweir 448cdf0e10cSrcweir REG_ENSURE(!key7.createLink(OUString::createFromAscii("myThirdLink"), OUString::createFromAscii("/myFifthKey/mySecondLink")), "test_registry_CppApi error 7m7"); 449cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("/myFourthKey/X/myFirstLinkSubKey/myThirdLink"), key7), "test_registry_CppApi error 7m8"); 450cdf0e10cSrcweir // REG_ENSURE(!key7.openKey(OUString::createFromAscii("/myFirstLinkSubKey/myThirdLink/myFirstLinkSubKey/myThirdLink"), key6), "test_registry_CppApi error 7m9"); 451cdf0e10cSrcweir // REG_ENSURE(key7.getName().equals(OUString::createFromAscii("/myFourthKey/X")), "test_registry_CppApi error 7m10"); 452cdf0e10cSrcweir REG_ENSURE(!key7.closeKey(), "test_registry_CppApi error 7m11"); 453cdf0e10cSrcweir 454cdf0e10cSrcweir REG_ENSURE(!rootKey.deleteLink(OUString::createFromAscii("/myFifthKey/mySecondLink")), "test_registry_CppApi error 7m12"); 455cdf0e10cSrcweir 456cdf0e10cSrcweir REG_ENSURE(!rootKey.createLink(OUString::createFromAscii("/myFifthKey/mySecondLink"), 457cdf0e10cSrcweir OUString::createFromAscii("/myFourthKey/X/myFirstLinkSubKey/myThirdLink")), 458cdf0e10cSrcweir "test_registry_CppApi error 7m13"); 459cdf0e10cSrcweir 460cdf0e10cSrcweir // REG_ENSURE(rootKey.openKey(OUString::createFromAscii("/myFourthKey/X/myFirstLinkSubKey/myThirdLink"), key7) == REG_DETECT_RECURSION, 461cdf0e10cSrcweir // "test_registry_CppApi error 7m14"); 462cdf0e10cSrcweir 463cdf0e10cSrcweir // REG_ENSURE(key7.closeKey() == REG_INVALID_KEY, "test_registry_CppApi error 7m11"); 464cdf0e10cSrcweir 465cdf0e10cSrcweir RegistryKeyNames subKeyNames; 466cdf0e10cSrcweir nSubKeys=0; 467cdf0e10cSrcweir 468cdf0e10cSrcweir REG_ENSURE(!rootKey.getKeyNames(OUString::createFromAscii("mySixthKey"), subKeyNames), "test_registry_CppApi error 7n"); 469cdf0e10cSrcweir 470cdf0e10cSrcweir nSubKeys = subKeyNames.getLength(); 471cdf0e10cSrcweir REG_ENSURE(nSubKeys == 2, "test_registry_CppApi error 7n1"); 472cdf0e10cSrcweir REG_ENSURE(subKeyNames.getElement(0).equals(OUString::createFromAscii("/mySixthKey/myFirstLink")), "test_registry_CppApi error 7p1)"); 473cdf0e10cSrcweir REG_ENSURE(subKeyNames.getElement(1).equals(OUString::createFromAscii("/mySixthKey/mySixthSubKey")), "test_registry_CppApi error 7p2"); 474cdf0e10cSrcweir 475cdf0e10cSrcweir 476cdf0e10cSrcweir RegistryKeyArray subKeys; 477cdf0e10cSrcweir nSubKeys=0; 478cdf0e10cSrcweir 479cdf0e10cSrcweir REG_ENSURE(!rootKey.openSubKeys(OUString::createFromAscii("myFirstKey"), subKeys), "test_registry_CppApi error 7o"); 480cdf0e10cSrcweir 481cdf0e10cSrcweir nSubKeys = subKeys.getLength(); 482cdf0e10cSrcweir REG_ENSURE(nSubKeys == 2, "test_registry_CppApi error 7o1"); 483cdf0e10cSrcweir REG_ENSURE(subKeys.getElement(0).getName().equals(OUString::createFromAscii("/myFirstKey/mySecondSubKey")), "test_registry_CppApi error 7p1)"); 484cdf0e10cSrcweir REG_ENSURE(subKeys.getElement(1).getName().equals(OUString::createFromAscii("/myFirstKey/X")), "test_registry_CppApi error 7p2"); 485cdf0e10cSrcweir 486cdf0e10cSrcweir REG_ENSURE(!rootKey.closeSubKeys(subKeys), "test_registry_CppApi error 7q)"); 487cdf0e10cSrcweir 488cdf0e10cSrcweir 489cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("/TEST"), key8), "test_registry_CppApi error 8"); 490cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("/TEST/Child1"), key8), "test_registry_CppApi error 8a"); 491cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("/TEST/Child2"), key8), "test_registry_CppApi error 8a1"); 492cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("/TEST"), key9), "test_registry_CppApi error 8b"); 493cdf0e10cSrcweir REG_ENSURE(!key8.closeKey() && !key9.closeKey(), "test_registry_CppApi error 8b1"); 494cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("/TEST"), key8), "test_registry_CppApi error 8b"); 495cdf0e10cSrcweir REG_ENSURE(!key8.closeKey(), "test_registry_CppApi error 8c"); 496cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("TEST"), key8), "test_registry_CppApi error 8c"); 497cdf0e10cSrcweir REG_ENSURE(!key8.closeKey(), "test_registry_CppApi error 8d"); 498cdf0e10cSrcweir 499cdf0e10cSrcweir 500cdf0e10cSrcweir sal_Char* Value=(sal_Char*)"Mein erster Value"; 501cdf0e10cSrcweir REG_ENSURE(!rootKey.setValue(OUString::createFromAscii("mySecondKey"), RG_VALUETYPE_STRING, Value, 18), "test_registry_CppApi error 9"); 502cdf0e10cSrcweir 503cdf0e10cSrcweir RegValueType valueType; 504cdf0e10cSrcweir sal_uInt32 valueSize; 505cdf0e10cSrcweir sal_Char* readValue; 506cdf0e10cSrcweir REG_ENSURE(!rootKey.getValueInfo(OUString::createFromAscii("mySecondKey"), &valueType, &valueSize), "test_registry_CppApi error 9a"); 507cdf0e10cSrcweir 508cdf0e10cSrcweir readValue = (sal_Char*)rtl_allocateMemory(valueSize); 509cdf0e10cSrcweir REG_ENSURE(!key2.getValue(OUString(), readValue), "test_registry_CppApi error 10"); 510cdf0e10cSrcweir 511cdf0e10cSrcweir REG_ENSURE(valueType == RG_VALUETYPE_STRING, "test_registry_CppApi error 11"); 512cdf0e10cSrcweir REG_ENSURE(valueSize == 18, "test_registry_CppApi error 12"); 513cdf0e10cSrcweir REG_ENSURE(strcmp(readValue, Value) == 0, "test_registry_CppApi error 13"); 514cdf0e10cSrcweir rtl_freeMemory(readValue); 515cdf0e10cSrcweir 516cdf0e10cSrcweir const sal_Char* pList[3]; 517cdf0e10cSrcweir const sal_Char* n1= "Hallo"; 518cdf0e10cSrcweir const sal_Char* n2= "jetzt komm"; 519cdf0e10cSrcweir const sal_Char* n3= "ich"; 520cdf0e10cSrcweir 521cdf0e10cSrcweir pList[0]=n1; 522cdf0e10cSrcweir pList[1]=n2; 523cdf0e10cSrcweir pList[2]=n3; 524cdf0e10cSrcweir 525cdf0e10cSrcweir REG_ENSURE(!rootKey.setStringListValue(OUString::createFromAscii("myFourthKey"), (sal_Char**)pList, 3), "test_registry_CppApi error 13a"); 526cdf0e10cSrcweir 527cdf0e10cSrcweir RegistryValueList<sal_Char*> valueList; 528cdf0e10cSrcweir REG_ENSURE(!rootKey.getStringListValue(OUString::createFromAscii("myFourthKey"), valueList), "test_registry_CppApi error 13b"); 529cdf0e10cSrcweir 530cdf0e10cSrcweir REG_ENSURE(strcmp(n1, valueList.getElement(0)) == 0, "test_registry_CppApi error 13c"); 531cdf0e10cSrcweir REG_ENSURE(strcmp(n2, valueList.getElement(1)) == 0, "test_registry_CppApi error 13d"); 532cdf0e10cSrcweir REG_ENSURE(strcmp(n3, valueList.getElement(2)) == 0, "test_registry_CppApi error 13e"); 533cdf0e10cSrcweir 534cdf0e10cSrcweir REG_ENSURE(!rootKey.getValueInfo(OUString::createFromAscii("myFourthKey"), &valueType, &valueSize), "test_registry_CppApi error 13e1"); 535cdf0e10cSrcweir REG_ENSURE(valueType == RG_VALUETYPE_STRINGLIST, "test_registry_CppApi error 13e2"); 536cdf0e10cSrcweir REG_ENSURE(valueSize == 3, "test_registry_CppApi error 13e3"); 537cdf0e10cSrcweir 538cdf0e10cSrcweir sal_Int32 pLong[3]; 539cdf0e10cSrcweir pLong[0] = 123; 540cdf0e10cSrcweir pLong[1] = 456; 541cdf0e10cSrcweir pLong[2] = 789; 542cdf0e10cSrcweir 543cdf0e10cSrcweir REG_ENSURE(!rootKey.setLongListValue(OUString::createFromAscii("myFifthKey"), pLong, 3), "test_registry_CppApi error 13f"); 544cdf0e10cSrcweir 545cdf0e10cSrcweir RegistryValueList<sal_Int32> longList; 546cdf0e10cSrcweir REG_ENSURE(!rootKey.getLongListValue(OUString::createFromAscii("myFifthKey"), longList), "test_registry_CppApi error 13g"); 547cdf0e10cSrcweir 548cdf0e10cSrcweir REG_ENSURE(pLong[0] == longList.getElement(0), "test_registry_CppApi error 13h"); 549cdf0e10cSrcweir REG_ENSURE(pLong[1] == longList.getElement(1), "test_registry_CppApi error 13i"); 550cdf0e10cSrcweir REG_ENSURE(pLong[2] == longList.getElement(2), "test_registry_CppApi error 13j"); 551cdf0e10cSrcweir 552cdf0e10cSrcweir 553cdf0e10cSrcweir OUString sWTestValue(OUString::createFromAscii( "Mein erster Unicode Value" )); 554cdf0e10cSrcweir const sal_Unicode* wTestValue= sWTestValue.getStr(); 555cdf0e10cSrcweir REG_ENSURE(!rootKey.setValue(OUString::createFromAscii("mySixthKey"), RG_VALUETYPE_UNICODE, (void*)wTestValue, 556cdf0e10cSrcweir (rtl_ustr_getLength(wTestValue)+1)*sizeof(sal_Unicode)), "test_registry_CppApi error 13j1"); 557cdf0e10cSrcweir 558cdf0e10cSrcweir REG_ENSURE(!rootKey.getValueInfo(OUString::createFromAscii("mySixthKey"), &valueType, &valueSize), "test_registry_CppApi error 13j2"); 559cdf0e10cSrcweir sal_Unicode* pTmpValue = (sal_Unicode*)rtl_allocateMemory(valueSize); 560cdf0e10cSrcweir REG_ENSURE(!rootKey.getValue(OUString::createFromAscii("mySixthKey"), pTmpValue), "test_registry_CppApi error 13j3"); 561cdf0e10cSrcweir REG_ENSURE(rtl_ustr_getLength(wTestValue) == rtl_ustr_getLength(pTmpValue), "test_registry_CppApi error 13j4"); 562cdf0e10cSrcweir REG_ENSURE(rtl_ustr_compare(wTestValue, pTmpValue) == 0, "test_registry_CppApi error 13j4"); 563cdf0e10cSrcweir 564cdf0e10cSrcweir const sal_Unicode* pUnicode[3]; 565cdf0e10cSrcweir OUString w1(OUString::createFromAscii( "Hallo" )); 566cdf0e10cSrcweir OUString w2(OUString::createFromAscii( "jetzt komm" )); 567cdf0e10cSrcweir OUString w3(OUString::createFromAscii( "ich als unicode" )); 568cdf0e10cSrcweir 569cdf0e10cSrcweir pUnicode[0]=w1.getStr(); 570cdf0e10cSrcweir pUnicode[1]=w2.getStr(); 571cdf0e10cSrcweir pUnicode[2]=w3.getStr(); 572cdf0e10cSrcweir 573cdf0e10cSrcweir REG_ENSURE(!rootKey.setUnicodeListValue(OUString::createFromAscii("mySixthKey"), (sal_Unicode**)pUnicode, 3), "test_registry_CppApi error 13k"); 574cdf0e10cSrcweir 575cdf0e10cSrcweir RegistryValueList<sal_Unicode*> unicodeList; 576cdf0e10cSrcweir REG_ENSURE(!rootKey.getUnicodeListValue(OUString::createFromAscii("mySixthKey"), unicodeList), "test_registry_CppApi error 13l"); 577cdf0e10cSrcweir 578cdf0e10cSrcweir REG_ENSURE(rtl_ustr_compare(w1, unicodeList.getElement(0)) == 0, "test_registry_CppApi error 13m"); 579cdf0e10cSrcweir REG_ENSURE(rtl_ustr_compare(w2, unicodeList.getElement(1)) == 0, "test_registry_CppApi error 13n"); 580cdf0e10cSrcweir REG_ENSURE(rtl_ustr_compare(w3, unicodeList.getElement(2)) == 0, "test_registry_CppApi error 13o"); 581cdf0e10cSrcweir 582cdf0e10cSrcweir REG_ENSURE(!key6.closeKey(), "test_registry_CppApi error 14"); 583cdf0e10cSrcweir 584cdf0e10cSrcweir REG_ENSURE(!key1.closeKey() && 585cdf0e10cSrcweir !key3.closeKey() && 586cdf0e10cSrcweir !key4.closeKey(), "test_registry_CppApi error 14"); 587cdf0e10cSrcweir 588cdf0e10cSrcweir REG_ENSURE(!rootKey.deleteKey(OUString::createFromAscii("myFirstKey")), "test_registry_CppApi error 15"); 589cdf0e10cSrcweir 590cdf0e10cSrcweir REG_ENSURE(!key2.closeKey(), "test_registry_CppApi error 16"); 591cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("mySecondKey"), key2), "test_registry_CppApi error 17"); 592cdf0e10cSrcweir 593cdf0e10cSrcweir REG_ENSURE(!key5.closeKey(), "test_registry_CppApi error 18"); 594cdf0e10cSrcweir 595cdf0e10cSrcweir REG_ENSURE(!rootKey.deleteKey(OUString::createFromAscii("myThirdKey")), "test_registry_CppApi error 19"); 596cdf0e10cSrcweir 597cdf0e10cSrcweir REG_ENSURE(rootKey.openKey(OUString::createFromAscii("myThirdKey"), key5), "test_registry_CppApi error 20"); 598cdf0e10cSrcweir 599cdf0e10cSrcweir REG_ENSURE(!key2.closeKey() && 600cdf0e10cSrcweir !rootKey.closeKey(), "test_registry_CppApi error 21"); 601cdf0e10cSrcweir 602cdf0e10cSrcweir REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 22"); 603cdf0e10cSrcweir 604cdf0e10cSrcweir // Test loadkey 605cdf0e10cSrcweir RegistryKey rootKey2, key21, key22, key23, key24 , key25; 606cdf0e10cSrcweir 607cdf0e10cSrcweir REG_ENSURE(!myRegistry->create(OUString::createFromAscii("test2.rdb")), "test_registry_CppApi error 23"); 608cdf0e10cSrcweir REG_ENSURE(!myRegistry->openRootKey(rootKey2), "test_registry_CppApi error 24"); 609cdf0e10cSrcweir 610cdf0e10cSrcweir REG_ENSURE(!rootKey2.createKey(OUString::createFromAscii("reg2FirstKey"), key21), "test_registry_CppApi error 25"); 611cdf0e10cSrcweir REG_ENSURE(!rootKey2.createKey(OUString::createFromAscii("reg2SecondKey"), key22), "test_registry_CppApi error 26"); 612cdf0e10cSrcweir REG_ENSURE(!key21.createKey(OUString::createFromAscii("reg2FirstSubKey"), key23), "test_registry_CppApi error 27"); 613cdf0e10cSrcweir REG_ENSURE(!key21.createKey(OUString::createFromAscii("reg2SecondSubKey"), key24), "test_registry_CppApi error 28"); 614cdf0e10cSrcweir REG_ENSURE(!rootKey2.createKey(OUString::createFromAscii("reg2ThirdKey"), key25), "test_registry_CppApi error 29"); 615cdf0e10cSrcweir 616cdf0e10cSrcweir sal_uInt32 nValue= 123456789; 617cdf0e10cSrcweir REG_ENSURE(!key23.setValue(OUString(), RG_VALUETYPE_LONG, &nValue, sizeof(sal_uInt32)), "test_registry_CppApi error 30"); 618cdf0e10cSrcweir 619cdf0e10cSrcweir REG_ENSURE(!key21.closeKey() && 620cdf0e10cSrcweir !key22.closeKey() && 621cdf0e10cSrcweir !key23.closeKey() && 622cdf0e10cSrcweir !key24.closeKey() && 623cdf0e10cSrcweir !key25.closeKey() && 624cdf0e10cSrcweir !rootKey2.closeKey(), "test_registry_CppApi error 31"); 625cdf0e10cSrcweir 626cdf0e10cSrcweir REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 32"); 627cdf0e10cSrcweir 628cdf0e10cSrcweir REG_ENSURE(!myRegistry->open(OUString::createFromAscii("test.rdb"), REG_READWRITE), "test_registry_CppApi error 33"); 629cdf0e10cSrcweir REG_ENSURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 34"); 630cdf0e10cSrcweir 631cdf0e10cSrcweir REG_ENSURE(!myRegistry->loadKey(rootKey, OUString::createFromAscii("allFromTest2"), 632cdf0e10cSrcweir OUString::createFromAscii("test2.rdb")), "test_registry_CppApi error 35"); 633cdf0e10cSrcweir REG_ENSURE(!myRegistry->saveKey(rootKey, OUString::createFromAscii("allFromTest2"), 634cdf0e10cSrcweir OUString::createFromAscii("test3.rdb")), "test_registry_CppApi error 36"); 635cdf0e10cSrcweir 636cdf0e10cSrcweir REG_ENSURE(!rootKey.createKey(OUString::createFromAscii("allFromTest3"), key1), "test_registry_CppApi error 37"); 637cdf0e10cSrcweir REG_ENSURE(!key1.createKey(OUString::createFromAscii("myFirstKey2"), key2), "test_registry_CppApi error 38"); 638cdf0e10cSrcweir REG_ENSURE(!key1.createKey(OUString::createFromAscii("mySecondKey2"), key3), "test_registry_CppApi error 39"); 639cdf0e10cSrcweir 640cdf0e10cSrcweir REG_ENSURE(!myRegistry->mergeKey(rootKey, OUString::createFromAscii("allFromTest3"), 641cdf0e10cSrcweir OUString::createFromAscii("test3.rdb")), "test_registry_CppApi error 40"); 642cdf0e10cSrcweir REG_ENSURE(!myRegistry->mergeKey(rootKey, OUString::createFromAscii("allFromTest3"), 643cdf0e10cSrcweir OUString::createFromAscii("ucrtest.rdb"), sal_True), "test_registry_CppApi error 40.a)"); 644cdf0e10cSrcweir 645cdf0e10cSrcweir // REG_ENSURE(myRegistry->mergeKey(rootKey, OUString::createFromAscii("allFromTest3"), OUString::createFromAscii("ucrtest.rdb"), sal_True) 646cdf0e10cSrcweir // == REG_NO_ERROR/*REG_MERGE_CONFLICT*/, "test_registry_CppApi error 40.b)"); 647cdf0e10cSrcweir 648cdf0e10cSrcweir REG_ENSURE(!key1.closeKey() && 649cdf0e10cSrcweir !key2.closeKey(), "test_registry_CppApi error 41"); 650cdf0e10cSrcweir 651cdf0e10cSrcweir const sal_Unicode* wValue= OUString::createFromAscii( "Mein erster Unicode Value" ).getStr(); 652cdf0e10cSrcweir REG_ENSURE(!key3.setValue(OUString(), RG_VALUETYPE_UNICODE, (void*)wValue, 653cdf0e10cSrcweir (rtl_ustr_getLength(wValue)+1)*sizeof(sal_Unicode)), "test_registry_CppApi error 42"); 654cdf0e10cSrcweir 655cdf0e10cSrcweir REG_ENSURE(!key3.closeKey(), "test_registry_CppApi error 43"); 656cdf0e10cSrcweir 657cdf0e10cSrcweir REG_ENSURE(!rootKey.openKey(OUString::createFromAscii("/allFromTest3/reg2FirstKey/reg2FirstSubKey"), key1), 658cdf0e10cSrcweir "test_registry_CppApi error 43.a)"); 659cdf0e10cSrcweir REG_ENSURE(!rootKey.deleteKey(OUString::createFromAscii("/allFromTest3/reg2FirstKey/reg2FirstSubKey")), "test_registry_CppApi error 44"); 660cdf0e10cSrcweir REG_ENSURE(key1.getValueInfo(OUString(), &valueType, &valueSize) == REG_INVALID_KEY, 661cdf0e10cSrcweir "test_registry_CppApi error 44.a)"); 662cdf0e10cSrcweir REG_ENSURE(!key1.closeKey(), "test_registry_CppApi error 44.b)"); 663cdf0e10cSrcweir 664cdf0e10cSrcweir REG_ENSURE(!rootKey.closeKey(), "test_registry_CppApi error 45"); 665cdf0e10cSrcweir 666cdf0e10cSrcweir REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 46"); 667cdf0e10cSrcweir 668cdf0e10cSrcweir REG_ENSURE(!myRegistry->open(OUString::createFromAscii("test.rdb"), REG_READWRITE), "test_registry_CppApi error 47"); 669cdf0e10cSrcweir 670cdf0e10cSrcweir REG_ENSURE(!myRegistry->destroy(OUString::createFromAscii("test2.rdb")), "test_registry_CppApi error 48"); 671cdf0e10cSrcweir // REG_ENSURE(!myRegistry->destroy("test3.rdb"), "test_registry_CppApi error 49"); 672cdf0e10cSrcweir 673cdf0e10cSrcweir Registry *myRegistry2 = new Registry(*myRegistry); 674cdf0e10cSrcweir 675cdf0e10cSrcweir REG_ENSURE(myRegistry->destroy(OUString()), "test_registry_CppApi error 50"); 676cdf0e10cSrcweir 677cdf0e10cSrcweir delete(myRegistry2); 678cdf0e10cSrcweir 679cdf0e10cSrcweir REG_ENSURE(!myRegistry->create(OUString::createFromAscii("destroytest.rdb")), "test_registry_CppApi error 51"); 680cdf0e10cSrcweir REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 52"); 681cdf0e10cSrcweir REG_ENSURE(!myRegistry->open(OUString::createFromAscii("destroytest.rdb"), REG_READONLY), "test_registry_CppApi error 53"); 682cdf0e10cSrcweir REG_ENSURE(!myRegistry->openRootKey(rootKey), "test_registry_CppApi error 54"); 683cdf0e10cSrcweir 684cdf0e10cSrcweir REG_ENSURE(myRegistry->mergeKey(rootKey, OUString::createFromAscii("allFromTest3"), 685cdf0e10cSrcweir OUString::createFromAscii("test3.rdb")), "test_registry_CppApi error 55"); 686cdf0e10cSrcweir REG_ENSURE(!myRegistry->destroy(OUString::createFromAscii("test3.rdb")), "test_registry_CppApi error 56"); 687cdf0e10cSrcweir 688cdf0e10cSrcweir REG_ENSURE(!rootKey.closeKey(), "test_registry_CppApi error 57"); 689cdf0e10cSrcweir REG_ENSURE(!myRegistry->close(), "test_registry_CppApi error 58"); 690cdf0e10cSrcweir REG_ENSURE(!myRegistry->open(OUString::createFromAscii("destroytest.rdb"), REG_READWRITE), "test_registry_CppApi error 59"); 691cdf0e10cSrcweir REG_ENSURE(!myRegistry->destroy(OUString()), "test_registry_CppApi error 60"); 692cdf0e10cSrcweir 693cdf0e10cSrcweir REG_ENSURE(!myRegistry->open(OUString::createFromAscii("test.rdb"), REG_READWRITE), "test_registry_CppApi error 61"); 694cdf0e10cSrcweir REG_ENSURE(!myRegistry->destroy(OUString::createFromAscii("ucrtest.rdb")), "test_registry_CppApi error 62"); 695cdf0e10cSrcweir REG_ENSURE(!myRegistry->destroy(OUString()), "test_registry_CppApi error 63"); 696cdf0e10cSrcweir delete(myRegistry); 697cdf0e10cSrcweir 698cdf0e10cSrcweir cout << "test_registry_CppApi() Ok!\n"; 699cdf0e10cSrcweir 700cdf0e10cSrcweir return; 701cdf0e10cSrcweir } 702cdf0e10cSrcweir 703cdf0e10cSrcweir 704