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/gesture-impl.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;
40 // TestGesture Struct (Gesture constructor is protected)
41 struct TestGesture : public Internal::Gesture
44 TestGesture(Gesture::Type type, Gesture::State state)
45 : Gesture(type, state) {}
47 virtual ~TestGesture() {}
52 int UtcDaliGestureConstructorP(void)
54 TestApplication application; // Reset all test adapter return codes
57 DALI_TEST_CHECK( !empty );
59 Gesture pan( new TestGesture(Gesture::Pan, Gesture::Started) );
60 DALI_TEST_EQUALS(Gesture::Pan, pan.GetType(), TEST_LOCATION);
61 DALI_TEST_EQUALS(Gesture::Started, pan.GetState(), TEST_LOCATION);
63 Gesture pinch( new TestGesture(Gesture::Pinch, Gesture::Clear) );
64 DALI_TEST_EQUALS(Gesture::Pinch, pinch.GetType(), TEST_LOCATION);
65 DALI_TEST_EQUALS(Gesture::Clear, pinch.GetState(), TEST_LOCATION);
67 // Test copy constructor
69 DALI_TEST_EQUALS(Gesture::Pan, pan2.GetType(), TEST_LOCATION);
70 DALI_TEST_EQUALS(Gesture::Started, pan2.GetState(), TEST_LOCATION);
73 // Test move constructor
74 const auto refCount = pan.GetObjectPtr()->ReferenceCount();
75 Gesture pan3( std::move( pan ) );
76 DALI_TEST_EQUALS(pan, Gesture(), TEST_LOCATION);
77 DALI_TEST_EQUALS(Gesture::Pan, pan3.GetType(), TEST_LOCATION);
78 DALI_TEST_EQUALS(pan3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
83 int UtcDaliGestureAssignmentP(void)
85 TestApplication application; // Reset all test adapter return codes
87 // Test Assignment operator
88 Gesture pan( new TestGesture(Gesture::Pan, Gesture::Finished) );
89 DALI_TEST_EQUALS(Gesture::Pan, pan.GetType(), TEST_LOCATION);
90 DALI_TEST_EQUALS(Gesture::Finished, pan.GetState(), TEST_LOCATION);
92 Gesture test( new TestGesture(Gesture::Pinch, Gesture::Started) );
93 DALI_TEST_EQUALS(Gesture::Pinch, test.GetType(), TEST_LOCATION);
94 DALI_TEST_EQUALS(Gesture::Started, test.GetState(), TEST_LOCATION);
98 DALI_TEST_EQUALS(Gesture::Pan, test.GetType(), TEST_LOCATION);
99 DALI_TEST_EQUALS(Gesture::Finished, test.GetState(), TEST_LOCATION);
102 const auto refCount = pan.GetObjectPtr()->ReferenceCount();
104 DALI_TEST_EQUALS(pan3, Gesture(), TEST_LOCATION);
105 pan3 = std::move(pan);
106 DALI_TEST_EQUALS(pan, Gesture(), TEST_LOCATION);
107 DALI_TEST_EQUALS(Gesture::Pan, pan3.GetType(), TEST_LOCATION);
108 DALI_TEST_EQUALS(pan3.GetBaseObject().ReferenceCount(), refCount, TEST_LOCATION);
113 int UtcDaliGestureGetTypeP(void)
115 TestApplication application; // Reset all test adapter return codes
117 Gesture pan( new TestGesture(Gesture::Pan, Gesture::Started) );
118 DALI_TEST_EQUALS(Gesture::Pan, pan.GetType(), TEST_LOCATION);
123 int UtcDaliGestureGetStateP(void)
125 TestApplication application; // Reset all test adapter return codes
127 Gesture pan( new TestGesture(Gesture::Pan, Gesture::Started) );
128 DALI_TEST_EQUALS(Gesture::Started, pan.GetState(), TEST_LOCATION);
130 GetImplementation(pan).SetState(Gesture::Finished);
131 DALI_TEST_EQUALS(Gesture::Finished, pan.GetState(), TEST_LOCATION);
136 int UtcDaliGestureGetTimeP(void)
138 TestApplication application; // Reset all test adapter return codes
140 Gesture pan( new TestGesture(Gesture::Pan, Gesture::Started) );
141 DALI_TEST_EQUALS(0, pan.GetTime(), TEST_LOCATION);
143 GetImplementation(pan).SetTime(61282);
144 DALI_TEST_EQUALS(61282, pan.GetTime(), TEST_LOCATION);