Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-RotationGesture.cpp
1 /*
2  * Copyright (c) 2019 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
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali/devel-api/events/gesture-devel.h>
23 #include <dali/devel-api/events/rotation-gesture.h>
24 #include <dali-test-suite-utils.h>
25
26 using namespace Dali;
27
28 void utc_dali_rotation_gesture_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void utc_dali_rotation_gesture_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 // Positive test case for a method
39 int UtcDaliRotationGestureConstructor(void)
40 {
41   TestApplication application; // Reset all test adapter return codes
42
43   RotationGesture gesture(Gesture::Started);
44   DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION);
45   DALI_TEST_EQUALS(0.0f, gesture.rotation.radian, TEST_LOCATION);
46   DALI_TEST_EQUALS(DevelGesture::Rotation, static_cast< DevelGesture::Type >( gesture.type ), TEST_LOCATION);
47
48   RotationGesture gesture2(Gesture::Continuing);
49   DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION);
50   DALI_TEST_EQUALS(0.0f, gesture2.rotation.radian, TEST_LOCATION);
51   DALI_TEST_EQUALS(DevelGesture::Rotation, static_cast< DevelGesture::Type >( gesture2.type ), TEST_LOCATION);
52
53   RotationGesture gesture3(Gesture::Finished);
54   DALI_TEST_EQUALS(Gesture::Finished, gesture3.state, TEST_LOCATION);
55   DALI_TEST_EQUALS(0.0f, gesture3.rotation.radian, TEST_LOCATION);
56   DALI_TEST_EQUALS(DevelGesture::Rotation, static_cast< DevelGesture::Type >( gesture3.type ), TEST_LOCATION);
57
58   // Test copy constructor
59   gesture3.rotation = 3.0f;
60
61   RotationGesture rotation(gesture3);
62   DALI_TEST_EQUALS(Gesture::Finished, rotation.state, TEST_LOCATION);
63   DALI_TEST_EQUALS(3.0f, rotation.rotation.radian, TEST_LOCATION);
64 DALI_TEST_EQUALS(DevelGesture::Rotation, static_cast< DevelGesture::Type >( rotation.type ), TEST_LOCATION);
65   END_TEST;
66 }
67
68 int UtcDaliRotationGestureAssignment(void)
69 {
70   // Test Assignment operator
71   RotationGesture gesture(Gesture::Started);
72   DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION);
73   DALI_TEST_EQUALS(0.0f, gesture.rotation.radian, TEST_LOCATION);
74   DALI_TEST_EQUALS(DevelGesture::Rotation, static_cast< DevelGesture::Type >( gesture.type ), TEST_LOCATION);
75
76   RotationGesture gesture2(Gesture::Continuing);
77   DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION);
78   DALI_TEST_EQUALS(0.0f, gesture2.rotation.radian, TEST_LOCATION);
79   DALI_TEST_EQUALS(DevelGesture::Rotation, static_cast< DevelGesture::Type >( gesture2.type ), TEST_LOCATION);
80
81   gesture2.rotation.radian = 3.0f;
82
83   gesture = gesture2;
84   DALI_TEST_EQUALS(Gesture::Continuing, gesture.state, TEST_LOCATION);
85   DALI_TEST_EQUALS(3.0f, gesture.rotation.radian, TEST_LOCATION);
86   DALI_TEST_EQUALS(DevelGesture::Rotation, static_cast< DevelGesture::Type >( gesture.type ), TEST_LOCATION);
87   END_TEST;
88 }
89
90 int UtcDaliRotationGestureDynamicAllocation(void)
91 {
92   RotationGesture* gesture = new RotationGesture( Gesture::Started );
93   DALI_TEST_EQUALS(Gesture::Started, gesture->state, TEST_LOCATION);
94   DALI_TEST_EQUALS(0.0f, gesture->rotation.radian, TEST_LOCATION);
95   DALI_TEST_EQUALS(DevelGesture::Rotation, static_cast< DevelGesture::Type >( gesture->type ), TEST_LOCATION);
96   delete gesture;
97
98   END_TEST;
99 }