Fix SVACE error in render-manager.cpp
[platform/core/uifw/dali-core.git] / automated-tests / src / dali-internal / utc-Dali-Internal-Gesture.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/internal/event/events/gesture-impl.h>
20 #include <dali/public-api/dali-core.h>
21 #include <stdlib.h>
22
23 #include <iostream>
24
25 using namespace Dali;
26
27 void utc_dali_internal_gesture_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void utc_dali_internal_gesture_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37 namespace
38 {
39 // TestGesture Struct (Gesture constructor is protected)
40 struct TestGesture : public Internal::Gesture
41 {
42 public:
43   TestGesture(GestureType::Value type, GestureState state)
44   : Gesture(type, state)
45   {
46   }
47
48   virtual ~TestGesture()
49   {
50   }
51 };
52
53 } // namespace
54
55 int UtcDaliGestureConstructorP(void)
56 {
57   TestApplication application; // Reset all test adapter return codes
58
59   Gesture empty;
60   DALI_TEST_CHECK(!empty);
61
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);
65
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);
69
70   // Test copy constructor
71   Gesture pan2(pan);
72   DALI_TEST_EQUALS(GestureType::PAN, pan2.GetType(), TEST_LOCATION);
73   DALI_TEST_EQUALS(GestureState::STARTED, pan2.GetState(), TEST_LOCATION);
74   END_TEST;
75
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);
82
83   END_TEST;
84 }
85
86 int UtcDaliGestureAssignmentP(void)
87 {
88   TestApplication application; // Reset all test adapter return codes
89
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);
94
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);
98
99   // Copy assignment
100   test = pan;
101   DALI_TEST_EQUALS(GestureType::PAN, test.GetType(), TEST_LOCATION);
102   DALI_TEST_EQUALS(GestureState::FINISHED, test.GetState(), TEST_LOCATION);
103
104   // Move assignment
105   const auto refCount = pan.GetObjectPtr()->ReferenceCount();
106   Gesture    pan3;
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);
112
113   END_TEST;
114 }
115
116 int UtcDaliGestureGetTypeP(void)
117 {
118   TestApplication application; // Reset all test adapter return codes
119
120   Gesture pan(new TestGesture(GestureType::PAN, GestureState::STARTED));
121   DALI_TEST_EQUALS(GestureType::PAN, pan.GetType(), TEST_LOCATION);
122
123   END_TEST;
124 }
125
126 int UtcDaliGestureGetStateP(void)
127 {
128   TestApplication application; // Reset all test adapter return codes
129
130   Gesture pan(new TestGesture(GestureType::PAN, GestureState::STARTED));
131   DALI_TEST_EQUALS(GestureState::STARTED, pan.GetState(), TEST_LOCATION);
132
133   GetImplementation(pan).SetState(GestureState::FINISHED);
134   DALI_TEST_EQUALS(GestureState::FINISHED, pan.GetState(), TEST_LOCATION);
135
136   END_TEST;
137 }
138
139 int UtcDaliGestureGetTimeP(void)
140 {
141   TestApplication application; // Reset all test adapter return codes
142
143   Gesture pan(new TestGesture(GestureType::PAN, GestureState::STARTED));
144   DALI_TEST_EQUALS(0, pan.GetTime(), TEST_LOCATION);
145
146   GetImplementation(pan).SetTime(61282);
147   DALI_TEST_EQUALS(61282, pan.GetTime(), TEST_LOCATION);
148
149   END_TEST;
150 }