Dali 3D User Interface Engine
utc-Dali-FileLoader.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include <dali/dali.h>
19 #include <dali-test-suite-utils.h>
20 #include <dali/devel-api/adaptor-framework/file-loader.h>
21 
22 
23 
24 using namespace Dali;
25 
26 
28 {
30 }
31 
33 {
35 }
36 
38 {
39  int errorCode;
40  Dali::Vector<char> buffer;
41 
42  //negative case
43  errorCode = FileLoader::ReadFile( TEST_RESOURCE_DIR "/not_exist.txt", buffer, FileLoader::TEXT );
44 
45  DALI_TEST_CHECK( errorCode == 0 );
46 
47  DALI_TEST_CHECK( buffer.Size() == 0 );
48 
49  //positive case
50  errorCode = FileLoader::ReadFile( TEST_RESOURCE_DIR "/test.txt", buffer, FileLoader::TEXT );
51 
52  DALI_TEST_CHECK( errorCode != 0 );
53 
54  DALI_TEST_CHECK( buffer.Size() > 0 );
55 
56  END_TEST;
57 }
58 
60 {
61  int errorCode;
62  Dali::Vector<char> buffer;
63  std::streampos fileSize = 0;
64 
65  //negative case
66  errorCode = FileLoader::ReadFile( TEST_RESOURCE_DIR "/not_exist.txt", fileSize, buffer, FileLoader::TEXT );
67 
68  DALI_TEST_CHECK( errorCode == 0 );
69 
70  DALI_TEST_CHECK( buffer.Size() == 0 );
71 
72  DALI_TEST_CHECK( fileSize == 0 );
73 
74  //positive case
75  errorCode = FileLoader::ReadFile( TEST_RESOURCE_DIR "/test.txt", fileSize, buffer, FileLoader::TEXT );
76 
77  DALI_TEST_CHECK( errorCode != 0 );
78 
79  DALI_TEST_CHECK( buffer.Size() > 0 );
80 
81  DALI_TEST_CHECK( fileSize != 0 );
82 
83  END_TEST;
84 }
85 
87 {
88  std::streampos fileSize = 0;
89 
90  //negative case
91  fileSize = FileLoader::GetFileSize( TEST_RESOURCE_DIR "/not_exist.txt" );
92 
93  DALI_TEST_CHECK( fileSize == 0 );
94 
95  //positive case
96  fileSize = FileLoader::GetFileSize( TEST_RESOURCE_DIR "/test.txt" );
97 
98  DALI_TEST_CHECK( fileSize != 0 );
99 
100  END_TEST;
101 }
Dali Docs Home
Read more about Dali