1*87d2adbcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*87d2adbcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*87d2adbcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*87d2adbcSAndrew Rist * distributed with this work for additional information
6*87d2adbcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*87d2adbcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*87d2adbcSAndrew Rist * "License"); you may not use this file except in compliance
9*87d2adbcSAndrew Rist * with the License. You may obtain a copy of the License at
10*87d2adbcSAndrew Rist *
11*87d2adbcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*87d2adbcSAndrew Rist *
13*87d2adbcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*87d2adbcSAndrew Rist * software distributed under the License is distributed on an
15*87d2adbcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*87d2adbcSAndrew Rist * KIND, either express or implied. See the License for the
17*87d2adbcSAndrew Rist * specific language governing permissions and limitations
18*87d2adbcSAndrew Rist * under the License.
19*87d2adbcSAndrew Rist *
20*87d2adbcSAndrew Rist *************************************************************/
21*87d2adbcSAndrew Rist
22*87d2adbcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sal.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // LLA:
28cdf0e10cSrcweir // this file is converted to use with testshl2
29cdf0e10cSrcweir // original was placed in sal/test/textenc.cxx
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir // -----------------------------------------------------------------------------
33cdf0e10cSrcweir #include <stdio.h>
34cdf0e10cSrcweir #include <osl/profile.h>
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include "cppunit/TestAssert.h"
37cdf0e10cSrcweir #include "cppunit/TestFixture.h"
38cdf0e10cSrcweir #include "cppunit/extensions/HelperMacros.h"
39cdf0e10cSrcweir #include "cppunit/plugin/TestPlugIn.h"
40cdf0e10cSrcweir
41cdf0e10cSrcweir //==================================================================================================
42cdf0e10cSrcweir // -----------------------------------------------------------------------------
43cdf0e10cSrcweir namespace osl_Profile
44cdf0e10cSrcweir {
45cdf0e10cSrcweir class oldtests : public CppUnit::TestFixture
46cdf0e10cSrcweir {
47cdf0e10cSrcweir public:
48cdf0e10cSrcweir void test_profile();
49cdf0e10cSrcweir
50cdf0e10cSrcweir CPPUNIT_TEST_SUITE( oldtests );
51cdf0e10cSrcweir CPPUNIT_TEST( test_profile );
52cdf0e10cSrcweir CPPUNIT_TEST_SUITE_END( );
53cdf0e10cSrcweir };
54cdf0e10cSrcweir
test_profile(void)55cdf0e10cSrcweir void oldtests::test_profile(void)
56cdf0e10cSrcweir {
57cdf0e10cSrcweir oslProfile hProfile;
58cdf0e10cSrcweir rtl_uString* ustrProfileName=0;
59cdf0e10cSrcweir rtl_uString* ustrProfileName2=0;
60cdf0e10cSrcweir
61cdf0e10cSrcweir rtl_uString_newFromAscii(&ustrProfileName,"//./tmp/soffice.ini");
62cdf0e10cSrcweir rtl_uString_newFromAscii(&ustrProfileName2,"//./tmp/not_existing_path/soffice.ini");
63cdf0e10cSrcweir
64cdf0e10cSrcweir
65cdf0e10cSrcweir // successful write
66cdf0e10cSrcweir hProfile = osl_openProfile( ustrProfileName, 0 );
67cdf0e10cSrcweir if (hProfile != 0)
68cdf0e10cSrcweir {
69cdf0e10cSrcweir if (! osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
70cdf0e10cSrcweir printf( "### cannot write into init file!\n" );
71cdf0e10cSrcweir
72cdf0e10cSrcweir osl_closeProfile( hProfile );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir // unsuccessful write
76cdf0e10cSrcweir hProfile = osl_openProfile( ustrProfileName2, 0 );
77cdf0e10cSrcweir if (hProfile != 0)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir if (osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
80cdf0e10cSrcweir printf( "### unexpected success writing into test2.ini!\n" );
81cdf0e10cSrcweir
82cdf0e10cSrcweir osl_closeProfile( hProfile );
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir rtl_uString_release(ustrProfileName);
86cdf0e10cSrcweir rtl_uString_release(ustrProfileName2);
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir } // namespace osl_Profile
90cdf0e10cSrcweir
91cdf0e10cSrcweir // -----------------------------------------------------------------------------
92cdf0e10cSrcweir CPPUNIT_TEST_SUITE_REGISTRATION( osl_Profile::oldtests );
93cdf0e10cSrcweir
94cdf0e10cSrcweir // -----------------------------------------------------------------------------
95cdf0e10cSrcweir CPPUNIT_PLUGIN_IMPLEMENT();
96