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/integration-api/events/touch-integ.h>
20 #include <dali/public-api/dali-core.h>
25 void utc_dali_touch_event_startup(void)
27 test_return_value = TET_UNDEF;
30 void utc_dali_touch_event_cleanup(void)
32 test_return_value = TET_PASS;
37 TouchPoint GenerateTouchPoint()
39 return TouchPoint(1, PointState::STARTED, 100.0f, 200.0f);
43 int UtcDaliTouchEventConstructorP(void)
45 TouchEvent touchEvent;
46 DALI_TEST_CHECK(!touchEvent);
50 int UtcDaliTouchEventCopyConstructorP(void)
52 TouchEvent touchEvent = Integration::NewTouchEvent(123u, GenerateTouchPoint());
53 DALI_TEST_CHECK(touchEvent);
55 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
57 TouchEvent touchEvent2(touchEvent);
58 DALI_TEST_CHECK(touchEvent);
59 DALI_TEST_CHECK(touchEvent2);
60 DALI_TEST_EQUALS(touchEvent, touchEvent2, TEST_LOCATION);
61 DALI_TEST_EQUALS(refCount + 1, touchEvent.GetBaseObject().ReferenceCount(), TEST_LOCATION);
66 int UtcDaliTouchEventMoveConstructorP(void)
68 TouchEvent touchEvent = Integration::NewTouchEvent(123u, GenerateTouchPoint());
69 DALI_TEST_CHECK(touchEvent);
71 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
73 TouchEvent touchEvent2(std::move(touchEvent));
74 DALI_TEST_CHECK(!touchEvent);
75 DALI_TEST_CHECK(touchEvent2);
76 DALI_TEST_EQUALS(refCount, touchEvent2.GetBaseObject().ReferenceCount(), TEST_LOCATION);
81 int UtcDaliTouchEventCopyAssignmentP(void)
83 TouchEvent touchEvent = Integration::NewTouchEvent(123u, GenerateTouchPoint());
84 DALI_TEST_CHECK(touchEvent);
86 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
88 TouchEvent touchEvent2;
89 DALI_TEST_CHECK(!touchEvent2);
91 touchEvent2 = touchEvent;
92 DALI_TEST_CHECK(touchEvent);
93 DALI_TEST_CHECK(touchEvent2);
94 DALI_TEST_EQUALS(touchEvent, touchEvent2, TEST_LOCATION);
95 DALI_TEST_EQUALS(refCount + 1, touchEvent.GetBaseObject().ReferenceCount(), TEST_LOCATION);
100 int UtcDaliTouchEventMoveAssignmentP(void)
102 TouchEvent touchEvent = Integration::NewTouchEvent(123u, GenerateTouchPoint());
103 DALI_TEST_CHECK(touchEvent);
105 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
107 TouchEvent touchEvent2;
108 DALI_TEST_CHECK(!touchEvent2);
110 touchEvent2 = std::move(touchEvent);
111 DALI_TEST_CHECK(!touchEvent);
112 DALI_TEST_CHECK(touchEvent2);
113 DALI_TEST_EQUALS(refCount, touchEvent2.GetBaseObject().ReferenceCount(), TEST_LOCATION);
118 int UtcDaliTouchEventCopyConstructorWithPointP(void)
120 Dali::Integration::Point point;
122 Vector2 touchPoint(10.0, 20.0);
123 point.SetDeviceId(1);
124 point.SetState(PointState::DOWN);
125 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
127 TouchEvent touchEvent = Integration::NewTouchEvent(123u, point);
128 DALI_TEST_CHECK(touchEvent);
130 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
132 TouchEvent touchEvent2(touchEvent);
133 DALI_TEST_CHECK(touchEvent);
134 DALI_TEST_CHECK(touchEvent2);
135 DALI_TEST_EQUALS(touchEvent, touchEvent2, TEST_LOCATION);
136 DALI_TEST_EQUALS(refCount + 1, touchEvent.GetBaseObject().ReferenceCount(), TEST_LOCATION);
141 int UtcDaliTouchEventMoveConstructorWithPointP(void)
143 Dali::Integration::Point point;
145 Vector2 touchPoint(10.0, 20.0);
146 point.SetDeviceId(1);
147 point.SetState(PointState::DOWN);
148 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
150 TouchEvent touchEvent = Integration::NewTouchEvent(123u, point);
151 DALI_TEST_CHECK(touchEvent);
153 const auto refCount = touchEvent.GetBaseObject().ReferenceCount();
155 TouchEvent touchEvent2(std::move(touchEvent));
156 DALI_TEST_CHECK(!touchEvent);
157 DALI_TEST_CHECK(touchEvent2);
158 DALI_TEST_EQUALS(refCount, touchEvent2.GetBaseObject().ReferenceCount(), TEST_LOCATION);