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