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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/internal/event/events/rotation-gesture/rotation-gesture-impl.h>
27 void utc_dali_internal_rotation_gesture_startup(void)
29 test_return_value = TET_UNDEF;
32 void utc_dali_internal_rotation_gesture_cleanup(void)
34 test_return_value = TET_PASS;
37 // Positive test case for a method
38 int UtcDaliRotationGestureConstructor(void)
40 TestApplication application; // Reset all test adapter return codes
42 RotationGesture gesture(new Internal::RotationGesture( Gesture::Started ));
43 DALI_TEST_EQUALS(Gesture::Started, gesture.GetState(), TEST_LOCATION);
44 DALI_TEST_EQUALS(0.0f, gesture.GetRotation().radian, TEST_LOCATION);
45 DALI_TEST_EQUALS(Gesture::Rotation, gesture.GetType(), TEST_LOCATION);
47 RotationGesture gesture2(new Internal::RotationGesture( Gesture::Continuing ));
48 DALI_TEST_EQUALS(Gesture::Continuing, gesture2.GetState(), TEST_LOCATION);
49 DALI_TEST_EQUALS(0.0f, gesture2.GetRotation().radian, TEST_LOCATION);
50 DALI_TEST_EQUALS(Gesture::Rotation, gesture2.GetType(), TEST_LOCATION);
52 RotationGesture gesture3(new Internal::RotationGesture( Gesture::Finished ));
53 DALI_TEST_EQUALS(Gesture::Finished, gesture3.GetState(), TEST_LOCATION);
54 DALI_TEST_EQUALS(0.0f, gesture3.GetRotation().radian, TEST_LOCATION);
55 DALI_TEST_EQUALS(Gesture::Rotation, gesture3.GetType(), TEST_LOCATION);
57 // Test copy constructor
58 GetImplementation( gesture3 ).SetRotation( Radian( 3.0f ));
60 RotationGesture rotation(gesture3);
61 DALI_TEST_EQUALS(Gesture::Finished, rotation.GetState(), TEST_LOCATION);
62 DALI_TEST_EQUALS(3.0f, rotation.GetRotation().radian, TEST_LOCATION);
63 DALI_TEST_EQUALS(Gesture::Rotation, rotation.GetType(), TEST_LOCATION);
65 // Test move constructor
66 const auto refCount = gesture.GetObjectPtr()->ReferenceCount();
67 RotationGesture gesture4( std::move( gesture ) );
68 DALI_TEST_CHECK(!gesture);
69 DALI_TEST_EQUALS(Gesture::Rotation, gesture4.GetType(), TEST_LOCATION);
70 DALI_TEST_EQUALS(gesture4.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
75 int UtcDaliRotationGestureAssignment(void)
77 // Test Assignment operator
78 RotationGesture gesture(new Internal::RotationGesture( Gesture::Started ));
79 DALI_TEST_EQUALS(Gesture::Started, gesture.GetState(), TEST_LOCATION);
80 DALI_TEST_EQUALS(0.0f, gesture.GetRotation().radian, TEST_LOCATION);
81 DALI_TEST_EQUALS(Gesture::Rotation, gesture.GetType(), TEST_LOCATION);
83 RotationGesture gesture2(new Internal::RotationGesture( Gesture::Continuing ));
84 DALI_TEST_EQUALS(Gesture::Continuing, gesture2.GetState(), TEST_LOCATION);
85 DALI_TEST_EQUALS(0.0f, gesture2.GetRotation().radian, TEST_LOCATION);
86 DALI_TEST_EQUALS(Gesture::Rotation, gesture2.GetType(), TEST_LOCATION);
88 GetImplementation( gesture2 ).SetRotation( Radian( 3.0f ));
91 DALI_TEST_EQUALS(Gesture::Continuing, gesture.GetState(), TEST_LOCATION);
92 DALI_TEST_EQUALS(3.0f, gesture.GetRotation().radian, TEST_LOCATION);
93 DALI_TEST_EQUALS(Gesture::Rotation, gesture.GetType(), TEST_LOCATION);
96 const auto refCount = gesture.GetObjectPtr()->ReferenceCount();
97 RotationGesture gesture3;
98 DALI_TEST_EQUALS(gesture3, Gesture(), TEST_LOCATION);
99 gesture3 = std::move(gesture);
100 DALI_TEST_CHECK(!gesture);
101 DALI_TEST_EQUALS(Gesture::Rotation, gesture3.GetType(), TEST_LOCATION);
102 DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
107 int UtcDaliRotationGestureSetGetRotationP(void)
109 RotationGesture gesture(new Internal::RotationGesture(Gesture::Started));
110 DALI_TEST_EQUALS(gesture.GetRotation(), Radian(), TEST_LOCATION);
112 GetImplementation(gesture).SetRotation(Dali::ANGLE_270);
113 DALI_TEST_EQUALS(gesture.GetRotation(), Dali::ANGLE_270, TEST_LOCATION);
118 int UtcDaliRotationGestureSetGetScreenCenterPointP(void)
120 RotationGesture gesture(new Internal::RotationGesture(Gesture::Started));
121 DALI_TEST_EQUALS(gesture.GetScreenCenterPoint(), Vector2::ZERO, TEST_LOCATION);
123 GetImplementation(gesture).SetScreenCenterPoint(Vector2(123.0f,321.0f));
124 DALI_TEST_EQUALS(gesture.GetScreenCenterPoint(), Vector2(123.0f,321.0f), TEST_LOCATION);
129 int UtcDaliRotationGestureSetGetLocalCenterPointP(void)
131 RotationGesture gesture(new Internal::RotationGesture(Gesture::Started));
132 DALI_TEST_EQUALS(gesture.GetLocalCenterPoint(), Vector2::ZERO, TEST_LOCATION);
134 GetImplementation(gesture).SetLocalCenterPoint(Vector2(123.0f,321.0f));
135 DALI_TEST_EQUALS(gesture.GetLocalCenterPoint(), Vector2(123.0f,321.0f), TEST_LOCATION);