xref: /AOO41X/main/sal/qa/osl/profile/osl_old_testprofile.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sal.hxx"
30 
31 // LLA:
32 // this file is converted to use with testshl2
33 // original was placed in sal/test/textenc.cxx
34 
35 
36 // -----------------------------------------------------------------------------
37 #include <stdio.h>
38 #include <osl/profile.h>
39 
40 #include "cppunit/TestAssert.h"
41 #include "cppunit/TestFixture.h"
42 #include "cppunit/extensions/HelperMacros.h"
43 #include "cppunit/plugin/TestPlugIn.h"
44 
45 //==================================================================================================
46 // -----------------------------------------------------------------------------
47 namespace osl_Profile
48 {
49     class oldtests : public CppUnit::TestFixture
50     {
51     public:
52         void test_profile();
53 
54         CPPUNIT_TEST_SUITE( oldtests );
55         CPPUNIT_TEST( test_profile );
56         CPPUNIT_TEST_SUITE_END( );
57     };
58 
59 void oldtests::test_profile(void)
60 {
61 	oslProfile hProfile;
62     rtl_uString* ustrProfileName=0;
63     rtl_uString* ustrProfileName2=0;
64 
65     rtl_uString_newFromAscii(&ustrProfileName,"//./tmp/soffice.ini");
66     rtl_uString_newFromAscii(&ustrProfileName2,"//./tmp/not_existing_path/soffice.ini");
67 
68 
69 	// successful write
70     hProfile = osl_openProfile( ustrProfileName, 0 );
71 	if (hProfile != 0)
72 	{
73 		if (! osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
74 			printf( "### cannot write into init file!\n" );
75 
76 		osl_closeProfile( hProfile );
77 	}
78 
79 	// unsuccessful write
80     hProfile = osl_openProfile( ustrProfileName2, 0 );
81 	if (hProfile != 0)
82 	{
83 		if (osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
84 			printf( "### unexpected success writing into test2.ini!\n" );
85 
86 		osl_closeProfile( hProfile );
87 	}
88 
89     rtl_uString_release(ustrProfileName);
90     rtl_uString_release(ustrProfileName2);
91 }
92 
93 } // namespace osl_Profile
94 
95 // -----------------------------------------------------------------------------
96 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Profile::oldtests );
97 
98 // -----------------------------------------------------------------------------
99 CPPUNIT_PLUGIN_IMPLEMENT();
100