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/devel-api/events/touch-event-devel.h>
20 #include <dali/integration-api/events/touch-integ.h>
21 #include <dali/public-api/dali-core.h>
26 void utc_dali_touch_event_startup(void)
28 test_return_value = TET_UNDEF;
31 void utc_dali_touch_event_cleanup(void)
33 test_return_value = TET_PASS;
38 TouchPoint GenerateTouchPoint()
40 return TouchPoint(1, PointState::STARTED, 100.0f, 200.0f);
44 int UtcDaliTouchEventConstructorP(void)
46 TouchEvent touchEvent;
47 DALI_TEST_CHECK(!touchEvent);
51 int UtcDaliTouchEventCopyConstructorP(void)
53 TouchEvent touchEvent = Integration::NewTouchEvent(123u, GenerateTouchPoint());
54 DALI_TEST_CHECK(touchEvent);
56 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
58 TouchEvent touchEvent2(touchEvent);
59 DALI_TEST_CHECK(touchEvent);
60 DALI_TEST_CHECK(touchEvent2);
61 DALI_TEST_EQUALS(touchEvent, touchEvent2, TEST_LOCATION);
62 DALI_TEST_EQUALS(refCount + 1, touchEvent.GetBaseObject().ReferenceCount(), TEST_LOCATION);
67 int UtcDaliTouchEventMoveConstructorP(void)
69 TouchEvent touchEvent = Integration::NewTouchEvent(123u, GenerateTouchPoint());
70 DALI_TEST_CHECK(touchEvent);
72 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
74 TouchEvent touchEvent2(std::move(touchEvent));
75 DALI_TEST_CHECK(!touchEvent);
76 DALI_TEST_CHECK(touchEvent2);
77 DALI_TEST_EQUALS(refCount, touchEvent2.GetBaseObject().ReferenceCount(), TEST_LOCATION);
82 int UtcDaliTouchEventCopyAssignmentP(void)
84 TouchEvent touchEvent = Integration::NewTouchEvent(123u, GenerateTouchPoint());
85 DALI_TEST_CHECK(touchEvent);
87 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
89 TouchEvent touchEvent2;
90 DALI_TEST_CHECK(!touchEvent2);
92 touchEvent2 = touchEvent;
93 DALI_TEST_CHECK(touchEvent);
94 DALI_TEST_CHECK(touchEvent2);
95 DALI_TEST_EQUALS(touchEvent, touchEvent2, TEST_LOCATION);
96 DALI_TEST_EQUALS(refCount + 1, touchEvent.GetBaseObject().ReferenceCount(), TEST_LOCATION);
101 int UtcDaliTouchEventMoveAssignmentP(void)
103 TouchEvent touchEvent = Integration::NewTouchEvent(123u, GenerateTouchPoint());
104 DALI_TEST_CHECK(touchEvent);
106 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
108 TouchEvent touchEvent2;
109 DALI_TEST_CHECK(!touchEvent2);
111 touchEvent2 = std::move(touchEvent);
112 DALI_TEST_CHECK(!touchEvent);
113 DALI_TEST_CHECK(touchEvent2);
114 DALI_TEST_EQUALS(refCount, touchEvent2.GetBaseObject().ReferenceCount(), TEST_LOCATION);
119 int UtcDaliTouchEventCopyConstructorWithPointP(void)
121 Dali::Integration::Point point;
123 Vector2 touchPoint(10.0, 20.0);
124 point.SetDeviceId(1);
125 point.SetState(PointState::DOWN);
126 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
128 TouchEvent touchEvent = Integration::NewTouchEvent(123u, point);
129 DALI_TEST_CHECK(touchEvent);
131 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
133 TouchEvent touchEvent2(touchEvent);
134 DALI_TEST_CHECK(touchEvent);
135 DALI_TEST_CHECK(touchEvent2);
136 DALI_TEST_EQUALS(touchEvent, touchEvent2, TEST_LOCATION);
137 DALI_TEST_EQUALS(refCount + 1, touchEvent.GetBaseObject().ReferenceCount(), TEST_LOCATION);
142 int UtcDaliTouchEventMoveConstructorWithPointP(void)
144 Dali::Integration::Point point;
146 Vector2 touchPoint(10.0, 20.0);
147 point.SetDeviceId(1);
148 point.SetState(PointState::DOWN);
149 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
151 TouchEvent touchEvent = Integration::NewTouchEvent(123u, point);
152 DALI_TEST_CHECK(touchEvent);
154 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
156 TouchEvent touchEvent2(std::move(touchEvent));
157 DALI_TEST_CHECK(!touchEvent);
158 DALI_TEST_CHECK(touchEvent2);
159 DALI_TEST_EQUALS(refCount, touchEvent2.GetBaseObject().ReferenceCount(), TEST_LOCATION);
164 int UtcDaliTouchEventSetTime(void)
166 TestApplication application;
168 TouchEvent touchEvent = Integration::NewTouchEvent(123u, GenerateTouchPoint());
169 DALI_TEST_CHECK(touchEvent);
171 DALI_TEST_EQUALS(123lu, touchEvent.GetTime(), TEST_LOCATION);
173 DevelTouchEvent::SetTime(touchEvent, 200lu);
174 DALI_TEST_EQUALS(200lu, touchEvent.GetTime(), TEST_LOCATION);