1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sal.hxx" 26 27 #include <testshl/simpleheader.hxx> 28 #include <osl/file.hxx> 29 #include <osl/thread.h> 30 #include <rtl/ustring.hxx> 31 32 using namespace osl; 33 using namespace rtl; 34 35 //######################################## 36 #ifdef UNX 37 # define COPY_SOURCE_PATH "/home/tr109510/ucbhelper.cxx" 38 # define COPY_DEST_PATH "/mnt/mercury08/ucbhelper.cxx" 39 #else /* if WNT */ 40 # define COPY_SOURCE_PATH "d:\\msvcr70.dll" 41 # define COPY_DEST_PATH "x:\\tra\\msvcr70.dll" 42 #endif 43 44 class test_osl_copyFile : public CppUnit::TestFixture 45 { 46 public: 47 void cp_file() 48 { 49 rtl::OUString src_url; 50 FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii(COPY_SOURCE_PATH), src_url); 51 52 rtl::OUString dest_url; 53 FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii(COPY_DEST_PATH), dest_url); 54 55 FileBase::RC err = File::copy(src_url, dest_url); 56 CPPUNIT_ASSERT_MESSAGE("Copy didn't recognized disk full", err != FileBase::E_None); 57 } 58 59 CPPUNIT_TEST_SUITE(test_osl_copyFile); 60 CPPUNIT_TEST(cp_file); 61 CPPUNIT_TEST_SUITE_END(); 62 }; 63 64 //######################################## 65 #ifdef UNX 66 # define WRITE_DEST_PATH "/mnt/mercury08/muell.tmp" 67 #else /* if WNT */ 68 # define WRITE_DEST_PATH "d:\\tmp_data.tmp" 69 #endif 70 71 class test_osl_writeFile : public CppUnit::TestFixture 72 { 73 public: 74 void wrt_file() 75 { 76 rtl::OUString dest_url; 77 FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii(WRITE_DEST_PATH), dest_url); 78 79 File tmp_file(dest_url); 80 rtl::OUString suErrorMsg = rtl::OUString::createFromAscii("File creation failed: ")+ dest_url; 81 FileBase::RC err = tmp_file.open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create); 82 83 CPPUNIT_ASSERT_MESSAGE( suErrorMsg, err == FileBase::E_None || err == FileBase::E_EXIST ); 84 85 char buffer[50000]; 86 sal_uInt64 written = 0; 87 err = tmp_file.write((void*)buffer, sizeof(buffer), written); 88 89 err = tmp_file.sync(); 90 91 CPPUNIT_ASSERT_MESSAGE("Write didn't recognized disk full", err != FileBase::E_None); 92 93 tmp_file.close(); 94 } 95 96 CPPUNIT_TEST_SUITE(test_osl_writeFile); 97 CPPUNIT_TEST(wrt_file); 98 CPPUNIT_TEST_SUITE_END(); 99 }; 100 101 //##################################### 102 // register test suites 103 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_osl_writeFile, "test_osl_writeFile"); 104 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_osl_copyFile, "test_osl_copyFile"); 105 106 NOADDITIONAL; 107 108