1 /*
2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "graphic_config.h"
17
18 #if ENABLE_DEBUG
19 #include "components/root_view.h"
20 #include "dfx/event_injector.h"
21 #include "engines/gfx/gfx_engine_manager.h"
22 #include "ui_test_event_injector.h"
23 #include <string>
24 #if ENABLE_WINDOW
25 #include "window/window.h"
26 #endif
27
28 namespace OHOS {
29 namespace {
30 const int16_t ITEM_H = 50;
31 const int16_t TEXT_H = 29;
32 const int16_t TEXT_W = 250;
33 const int16_t TEST_VIEW_H = 50;
34 const int16_t TEST_VIEW_W = 50;
35 const int16_t GAP = 5;
36 const int16_t TEST_VIEW_GAP = 80;
37 const int16_t TEST_BUTTON_W = 100;
38 const int16_t TEST_BUTTON_H = 30;
39 const int16_t LAYOUT_HEIGHT = 150;
40 const int16_t LAYOUT_WIDTH = 480;
41 const int16_t BLANK = 20;
42 const int16_t SCROLL_WIDTH = 300;
43 const int16_t SCROLL_HEIGHT = 300;
44 const int16_t SCROLL_BUTTON_W = 800;
45 const int16_t SCROLL_BUTTON_H = 400;
46 const int16_t DRAG_TIME_OFFSET = 20;
47 const int16_t RATIO_X = 3;
48 const int16_t RATIO_Y = 10;
49 const int16_t POINT_OFFSET = 4;
50 } // namespace
51
52 class TestEventInjectorView : public UIView, public RootView::OnKeyActListener {
53 public:
TestEventInjectorView()54 TestEventInjectorView() : label_(nullptr) {}
~TestEventInjectorView()55 virtual ~TestEventInjectorView()
56 {
57 RootView::GetInstance()->ClearOnKeyActListener();
58 }
59
InitListener()60 void InitListener()
61 {
62 RootView::GetInstance()->SetOnKeyActListener(this);
63 }
64
OnLongPressEvent(const LongPressEvent & event)65 bool OnLongPressEvent(const LongPressEvent& event) override
66 {
67 if (label_ != nullptr) {
68 label_->SetText("long press!");
69 label_->Invalidate();
70 }
71 return UIView::OnLongPressEvent(event);
72 }
73
OnDragEvent(const DragEvent & event)74 bool OnDragEvent(const DragEvent& event) override
75 {
76 if (label_ != nullptr) {
77 label_->SetText("drag!");
78 label_->Invalidate();
79 }
80 return UIView::OnDragEvent(event);
81 }
82
SetSentence(const char * sentence)83 void SetSentence(const char* sentence)
84 {
85 sentence_ = sentence;
86 }
87
OnClickEvent(const ClickEvent & event)88 bool OnClickEvent(const ClickEvent& event) override
89 {
90 if (label_ != nullptr) {
91 label_->SetText(sentence_);
92 label_->Invalidate();
93 }
94 return UIView::OnClickEvent(event);
95 }
96
OnPressEvent(const PressEvent & event)97 bool OnPressEvent(const PressEvent& event) override
98 {
99 if (label_ != nullptr) {
100 label_->SetText("press!");
101 label_->Invalidate();
102 }
103 return UIView::OnPressEvent(event);
104 }
105
OnReleaseEvent(const ReleaseEvent & event)106 bool OnReleaseEvent(const ReleaseEvent& event) override
107 {
108 if (label_ != nullptr) {
109 label_->SetText("release!");
110 label_->Invalidate();
111 }
112 return UIView::OnReleaseEvent(event);
113 }
114
OnCancelEvent(const CancelEvent & event)115 bool OnCancelEvent(const CancelEvent& event) override
116 {
117 if (label_ != nullptr) {
118 label_->SetText("cancel!");
119 label_->Invalidate();
120 }
121 return UIView::OnCancelEvent(event);
122 }
123
SetLabel(UILabel * label)124 void SetLabel(UILabel* label)
125 {
126 label_ = label;
127 }
128
OnKeyAct(UIView & view,const KeyEvent & event)129 bool OnKeyAct(UIView& view, const KeyEvent& event) override
130 {
131 if (label_ == nullptr) {
132 return false;
133 }
134 label_->SetText("key!");
135 label_->Invalidate();
136 return true;
137 }
138
139 private:
140 UILabel* label_;
141 const char* sentence_ = "click";
142 };
143
SetUp()144 void UITestEventInjector::SetUp()
145 {
146 if (container_ == nullptr) {
147 container_ = new UIScrollView();
148 container_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
149 container_->SetHorizontalScrollState(false);
150 container_->SetThrowDrag(true);
151 }
152 EventInjector::GetInstance()->RegisterEventInjector(EventDataType::POINT_TYPE);
153 EventInjector::GetInstance()->RegisterEventInjector(EventDataType::KEY_TYPE);
154
155 #if ENABLE_WINDOW
156 Window* window = RootView::GetInstance()->GetBoundWindow();
157 if (window != nullptr) {
158 EventInjector::GetInstance()->SetWindowId(window->GetWindowId());
159 }
160 #endif
161 }
162
TearDown()163 void UITestEventInjector::TearDown()
164 {
165 DeleteChildren(container_);
166 container_ = nullptr;
167 layout_ = nullptr;
168 positionX_ = 20; // 20 : start x
169 positionY_ = 20; // 20 : start y
170 if (EventInjector::GetInstance()->IsEventInjectorRegistered(EventDataType::POINT_TYPE)) {
171 EventInjector::GetInstance()->UnregisterEventInjector(EventDataType::POINT_TYPE);
172 }
173 if (EventInjector::GetInstance()->IsEventInjectorRegistered(EventDataType::KEY_TYPE)) {
174 EventInjector::GetInstance()->UnregisterEventInjector(EventDataType::KEY_TYPE);
175 }
176 }
177
GetTestView()178 const UIView* UITestEventInjector::GetTestView()
179 {
180 UIKitEventInjectorClickEvent001();
181 UIKitEventInjectorDragEvent002();
182 UIKitEventInjectorLongPressEvent003();
183 UIKitEventInjectorKeyEvent004();
184
185 SetUpScrollView();
186 UIKitEventInjectorUptoDown005();
187 UIKitEventInjectorDowntoUp006();
188 UIKitEventInjectorLefttoRight007();
189 UIKitEventInjectorRighttoLeft008();
190 UIKitEventInjectorULefttoLRight009();
191 UIKitEventInjectorLRighttoULeft010();
192 IncreaseDragTime();
193 DecreaseDragTime();
194 DragTimeDisplay();
195
196 layout_->LayoutChildren();
197 return container_;
198 }
199
UIKitEventInjectorClickEvent001()200 void UITestEventInjector::UIKitEventInjectorClickEvent001()
201 {
202 clickBtn_ = new UILabelButton();
203 InnerTest("模拟点击事件 ", true, false, false, "click", clickBtn_, clickTestView_);
204 }
205
UIKitEventInjectorDragEvent002()206 void UITestEventInjector::UIKitEventInjectorDragEvent002()
207 {
208 dragBtn_ = new UILabelButton();
209 InnerTest("模拟滑动事件 ", true, true, false, "drag", dragBtn_, dragTestView_);
210 }
211
UIKitEventInjectorLongPressEvent003()212 void UITestEventInjector::UIKitEventInjectorLongPressEvent003()
213 {
214 longPressBtn_ = new UILabelButton();
215 InnerTest("模拟长按事件 ", true, true, true, "long press", longPressBtn_, longPressTestView_);
216 }
217
UIKitEventInjectorKeyEvent004()218 void UITestEventInjector::UIKitEventInjectorKeyEvent004()
219 {
220 keyBtn_ = new UILabelButton();
221 InnerTest("模拟按键输入 ", true, false, false, "key event", keyBtn_, KeyEventTestView_);
222 }
223
UIKitEventInjectorUptoDown005()224 void UITestEventInjector::UIKitEventInjectorUptoDown005()
225 {
226 upToDownBtn_ = new UILabelButton();
227 SetUpButton(upToDownBtn_, "up to down", UI_TEST_UP_TO_DOWN);
228 }
229
UIKitEventInjectorDowntoUp006()230 void UITestEventInjector::UIKitEventInjectorDowntoUp006()
231 {
232 downToUpBtn_ = new UILabelButton();
233 SetUpButton(downToUpBtn_, "down to up", UI_TEST_DOWN_TO_UP);
234 }
235
UIKitEventInjectorLefttoRight007()236 void UITestEventInjector::UIKitEventInjectorLefttoRight007()
237 {
238 leftToRightBtn_ = new UILabelButton();
239 SetUpButton(leftToRightBtn_, "left to right", UI_TEST_LEFT_TO_RIGHT);
240 }
241
UIKitEventInjectorRighttoLeft008()242 void UITestEventInjector::UIKitEventInjectorRighttoLeft008()
243 {
244 rightToLeftBtn_ = new UILabelButton();
245 SetUpButton(rightToLeftBtn_, "right to left", UI_TEST_RIGHT_TO_LEFT);
246 }
247
UIKitEventInjectorULefttoLRight009()248 void UITestEventInjector::UIKitEventInjectorULefttoLRight009()
249 {
250 uLeftTolRightBtn_ = new UILabelButton();
251 SetUpButton(uLeftTolRightBtn_, "uLeft to lRight", UI_TEST_ULEFT_TO_LRIGHT);
252 }
253
UIKitEventInjectorLRighttoULeft010()254 void UITestEventInjector::UIKitEventInjectorLRighttoULeft010()
255 {
256 lRightTouLeftBtn_ = new UILabelButton();
257 SetUpButton(lRightTouLeftBtn_, "lRight to uleft", UI_TEST_LRIGHT_TO_ULEFT);
258 }
259
IncreaseDragTime()260 void UITestEventInjector::IncreaseDragTime()
261 {
262 increaseDragTimeBtn_ = new UILabelButton();
263 SetUpButton(increaseDragTimeBtn_, "increase drag time", UI_TEST_INCREASE_DRAG_TIME);
264 }
265
DecreaseDragTime()266 void UITestEventInjector::DecreaseDragTime()
267 {
268 decreaseDragTimeBtn_ = new UILabelButton();
269 SetUpButton(decreaseDragTimeBtn_, "decrease drag time", UI_TEST_DECREASE_DRAG_TIME);
270 }
271
DragTimeDisplay()272 void UITestEventInjector::DragTimeDisplay()
273 {
274 DragTimeDisplayBtn_ = new UILabelButton();
275 std::string dragTimestr = "dragTime:" + std::to_string(dragTime_);
276 SetUpButton(DragTimeDisplayBtn_, dragTimestr.c_str(), UI_TEST_SET_DRAGE_TIME);
277 }
278
InnerTest(const char * title,bool touchable,bool draggable,bool dragParent,const char * btnTitle,UILabelButton * btn,TestEventInjectorView * & testView)279 void UITestEventInjector::InnerTest(const char* title,
280 bool touchable,
281 bool draggable,
282 bool dragParent,
283 const char* btnTitle,
284 UILabelButton* btn,
285 TestEventInjectorView*& testView)
286 {
287 if ((container_ != nullptr) && (btn != nullptr)) {
288 UILabel* label = new UILabel();
289 container_->Add(label);
290 label->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, positionY_, Screen::GetInstance().GetWidth(),
291 TITLE_LABEL_DEFAULT_HEIGHT);
292 label->SetText(title);
293 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
294 positionY_ += (TEXT_H + GAP);
295 testView = new TestEventInjectorView();
296 testView->InitListener();
297 container_->Add(testView);
298 testView->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, positionY_, TEST_VIEW_W, TEST_VIEW_H);
299 testView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
300 testView->SetTouchable(touchable);
301 testView->SetDraggable(draggable);
302 testView->SetDragParentInstead(dragParent);
303 UILabel* label1 = new UILabel();
304 container_->Add(label1);
305 label1->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE + TEST_VIEW_GAP,
306 positionY_ + 2 * GAP, TEXT_W, TEXT_H); // 2 : ratio
307 label1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
308 testView->SetLabel(label1);
309
310 container_->Add(btn);
311 btn->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE + 3 * TEST_VIEW_GAP, positionY_ + GAP, // 3 : ratio
312 BUTTON_WIDHT2, BUTTON_HEIGHT2);
313 btn->SetText(btnTitle);
314 btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
315 btn->SetOnClickListener(this);
316 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
317 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
318 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
319 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
320 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
321 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
322
323 positionY_ += ITEM_H;
324 }
325 }
326
SetUpScrollView()327 void UITestEventInjector::SetUpScrollView()
328 {
329 if (container_ == nullptr) {
330 return;
331 }
332 UILabel* label = GetTitleLabel("模拟Drag事件测试");
333 container_->Add(label);
334 label->SetPosition(TEXT_DISTANCE_TO_LEFT_SIDE, positionY_);
335 SetLastPos(label);
336
337 scrollTestView_ = new UIScrollView();
338 scrollTestView_->SetIntercept(true);
339 scrollTestView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
340 scrollTestView_->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, positionY_, SCROLL_WIDTH, SCROLL_HEIGHT);
341 if (Screen::GetInstance().GetScreenShape() == ScreenShape::RECTANGLE) {
342 scrollTestView_->SetXScrollBarVisible(true);
343 }
344 scrollTestView_->SetYScrollBarVisible(true);
345 scrollTestView_->SetThrowDrag(true);
346 container_->Add(scrollTestView_);
347 UILabelButton* button1 = new UILabelButton();
348 button1->SetText("button1");
349 button1->SetPosition(0, 0, SCROLL_BUTTON_W, SCROLL_BUTTON_H);
350 UILabelButton* button2 = new UILabelButton();
351 button2->SetText("button2");
352 button2->SetPosition(0, SCROLL_BUTTON_H, SCROLL_BUTTON_W, SCROLL_BUTTON_H);
353 scrollTestView_->Add(button1);
354 scrollTestView_->Add(button2);
355
356 if (layout_ == nullptr) {
357 layout_ = new GridLayout();
358 layout_->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE + SCROLL_WIDTH + GAP, positionY_, LAYOUT_WIDTH, LAYOUT_HEIGHT);
359 container_->Add(layout_);
360 layout_->SetLayoutDirection(LAYOUT_VER);
361 layout_->SetRows(3); // 3 : rows
362 layout_->SetCols(3); // 3 : columns
363 }
364 }
365
SetLastPos(UIView * view)366 void UITestEventInjector::SetLastPos(UIView* view)
367 {
368 if (view == nullptr) {
369 return;
370 }
371 lastX_ = view->GetX();
372 lastY_ = view->GetY() + view->GetHeight();
373 positionY_ = lastY_ + 8 * GAP; /* 8:ratio */
374 }
375
SetUpButton(UILabelButton * btn,const char * title,const char * id)376 void UITestEventInjector::SetUpButton(UILabelButton* btn, const char* title, const char* id)
377 {
378 if (btn == nullptr || title == nullptr || id == nullptr) {
379 return;
380 }
381 layout_->Add(btn);
382 btn->Resize(BUTTON_WIDHT3, BUTTON_HEIGHT3);
383 btn->SetText(title);
384 btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
385 btn->SetOnClickListener(this);
386 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
387 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
388 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
389 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
390 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
391 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
392 btn->SetViewId(id);
393 }
394
SetDragTimeDisplay(uint16_t dragTime)395 void UITestEventInjector::SetDragTimeDisplay(uint16_t dragTime)
396 {
397 std::string dragTimestr = "dragTime:" + std::to_string(dragTime);
398 DragTimeDisplayBtn_->SetText(dragTimestr.c_str());
399 DragTimeDisplayBtn_->Invalidate();
400 }
401
402 /* drag range:0 < x < 300, 62 < y < 362, click range:20 < x < 60, 392 < y < 432 */
OnClick(UIView & view,const ClickEvent & event)403 bool UITestEventInjector::OnClick(UIView& view, const ClickEvent& event)
404 {
405 Point point;
406 Point scrollPoint;
407 if (&view == clickBtn_) {
408 point = {static_cast<int16_t>(clickTestView_->GetRect().GetX() + TEST_VIEW_W / POINT_OFFSET),
409 clickBtn_->GetRect().GetBottom()};
410 EventInjector::GetInstance()->SetClickEvent(point);
411 } else if (&view == dragBtn_) {
412 point = {static_cast<int16_t>(dragTestView_->GetRect().GetX() + TEST_VIEW_W / POINT_OFFSET),
413 dragBtn_->GetRect().GetBottom()};
414 Point endPoint = {static_cast<int16_t>(point.x + (RATIO_X * TEST_VIEW_W) / POINT_OFFSET), point.y};
415 // 80:ms
416 EventInjector::GetInstance()->SetDragEvent(point, endPoint, 80);
417 } else if (&view == longPressBtn_) {
418 point = {static_cast<int16_t>(longPressTestView_->GetRect().GetX() + TEST_VIEW_W / POINT_OFFSET),
419 longPressBtn_->GetRect().GetBottom()};
420 EventInjector::GetInstance()->SetLongPressEvent(point);
421 } else if (&view == keyBtn_) {
422 // 26:key id
423 uint16_t keyId = 26;
424 EventInjector::GetInstance()->SetKeyEvent(keyId, InputDevice::STATE_PRESS);
425 } else if (&view == upToDownBtn_) {
426 scrollPoint = {scrollTestView_->GetRect().GetX(), scrollTestView_->GetRect().GetY()};
427 Point startPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_X),
428 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_Y)};
429 Point endPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_X),
430 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_X)};
431 EventInjector::GetInstance()->SetDragEvent(startPoint, endPoint, dragTime_);
432 } else if (&view == downToUpBtn_) {
433 scrollPoint = {scrollTestView_->GetRect().GetX(), scrollTestView_->GetRect().GetY()};
434 Point startPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_X),
435 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_X)};
436 Point endPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_X),
437 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_Y)};
438 EventInjector::GetInstance()->SetDragEvent(startPoint, endPoint, dragTime_);
439 } else if (&view == leftToRightBtn_) {
440 scrollPoint = {scrollTestView_->GetRect().GetX(), scrollTestView_->GetRect().GetY()};
441 Point startPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_Y),
442 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_X)};
443 Point endPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_X),
444 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_X)};
445 EventInjector::GetInstance()->SetDragEvent(startPoint, endPoint, dragTime_);
446 } else if (&view == rightToLeftBtn_) {
447 scrollPoint = {scrollTestView_->GetRect().GetX(), scrollTestView_->GetRect().GetY()};
448 Point startPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_X),
449 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_X)};
450 Point endPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_Y),
451 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_X)};
452 EventInjector::GetInstance()->SetDragEvent(startPoint, endPoint, dragTime_);
453 } else if (&view == uLeftTolRightBtn_) {
454 scrollPoint = {scrollTestView_->GetRect().GetX(), scrollTestView_->GetRect().GetY()};
455 Point startPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_Y),
456 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_Y)};
457 Point endPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_X),
458 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_X)};
459 EventInjector::GetInstance()->SetDragEvent(startPoint, endPoint, dragTime_);
460 } else if (&view == lRightTouLeftBtn_) {
461 scrollPoint = {scrollTestView_->GetRect().GetX(), scrollTestView_->GetRect().GetY()};
462 Point startPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_X),
463 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_X)};
464 Point endPoint = {static_cast<int16_t>(scrollPoint.x + SCROLL_WIDTH / RATIO_Y),
465 static_cast<int16_t>(scrollPoint.y + SCROLL_HEIGHT / RATIO_Y)};
466 EventInjector::GetInstance()->SetDragEvent(startPoint, endPoint, dragTime_);
467 } else if (&view == increaseDragTimeBtn_) {
468 dragTime_ += DRAG_TIME_OFFSET;
469 SetDragTimeDisplay(dragTime_);
470 } else if (&view == decreaseDragTimeBtn_) {
471 dragTime_ -= DRAG_TIME_OFFSET;
472 SetDragTimeDisplay(dragTime_);
473 }
474 return true;
475 }
476 } // namespace OHOS
477 #endif // ENABLE_DEBUG