2 * Copyright (c) 2014 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/long-press-gesture/long-press-gesture-impl.h>
27 void utc_dali_internal_long_press_gesture_startup(void)
29 test_return_value = TET_UNDEF;
32 void utc_dali_internal_long_press_gesture_cleanup(void)
34 test_return_value = TET_PASS;
37 int UtcDaliLongPressGestureConstructorP(void)
39 TestApplication application;
41 LongPressGesture gesture(new Internal::LongPressGesture( Gesture::Started ));
42 DALI_TEST_EQUALS(1u, gesture.GetNumberOfTouches(), TEST_LOCATION);
43 DALI_TEST_EQUALS(Gesture::LongPress, gesture.GetType(), TEST_LOCATION);
45 // Test Copy constructor
46 GetImplementation( gesture ).SetNumberOfTouches( 5u );
48 LongPressGesture gesture2(gesture);
49 DALI_TEST_EQUALS(5u, gesture2.GetNumberOfTouches(), TEST_LOCATION);
50 DALI_TEST_EQUALS(Gesture::LongPress, gesture2.GetType(), TEST_LOCATION);
51 DALI_TEST_EQUALS(Gesture::Started, gesture2.GetState(), TEST_LOCATION);
53 // Test move constructor
54 const auto refCount = gesture.GetObjectPtr()->ReferenceCount();
55 LongPressGesture gesture3( std::move( gesture ) );
56 DALI_TEST_EQUALS(gesture, LongPressGesture(), TEST_LOCATION);
57 DALI_TEST_EQUALS(Gesture::LongPress, gesture3.GetType(), TEST_LOCATION);
58 DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
63 int UtcDaliLongPressGestureAssignmentP(void)
65 // Test Assignment operator
66 LongPressGesture gesture(new Internal::LongPressGesture( Gesture::Started ));
67 DALI_TEST_EQUALS(1u, gesture.GetNumberOfTouches(), TEST_LOCATION);
68 DALI_TEST_EQUALS(Gesture::LongPress, gesture.GetType(), TEST_LOCATION);
70 GetImplementation( gesture ).SetNumberOfTouches( 5u );
72 LongPressGesture gesture2(new Internal::LongPressGesture( Gesture::Finished ));
73 DALI_TEST_EQUALS(Gesture::Finished, gesture2.GetState(), TEST_LOCATION);
75 DALI_TEST_EQUALS(5u, gesture2.GetNumberOfTouches(), TEST_LOCATION);
76 DALI_TEST_EQUALS(Gesture::LongPress, gesture2.GetType(), TEST_LOCATION);
77 DALI_TEST_EQUALS(Gesture::Started, gesture2.GetState(), TEST_LOCATION);
80 const auto refCount = gesture.GetObjectPtr()->ReferenceCount();
81 LongPressGesture gesture3;
82 DALI_TEST_EQUALS(gesture3, Gesture(), TEST_LOCATION);
83 gesture3 = std::move(gesture);
84 DALI_TEST_EQUALS(gesture, Gesture(), TEST_LOCATION);
85 DALI_TEST_EQUALS(Gesture::LongPress, gesture3.GetType(), TEST_LOCATION);
86 DALI_TEST_EQUALS(gesture3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
91 int UtcDaliLongPressGestureGetNumberOfTouchesP(void)
93 TestApplication application;
95 LongPressGesture gesture(new Internal::LongPressGesture(Gesture::Started));
96 DALI_TEST_EQUALS(gesture.GetNumberOfTouches(), 1, TEST_LOCATION);
98 GetImplementation(gesture).SetNumberOfTouches(4);
99 DALI_TEST_EQUALS(gesture.GetNumberOfTouches(), 4, TEST_LOCATION);
104 int UtcDaliLongPressGestureGetScreenPointP(void)
106 TestApplication application;
108 LongPressGesture gesture(new Internal::LongPressGesture(Gesture::Started));
109 DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2::ZERO , TEST_LOCATION);
110 DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2::ZERO , TEST_LOCATION);
112 GetImplementation(gesture).SetScreenPoint(Vector2(100.0f, 300.0f));
113 DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2(100.0f, 300.0f), TEST_LOCATION);
114 DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2::ZERO , TEST_LOCATION);
119 int UtcDaliLongPressGestureGetLocalPointP(void)
121 TestApplication application;
123 LongPressGesture gesture(new Internal::LongPressGesture(Gesture::Started));
124 DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2::ZERO , TEST_LOCATION);
125 DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2::ZERO , TEST_LOCATION);
127 GetImplementation(gesture).SetLocalPoint(Vector2(100.0f, 300.0f));
128 DALI_TEST_EQUALS(gesture.GetLocalPoint(), Vector2(100.0f, 300.0f), TEST_LOCATION);
129 DALI_TEST_EQUALS(gesture.GetScreenPoint(), Vector2::ZERO , TEST_LOCATION);