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.
18 #include <dali-test-suite-utils.h>
19 #include <dali/internal/event/events/gesture-impl.h>
20 #include <dali/public-api/dali-core.h>
27 void utc_dali_internal_gesture_startup(void)
29 test_return_value = TET_UNDEF;
32 void utc_dali_internal_gesture_cleanup(void)
34 test_return_value = TET_PASS;
39 // TestGesture Struct (Gesture constructor is protected)
40 struct TestGesture : public Internal::Gesture
43 TestGesture(GestureType::Value type, GestureState state)
44 : Gesture(type, state)
48 virtual ~TestGesture()
55 int UtcDaliGestureConstructorP(void)
57 TestApplication application; // Reset all test adapter return codes
60 DALI_TEST_CHECK(!empty);
62 Gesture pan(new TestGesture(GestureType::PAN, GestureState::STARTED));
63 DALI_TEST_EQUALS(GestureType::PAN, pan.GetType(), TEST_LOCATION);
64 DALI_TEST_EQUALS(GestureState::STARTED, pan.GetState(), TEST_LOCATION);
66 Gesture pinch(new TestGesture(GestureType::PINCH, GestureState::CLEAR));
67 DALI_TEST_EQUALS(GestureType::PINCH, pinch.GetType(), TEST_LOCATION);
68 DALI_TEST_EQUALS(GestureState::CLEAR, pinch.GetState(), TEST_LOCATION);
70 // Test copy constructor
72 DALI_TEST_EQUALS(GestureType::PAN, pan2.GetType(), TEST_LOCATION);
73 DALI_TEST_EQUALS(GestureState::STARTED, pan2.GetState(), TEST_LOCATION);
76 // Test move constructor
77 const auto refCount = pan.GetObjectPtr()->ReferenceCount();
78 Gesture pan3(std::move(pan));
79 DALI_TEST_EQUALS(pan, Gesture(), TEST_LOCATION);
80 DALI_TEST_EQUALS(GestureType::PAN, pan3.GetType(), TEST_LOCATION);
81 DALI_TEST_EQUALS(pan3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
86 int UtcDaliGestureAssignmentP(void)
88 TestApplication application; // Reset all test adapter return codes
90 // Test Assignment operator
91 Gesture pan(new TestGesture(GestureType::PAN, GestureState::FINISHED));
92 DALI_TEST_EQUALS(GestureType::PAN, pan.GetType(), TEST_LOCATION);
93 DALI_TEST_EQUALS(GestureState::FINISHED, pan.GetState(), TEST_LOCATION);
95 Gesture test(new TestGesture(GestureType::PINCH, GestureState::STARTED));
96 DALI_TEST_EQUALS(GestureType::PINCH, test.GetType(), TEST_LOCATION);
97 DALI_TEST_EQUALS(GestureState::STARTED, test.GetState(), TEST_LOCATION);
101 DALI_TEST_EQUALS(GestureType::PAN, test.GetType(), TEST_LOCATION);
102 DALI_TEST_EQUALS(GestureState::FINISHED, test.GetState(), TEST_LOCATION);
105 const auto refCount = pan.GetObjectPtr()->ReferenceCount();
107 DALI_TEST_EQUALS(pan3, Gesture(), TEST_LOCATION);
108 pan3 = std::move(pan);
109 DALI_TEST_EQUALS(pan, Gesture(), TEST_LOCATION);
110 DALI_TEST_EQUALS(GestureType::PAN, pan3.GetType(), TEST_LOCATION);
111 DALI_TEST_EQUALS(pan3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
116 int UtcDaliGestureGetTypeP(void)
118 TestApplication application; // Reset all test adapter return codes
120 Gesture pan(new TestGesture(GestureType::PAN, GestureState::STARTED));
121 DALI_TEST_EQUALS(GestureType::PAN, pan.GetType(), TEST_LOCATION);
126 int UtcDaliGestureGetStateP(void)
128 TestApplication application; // Reset all test adapter return codes
130 Gesture pan(new TestGesture(GestureType::PAN, GestureState::STARTED));
131 DALI_TEST_EQUALS(GestureState::STARTED, pan.GetState(), TEST_LOCATION);
133 GetImplementation(pan).SetState(GestureState::FINISHED);
134 DALI_TEST_EQUALS(GestureState::FINISHED, pan.GetState(), TEST_LOCATION);
139 int UtcDaliGestureGetTimeP(void)
141 TestApplication application; // Reset all test adapter return codes
143 Gesture pan(new TestGesture(GestureType::PAN, GestureState::STARTED));
144 DALI_TEST_EQUALS(0, pan.GetTime(), TEST_LOCATION);
146 GetImplementation(pan).SetTime(61282);
147 DALI_TEST_EQUALS(61282, pan.GetTime(), TEST_LOCATION);