Dali 3D User Interface Engine
test-platform-abstraction.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 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 
19 #include "dali-test-suite-utils.h"
21 
22 namespace Dali
23 {
24 
26 : mTrace(),
27  mIsLoadingResult( false ),
28  mGetDefaultFontSizeResult( 0 ),
29  mResources(),
30  mRequest( NULL ),
31  mSize(),
32  mClosestSize(),
33  mLoadFileResult(),
34  mSaveFileResult( false )
35 {
36  Initialize();
37 }
38 
40 {
41 }
42 
44 {
45  mTrace.PushCall("Suspend", "");
46 }
47 
49 {
50  mTrace.PushCall("Resume", "");
51 }
52 
54  ImageDimensions size,
55  FittingMode::Type fittingMode,
56  SamplingMode::Type samplingMode,
57  bool orientationCorrection )
58 {
60  mTrace.PushCall("GetClosestImageSize", "");
61  return closestSize;
62 }
63 
65  ImageDimensions size,
66  FittingMode::Type fittingMode,
67  SamplingMode::Type samplingMode,
68  bool orientationCorrection )
69 {
71  mTrace.PushCall("GetClosestImageSize", "");
72  return closestSize;
73 }
74 
76 {
77  std::ostringstream out;
78  out << "Type:" << request.GetType()->id << ", Path: " << request.GetPath() << std::endl ;
79 
80  mTrace.PushCall("LoadResource", out.str());
81  if(mRequest != NULL)
82  {
83  delete mRequest;
84  tet_infoline ("Warning: multiple resource requests not handled by Test Suite. You may see unexpected errors");
85  }
87 }
88 
90 {
91  mTrace.PushCall("LoadResourceSynchronously", "");
93 }
94 
95 Integration::BitmapPtr TestPlatformAbstraction::DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t size )
96 {
97  mTrace.PushCall("DecodeBuffer", "");
98  return Integration::BitmapPtr();
99 }
100 
102 {
103  mTrace.PushCall("CancelLoad", "");
104 }
105 
107 {
108  mTrace.PushCall("GetResources", "");
109 
110  if(mResources.loaded)
111  {
113  }
115  {
117  }
118 }
119 
121 {
122  mTrace.PushCall("IsLoading", "");
123  return mIsLoadingResult;
124 }
125 
127 {
128  mTrace.PushCall("GetDefaultFontSize", "");
130 }
131 
132 void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical)
133 {
134  mTrace.PushCall("SetDpi", "");
135 }
136 
137 bool TestPlatformAbstraction::LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const
138 {
139  mTrace.PushCall("LoadFile", "");
141  {
142  buffer = mLoadFileResult.buffer;
143  }
144 
146 }
147 
148 bool TestPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const
149 {
150  mTrace.PushCall("LoadShaderBinaryFile", "");
152  {
153  buffer = mLoadFileResult.buffer;
154  }
155 
157 }
158 
159 bool TestPlatformAbstraction::SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const
160 {
161  mTrace.PushCall("SaveFile", "");
162  return false;
163 }
164 
166 {
167  mTrace.PushCall("JoinLoaderThreads", "");
168 }
169 
172 {
173  mTrace.Reset();
174  mTrace.Enable(true);
175  memset(&mResources, 0, sizeof(Resources));
176  mIsLoadingResult=false;
177 
178  if(mRequest)
179  {
180  delete mRequest;
181  mRequest = 0;
182  }
183 }
184 
185 bool TestPlatformAbstraction::WasCalled(TestFuncEnum func)
186 {
187  switch(func)
188  {
189  case SuspendFunc: return mTrace.FindMethod("Suspend");
190  case ResumeFunc: return mTrace.FindMethod("Resume");
191  case LoadResourceFunc: return mTrace.FindMethod("LoadResource");
192  case LoadFileFunc: return mTrace.FindMethod("LoadFile");
193  case LoadShaderBinaryFileFunc: return mTrace.FindMethod("LoadShaderBinaryFile");
194  case SaveShaderBinaryFileFunc: return mTrace.FindMethod("SaveShaderBinaryFile");
195  case SaveFileFunc: return mTrace.FindMethod("SaveFile");
196  case CancelLoadFunc: return mTrace.FindMethod("CancelLoad");
197  case GetResourcesFunc: return mTrace.FindMethod("GetResources");
198  case IsLoadingFunc: return mTrace.FindMethod("IsLoading");
199  case SetDpiFunc: return mTrace.FindMethod("SetDpi");
200  case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads");
201  }
202  return false;
203 }
204 
206 {
207  mIsLoadingResult = result;
208 }
209 
211 {
212  memset(&mResources, 0, sizeof(Resources));
213 }
214 
216  Integration::ResourceTypeId loadedType,
217  Integration::ResourcePointer loadedResource)
218 {
219  mResources.loaded = true;
220  mResources.loadedId = loadedId;
221  mResources.loadedType = loadedType;
222  mResources.loadedResource = loadedResource;
223 }
224 
227 {
228  mResources.loadFailed = true;
230  mResources.loadFailure = failure;
231 }
232 
234 {
235  return mRequest;
236 }
237 
239 {
240  delete mRequest;
241  mRequest = NULL;
242 }
243 
245 {
246  mClosestSize = size;
247 }
248 
250 {
251  mLoadFileResult.loadResult = result;
252  if( result )
253  {
254  mLoadFileResult.buffer = buffer;
255  }
256 }
257 
259 {
260  mSaveFileResult = result;
261 }
262 
263 } // namespace Dali
Dali Docs Home
Read more about Dali