2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "test-platform-abstraction.h"
19 #include "dali-test-suite-utils.h"
20 #include <dali/integration-api/bitmap.h>
25 TestPlatformAbstraction::TestPlatformAbstraction()
27 mIsLoadingResult( false ),
30 mSaveFileResult( false ),
31 mSynchronouslyLoadedResource()
36 TestPlatformAbstraction::~TestPlatformAbstraction()
40 ImageDimensions TestPlatformAbstraction::GetClosestImageSize( const std::string& filename,
42 FittingMode::Type fittingMode,
43 SamplingMode::Type samplingMode,
44 bool orientationCorrection )
46 ImageDimensions closestSize = ImageDimensions( mClosestSize );
47 mTrace.PushCall("GetClosestImageSize", "");
51 ImageDimensions TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
53 FittingMode::Type fittingMode,
54 SamplingMode::Type samplingMode,
55 bool orientationCorrection )
57 ImageDimensions closestSize = ImageDimensions( mClosestSize );
58 mTrace.PushCall("GetClosestImageSize", "");
62 Integration::ResourcePointer TestPlatformAbstraction::LoadImageSynchronously( const Integration::BitmapResourceType& resourceType, const std::string& resourcePath )
64 mTrace.PushCall("LoadResourceSynchronously", "");
65 return mSynchronouslyLoadedResource;
68 Integration::BitmapPtr TestPlatformAbstraction::DecodeBuffer( const Integration::BitmapResourceType& resourceType, uint8_t * buffer, size_t size )
70 mTrace.PushCall("DecodeBuffer", "");
71 return mDecodedBitmap;
74 bool TestPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const
76 mTrace.PushCall("LoadShaderBinaryFile", "");
77 if( mLoadFileResult.loadResult )
79 buffer = mLoadFileResult.buffer;
82 return mLoadFileResult.loadResult;
86 /** Call this every test */
87 void TestPlatformAbstraction::Initialize()
91 mIsLoadingResult=false;
92 mSynchronouslyLoadedResource.Reset();
93 mDecodedBitmap.Reset();
96 bool TestPlatformAbstraction::WasCalled(TestFuncEnum func)
100 case LoadResourceSynchronouslyFunc: return mTrace.FindMethod("LoadResourceSynchronously");
101 case LoadShaderBinaryFileFunc: return mTrace.FindMethod("LoadShaderBinaryFile");
102 case SaveShaderBinaryFileFunc: return mTrace.FindMethod("SaveShaderBinaryFile");
107 void TestPlatformAbstraction::SetIsLoadingResult(bool result)
109 mIsLoadingResult = result;
112 void TestPlatformAbstraction::ClearReadyResources()
114 mSynchronouslyLoadedResource.Reset();
115 mDecodedBitmap.Reset();
118 void TestPlatformAbstraction::SetClosestImageSize( const Vector2& size )
120 mClosestSize = ImageDimensions( static_cast<uint32_t>( size.x ), static_cast<uint32_t>( size.y ) );
123 void TestPlatformAbstraction::SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer )
125 mLoadFileResult.loadResult = result;
128 mLoadFileResult.buffer = buffer;
132 void TestPlatformAbstraction::SetSaveFileResult( bool result )
134 mSaveFileResult = result;
137 void TestPlatformAbstraction::SetSynchronouslyLoadedResource( Integration::ResourcePointer resource )
139 mSynchronouslyLoadedResource = resource;
142 void TestPlatformAbstraction::SetDecodedBitmap( Integration::BitmapPtr bitmap )
144 mDecodedBitmap = bitmap;