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 "gtest/gtest.h"
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 ::testing::Test
45 {
46 public:
47 };
48
TEST_F(test_osl_copyFile,cp_file)49 TEST_F(test_osl_copyFile, cp_file)
50 {
51 rtl::OUString src_url;
52 FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii(COPY_SOURCE_PATH), src_url);
53
54 rtl::OUString dest_url;
55 FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii(COPY_DEST_PATH), dest_url);
56
57 FileBase::RC err = File::copy(src_url, dest_url);
58 ASSERT_TRUE(err != FileBase::E_None) << "Copy didn't recognized disk full";
59 }
60
61 //########################################
62 #ifdef UNX
63 # define WRITE_DEST_PATH "/mnt/mercury08/muell.tmp"
64 #else /* if WNT */
65 # define WRITE_DEST_PATH "d:\\tmp_data.tmp"
66 #endif
67
68 class test_osl_writeFile : public ::testing::Test
69 {
70 public:
71 };
72
TEST_F(test_osl_writeFile,wrt_file)73 TEST_F(test_osl_writeFile, wrt_file)
74 {
75 rtl::OUString dest_url;
76 FileBase::getFileURLFromSystemPath(rtl::OUString::createFromAscii(WRITE_DEST_PATH), dest_url);
77
78 File tmp_file(dest_url);
79 rtl::OUString suErrorMsg = rtl::OUString::createFromAscii("File creation failed: ")+ dest_url;
80 FileBase::RC err = tmp_file.open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create);
81
82 ASSERT_TRUE(err == FileBase::E_None || err == FileBase::E_EXIST) << suErrorMsg.pData;
83
84 char buffer[50000];
85 sal_uInt64 written = 0;
86 err = tmp_file.write((void*)buffer, sizeof(buffer), written);
87
88 err = tmp_file.sync();
89
90 ASSERT_TRUE(err != FileBase::E_None) << "Write didn't recognized disk full";
91
92 tmp_file.close();
93 }
94
main(int argc,char ** argv)95 int main(int argc, char **argv)
96 {
97 ::testing::InitGoogleTest(&argc, argv);
98 return RUN_ALL_TESTS();
99 }
100