9a36354af1eb2e56385b40205837353b74e3595e
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-NativeImage.cpp
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 <iostream>
19 #include <algorithm>
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23 #include <test-native-image.h>
24
25 using namespace Dali;
26
27 void utc_dali_native_image_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void utc_dali_native_image_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37 int UtcDaliNativeImageNew(void)
38 {
39   TestApplication application;
40
41   tet_infoline("UtcDaliNativeImageNew - NativeImage::New(NativeImageInterface&)");
42
43   // invoke default handle constructor
44   NativeImage image;
45   TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
46
47   DALI_TEST_CHECK( !image );
48
49   // initialise handle
50   image = NativeImage::New(*(nativeImage.Get()));
51
52   DALI_TEST_CHECK( image );
53   END_TEST;
54 }
55
56 int UtcDaliNativeImageDownCast(void)
57 {
58   TestApplication application;
59   tet_infoline("Testing Dali::Image::DownCast()");
60
61   TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
62   NativeImage image = NativeImage::New(*(nativeImage.Get()));
63
64   BaseHandle object(image);
65
66   NativeImage image2 = NativeImage::DownCast(object);
67   DALI_TEST_CHECK(image2);
68
69   NativeImage image3 = DownCast< NativeImage >(object);
70   DALI_TEST_CHECK(image3);
71
72   BaseHandle unInitializedObject;
73   NativeImage image4 = NativeImage::DownCast(unInitializedObject);
74   DALI_TEST_CHECK(!image4);
75
76   NativeImage image5 = DownCast< NativeImage >(unInitializedObject);
77   DALI_TEST_CHECK(!image5);
78
79   Image image6 = NativeImage::New(*(nativeImage.Get()));
80   NativeImage image7 = NativeImage::DownCast(image6);
81   DALI_TEST_CHECK(image7);
82   END_TEST;
83 }