2 * Copyright (c) 2015 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.
19 #include <dali-test-suite-utils.h>
21 #include <dali/devel-api/images/pixel-data.h>
22 #include <dali/public-api/images/pixel.h>
23 #include <dali/public-api/common/dali-vector.h>
27 int UtcDaliPixelData01(void)
29 TestApplication application;
31 unsigned int width = 10u;
32 unsigned int height = 10u;
33 unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::RGB888 );
35 unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
36 PixelDataPtr pixelData = PixelData::New( buffer, width, height, Pixel::RGB888, PixelData::FREE );
38 DALI_TEST_CHECK( pixelData );
39 DALI_TEST_CHECK( pixelData->GetWidth() == width );
40 DALI_TEST_CHECK( pixelData->GetHeight() == height );
41 DALI_TEST_CHECK( pixelData->GetPixelFormat() == Pixel::RGB888 );
42 DALI_TEST_CHECK( pixelData->GetBuffer() == buffer );
47 int UtcDaliPixelData02(void)
49 TestApplication application;
51 unsigned int width = 10u;
52 unsigned int height = 10u;
53 unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::L8 );
54 unsigned char* buffer = new unsigned char [ bufferSize ];
57 PixelDataPtr pixelData2 = PixelData::New( buffer, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
59 DALI_TEST_CHECK( pixelData2 );
60 DALI_TEST_CHECK( pixelData2->GetBuffer()[0] == 'a' );
63 DALI_TEST_CHECK( pixelData2->GetBuffer()[0] == 'b' );
68 int UtcDaliPixelDataNonCopyable(void)
70 // we want to make sure that PixelData is not copyable (its copy constructor is not defined)
71 // this test will stop compiling if PixelData has compiler generated copy constructor
72 DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( PixelData ) );
74 DALI_TEST_CHECK( true );