2 * Copyright (c) 2020 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 <dali-test-suite-utils.h>
19 #include <dali/devel-api/events/rotation-gesture-devel.h>
20 #include <dali/internal/event/events/rotation-gesture/rotation-gesture-impl.h>
21 #include <dali/public-api/dali-core.h>
28 void utc_dali_internal_rotation_gesture_startup(void)
30 test_return_value = TET_UNDEF;
33 void utc_dali_internal_rotation_gesture_cleanup(void)
35 test_return_value = TET_PASS;
38 // Positive test case for a method
39 int UtcDaliRotationGestureConstructor(void)
41 TestApplication application; // Reset all test adapter return codes
43 RotationGesture gesture = DevelRotationGesture::New(GestureState::STARTED);
44 DALI_TEST_EQUALS(GestureState::STARTED, gesture.GetState(), TEST_LOCATION);
45 DALI_TEST_EQUALS(0.0f, gesture.GetRotation().radian, TEST_LOCATION);
46 DALI_TEST_EQUALS(GestureType::ROTATION, gesture.GetType(), TEST_LOCATION);
48 RotationGesture gesture2 = DevelRotationGesture::New(GestureState::CONTINUING);
49 DALI_TEST_EQUALS(GestureState::CONTINUING, gesture2.GetState(), TEST_LOCATION);
50 DALI_TEST_EQUALS(0.0f, gesture2.GetRotation().radian, TEST_LOCATION);
51 DALI_TEST_EQUALS(GestureType::ROTATION, gesture2.GetType(), TEST_LOCATION);
53 RotationGesture gesture3 = DevelRotationGesture::New(GestureState::FINISHED);
54 DALI_TEST_EQUALS(GestureState::FINISHED, gesture3.GetState(), TEST_LOCATION);
55 DALI_TEST_EQUALS(0.0f, gesture3.GetRotation().radian, TEST_LOCATION);
56 DALI_TEST_EQUALS(GestureType::ROTATION, gesture3.GetType(), TEST_LOCATION);
58 // Test copy constructor
59 GetImplementation(gesture3).SetRotation(Radian(3.0f));
61 RotationGesture rotation(gesture3);
62 DALI_TEST_EQUALS(GestureState::FINISHED, rotation.GetState(), TEST_LOCATION);
63 DALI_TEST_EQUALS(3.0f, rotation.GetRotation().radian, TEST_LOCATION);
64 DALI_TEST_EQUALS(GestureType::ROTATION, rotation.GetType(), TEST_LOCATION);
66 // Test move constructor
67 const auto refCount = gesture.GetObjectPtr()->ReferenceCount();
68 RotationGesture gesture4(std::move(gesture));
69 DALI_TEST_CHECK(!gesture);
70 DALI_TEST_EQUALS(GestureType::ROTATION, gesture4.GetType(), TEST_LOCATION);
71 DALI_TEST_EQUALS(gesture4.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
76 int UtcDaliRotationGestureAssignment(void)
78 // Test Assignment operator
79 RotationGesture gesture = DevelRotationGesture::New(GestureState::STARTED);
80 DALI_TEST_EQUALS(GestureState::STARTED, gesture.GetState(), TEST_LOCATION);
81 DALI_TEST_EQUALS(0.0f, gesture.GetRotation().radian, TEST_LOCATION);
82 DALI_TEST_EQUALS(GestureType::ROTATION, gesture.GetType(), TEST_LOCATION);
84 RotationGesture gesture2 = DevelRotationGesture::New(GestureState::CONTINUING);
85 DALI_TEST_EQUALS(GestureState::CONTINUING, gesture2.GetState(), TEST_LOCATION);
86 DALI_TEST_EQUALS(0.0f, gesture2.GetRotation().radian, TEST_LOCATION);
87 DALI_TEST_EQUALS(GestureType::ROTATION, gesture2.GetType(), TEST_LOCATION);
89 GetImplementation(gesture2).SetRotation(Radian(3.0f));
92 DALI_TEST_EQUALS(GestureState::CONTINUING, gesture.GetState(), TEST_LOCATION);
93 DALI_TEST_EQUALS(3.0f, gesture.GetRotation().radian, TEST_LOCATION);
94 DALI_TEST_EQUALS(GestureType::ROTATION, gesture.GetType(), TEST_LOCATION);
97 const auto refCount = gesture.GetObjectPtr()->ReferenceCount();
98 RotationGesture gesture3;
99 DALI_TEST_EQUALS(gesture3, Gesture(), TEST_LOCATION);
100 gesture3 = std::move(gesture);
101 DALI_TEST_CHECK(!gesture);
102 DALI_TEST_EQUALS(GestureType::ROTATION, gesture3.GetType(), TEST_LOCATION);
103 DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
108 int UtcDaliRotationGestureSetGetRotationP(void)
110 RotationGesture gesture = DevelRotationGesture::New(GestureState::STARTED);
111 DALI_TEST_EQUALS(gesture.GetRotation(), Radian(), TEST_LOCATION);
113 GetImplementation(gesture).SetRotation(Dali::ANGLE_270);
114 DALI_TEST_EQUALS(gesture.GetRotation(), Dali::ANGLE_270, TEST_LOCATION);
119 int UtcDaliRotationGestureSetGetScreenCenterPointP(void)
121 RotationGesture gesture = DevelRotationGesture::New(GestureState::STARTED);
122 DALI_TEST_EQUALS(gesture.GetScreenCenterPoint(), Vector2::ZERO, TEST_LOCATION);
124 GetImplementation(gesture).SetScreenCenterPoint(Vector2(123.0f, 321.0f));
125 DALI_TEST_EQUALS(gesture.GetScreenCenterPoint(), Vector2(123.0f, 321.0f), TEST_LOCATION);
130 int UtcDaliRotationGestureSetGetLocalCenterPointP(void)
132 RotationGesture gesture = DevelRotationGesture::New(GestureState::STARTED);
133 DALI_TEST_EQUALS(gesture.GetLocalCenterPoint(), Vector2::ZERO, TEST_LOCATION);
135 GetImplementation(gesture).SetLocalCenterPoint(Vector2(123.0f, 321.0f));
136 DALI_TEST_EQUALS(gesture.GetLocalCenterPoint(), Vector2(123.0f, 321.0f), TEST_LOCATION);