mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-11-23 15:40:16 +00:00
Merge master
Signed-off-by: wuliangdong <wuliangdong1@huawei.com> Change-Id: I5d8720b9c698cadca95c05df6ecf89c5b7542451
This commit is contained in:
commit
d1fcbe18f2
@ -47,6 +47,7 @@ constexpr int32_t TIME_WAIT_FOR_OP_MS { 20 };
|
|||||||
constexpr int32_t TIME_WAIT_FOR_INJECT_MS { 80 };
|
constexpr int32_t TIME_WAIT_FOR_INJECT_MS { 80 };
|
||||||
constexpr int32_t TIME_WAIT_FOR_TOUCH_DOWN_MS { 1000 };
|
constexpr int32_t TIME_WAIT_FOR_TOUCH_DOWN_MS { 1000 };
|
||||||
constexpr int32_t PROMISE_WAIT_SPAN_MS { 2000 };
|
constexpr int32_t PROMISE_WAIT_SPAN_MS { 2000 };
|
||||||
|
constexpr int32_t TIME_WAIT_FOR_NOTIFY_LINSTER { 100 };
|
||||||
constexpr int32_t TEST_PIXEL_MAP_WIDTH { 200 };
|
constexpr int32_t TEST_PIXEL_MAP_WIDTH { 200 };
|
||||||
constexpr int32_t TEST_PIXEL_MAP_HEIGHT { 200 };
|
constexpr int32_t TEST_PIXEL_MAP_HEIGHT { 200 };
|
||||||
constexpr int32_t MAX_PIXEL_MAP_WIDTH { 600 };
|
constexpr int32_t MAX_PIXEL_MAP_WIDTH { 600 };
|
||||||
@ -76,6 +77,7 @@ constexpr int32_t RADIUS_IN { 42 };
|
|||||||
constexpr int32_t RADIUS_OUT { 42 };
|
constexpr int32_t RADIUS_OUT { 42 };
|
||||||
constexpr int32_t ALPHA_IN { 51 };
|
constexpr int32_t ALPHA_IN { 51 };
|
||||||
constexpr int32_t ALPHA_OUT { 0 };
|
constexpr int32_t ALPHA_OUT { 0 };
|
||||||
|
constexpr int64_t DOWN_TIME { 1 };
|
||||||
const std::string UD_KEY { "Unified data key" };
|
const std::string UD_KEY { "Unified data key" };
|
||||||
const std::string EXTRA_INFO { "{ \"drag_allow_distributed\" : false }" };
|
const std::string EXTRA_INFO { "{ \"drag_allow_distributed\" : false }" };
|
||||||
const std::string SYSTEM_CORE { "system_core" };
|
const std::string SYSTEM_CORE { "system_core" };
|
||||||
@ -87,6 +89,7 @@ int32_t g_screenHeight { 1280 };
|
|||||||
uint64_t g_tokenID { 0 };
|
uint64_t g_tokenID { 0 };
|
||||||
const char *g_cores[] = { "ohos.permission.INPUT_MONITORING" };
|
const char *g_cores[] = { "ohos.permission.INPUT_MONITORING" };
|
||||||
const char *g_basics[] = { "ohos.permission.COOPERATE_MANAGER" };
|
const char *g_basics[] = { "ohos.permission.COOPERATE_MANAGER" };
|
||||||
|
std::shared_ptr<MMI::KeyEvent> g_keyEvent = MMI::KeyEvent::Create();
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class InteractionManagerTest : public testing::Test {
|
class InteractionManagerTest : public testing::Test {
|
||||||
@ -104,15 +107,22 @@ public:
|
|||||||
int32_t deviceId, const std::pair<int32_t, int32_t> &displayLocation, bool isPressed);
|
int32_t deviceId, const std::pair<int32_t, int32_t> &displayLocation, bool isPressed);
|
||||||
static std::shared_ptr<MMI::PointerEvent> SetupPointerEvent(const std::pair<int32_t, int32_t> &displayLocation,
|
static std::shared_ptr<MMI::PointerEvent> SetupPointerEvent(const std::pair<int32_t, int32_t> &displayLocation,
|
||||||
int32_t action, int32_t sourceType, int32_t pointerId, bool isPressed);
|
int32_t action, int32_t sourceType, int32_t pointerId, bool isPressed);
|
||||||
static void SimulateDownEvent(const std::pair<int32_t, int32_t> &location, int32_t sourceType, int32_t pointerId);
|
static void SimulateDownPointerEvent(
|
||||||
static void SimulateUpEvent(const std::pair<int32_t, int32_t> &location, int32_t sourceType, int32_t pointerId);
|
const std::pair<int32_t, int32_t> &location, int32_t sourceType, int32_t pointerId);
|
||||||
static void SimulateMoveEvent(const std::pair<int32_t, int32_t> &srcLocation, const std::pair<int32_t, int32_t>
|
static void SimulateUpPointerEvent(
|
||||||
&dstLocation, int32_t sourceType, int32_t pointerId, bool isPressed);
|
const std::pair<int32_t, int32_t> &location, int32_t sourceType, int32_t pointerId);
|
||||||
|
static void SimulateMovePointerEvent(const std::pair<int32_t, int32_t> &srcLocation,
|
||||||
|
const std::pair<int32_t, int32_t> &dstLocation, int32_t sourceType, int32_t pointerId, bool isPressed);
|
||||||
static int32_t TestAddMonitor(std::shared_ptr<MMI::IInputEventConsumer> consumer);
|
static int32_t TestAddMonitor(std::shared_ptr<MMI::IInputEventConsumer> consumer);
|
||||||
static void TestRemoveMonitor(int32_t monitorId);
|
static void TestRemoveMonitor(int32_t monitorId);
|
||||||
static void PrintDragData(const DragData &dragData);
|
static void PrintDragData(const DragData &dragData);
|
||||||
static void SetPermission(const std::string &level, const char** perms, size_t permAmount);
|
static void SetPermission(const std::string &level, const char** perms, size_t permAmount);
|
||||||
static void RemovePermission();
|
static void RemovePermission();
|
||||||
|
static void SetupKeyEvent(int32_t action, int32_t key, bool isPressed);
|
||||||
|
static void ClearUpKeyEvent();
|
||||||
|
static void SimulateDownKeyEvent(int32_t key);
|
||||||
|
static void SimulateUpKeyEvent(int32_t key);
|
||||||
|
static void PrintDragAction(DragAction dragAction);
|
||||||
};
|
};
|
||||||
|
|
||||||
void InteractionManagerTest::SetPermission(const std::string &level, const char** perms, size_t permAmount)
|
void InteractionManagerTest::SetPermission(const std::string &level, const char** perms, size_t permAmount)
|
||||||
@ -151,7 +161,7 @@ void InteractionManagerTest::RemovePermission()
|
|||||||
class DragListenerTest : public IDragListener {
|
class DragListenerTest : public IDragListener {
|
||||||
public:
|
public:
|
||||||
DragListenerTest() {}
|
DragListenerTest() {}
|
||||||
explicit DragListenerTest(std::string name) : moduleName_(name) {}
|
explicit DragListenerTest(const std::string& name) : moduleName_(name) {}
|
||||||
void OnDragMessage(DragState state) override
|
void OnDragMessage(DragState state) override
|
||||||
{
|
{
|
||||||
if (moduleName_.empty()) {
|
if (moduleName_.empty()) {
|
||||||
@ -182,9 +192,15 @@ private:
|
|||||||
class SubscriptListenerTest : public ISubscriptListener {
|
class SubscriptListenerTest : public ISubscriptListener {
|
||||||
public:
|
public:
|
||||||
SubscriptListenerTest() {}
|
SubscriptListenerTest() {}
|
||||||
explicit SubscriptListenerTest(std::string name) : moduleName_(name) {}
|
explicit SubscriptListenerTest(const std::string& name) : moduleName_(name)
|
||||||
|
{
|
||||||
|
futureFlag_ = promiseFlag_.get_future();
|
||||||
|
}
|
||||||
void OnMessage(DragCursorStyle style) override
|
void OnMessage(DragCursorStyle style) override
|
||||||
{
|
{
|
||||||
|
if (style != dragStyle_) {
|
||||||
|
promiseFlag_.set_value(true);
|
||||||
|
}
|
||||||
SetDragSyle(style);
|
SetDragSyle(style);
|
||||||
if (moduleName_.empty()) {
|
if (moduleName_.empty()) {
|
||||||
moduleName_ = std::string("SubscriptListenerTest");
|
moduleName_ = std::string("SubscriptListenerTest");
|
||||||
@ -220,6 +236,10 @@ private:
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::promise<bool> promiseFlag_;
|
||||||
|
std::future<bool> futureFlag_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DragCursorStyle dragStyle_ { DragCursorStyle::DEFAULT };
|
DragCursorStyle dragStyle_ { DragCursorStyle::DEFAULT };
|
||||||
std::string moduleName_;
|
std::string moduleName_;
|
||||||
@ -392,7 +412,7 @@ std::shared_ptr<MMI::PointerEvent> InteractionManagerTest::SetupPointerEvent(con
|
|||||||
return pointerEvent;
|
return pointerEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteractionManagerTest::SimulateDownEvent(const std::pair<int32_t, int32_t> &location, int32_t sourceType,
|
void InteractionManagerTest::SimulateDownPointerEvent(const std::pair<int32_t, int32_t> &location, int32_t sourceType,
|
||||||
int32_t pointerId)
|
int32_t pointerId)
|
||||||
{
|
{
|
||||||
CALL_DEBUG_ENTER;
|
CALL_DEBUG_ENTER;
|
||||||
@ -404,7 +424,7 @@ void InteractionManagerTest::SimulateDownEvent(const std::pair<int32_t, int32_t>
|
|||||||
MMI::InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
|
MMI::InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteractionManagerTest::SimulateUpEvent(const std::pair<int32_t, int32_t> &location, int32_t sourceType,
|
void InteractionManagerTest::SimulateUpPointerEvent(const std::pair<int32_t, int32_t> &location, int32_t sourceType,
|
||||||
int32_t pointerId)
|
int32_t pointerId)
|
||||||
{
|
{
|
||||||
CALL_DEBUG_ENTER;
|
CALL_DEBUG_ENTER;
|
||||||
@ -416,7 +436,7 @@ void InteractionManagerTest::SimulateUpEvent(const std::pair<int32_t, int32_t> &
|
|||||||
MMI::InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
|
MMI::InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteractionManagerTest::SimulateMoveEvent(const std::pair<int32_t, int32_t> &srcLocation,
|
void InteractionManagerTest::SimulateMovePointerEvent(const std::pair<int32_t, int32_t> &srcLocation,
|
||||||
const std::pair<int32_t, int32_t> &dstLocation, int32_t sourceType, int32_t pointerId, bool isPressed)
|
const std::pair<int32_t, int32_t> &dstLocation, int32_t sourceType, int32_t pointerId, bool isPressed)
|
||||||
{
|
{
|
||||||
CALL_DEBUG_ENTER;
|
CALL_DEBUG_ENTER;
|
||||||
@ -481,6 +501,69 @@ void InteractionManagerTest::PrintDragData(const DragData &dragData)
|
|||||||
dragData.dragNum, dragData.hasCanceledAnimation, dragData.udKey.substr(0, SUBSTR_UDKEY_LEN).c_str());
|
dragData.dragNum, dragData.hasCanceledAnimation, dragData.udKey.substr(0, SUBSTR_UDKEY_LEN).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InteractionManagerTest::SetupKeyEvent(
|
||||||
|
int32_t action, int32_t key, bool isPressed)
|
||||||
|
{
|
||||||
|
CALL_DEBUG_ENTER;
|
||||||
|
CHKPV(g_keyEvent);
|
||||||
|
MMI::KeyEvent::KeyItem keyItem;
|
||||||
|
keyItem.SetKeyCode(key);
|
||||||
|
keyItem.SetDeviceId(1);
|
||||||
|
keyItem.SetDownTime(DOWN_TIME);
|
||||||
|
g_keyEvent->SetKeyAction(action);
|
||||||
|
g_keyEvent->SetKeyCode(key);
|
||||||
|
if (action == MMI::KeyEvent::KEY_ACTION_DOWN) {
|
||||||
|
keyItem.SetPressed(isPressed);
|
||||||
|
} else if (action == MMI::KeyEvent::KEY_ACTION_UP) {
|
||||||
|
g_keyEvent->RemoveReleasedKeyItems(keyItem);
|
||||||
|
}
|
||||||
|
g_keyEvent->AddPressedKeyItems(keyItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractionManagerTest::ClearUpKeyEvent()
|
||||||
|
{
|
||||||
|
CALL_DEBUG_ENTER;
|
||||||
|
CHKPV(g_keyEvent);
|
||||||
|
for (const auto& iter : g_keyEvent->GetKeyItems()) {
|
||||||
|
if (!iter.IsPressed()) {
|
||||||
|
FI_HILOGD("TEST:Clean keyItem, keyCode:%{public}d", iter.GetKeyCode());
|
||||||
|
g_keyEvent->RemoveReleasedKeyItems(iter);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractionManagerTest::SimulateDownKeyEvent(int32_t key)
|
||||||
|
{
|
||||||
|
CALL_DEBUG_ENTER;
|
||||||
|
SetupKeyEvent(MMI::KeyEvent::KEY_ACTION_DOWN, key, true);
|
||||||
|
FI_HILOGD("TEST:keyCode:%{public}d, keyAction: KEY_ACTION_DOWN", key);
|
||||||
|
MMI::InputManager::GetInstance()->SimulateInputEvent(g_keyEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractionManagerTest::SimulateUpKeyEvent(int32_t key)
|
||||||
|
{
|
||||||
|
CALL_DEBUG_ENTER;
|
||||||
|
SetupKeyEvent(MMI::KeyEvent::KEY_ACTION_UP, key, false);
|
||||||
|
FI_HILOGD("TEST:keyCode:%{public}d, keyAction: KEY_ACTION_UP", key);
|
||||||
|
MMI::InputManager::GetInstance()->SimulateInputEvent(g_keyEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractionManagerTest::PrintDragAction(DragAction dragAction)
|
||||||
|
{
|
||||||
|
switch (dragAction) {
|
||||||
|
case DragAction::MOVE:
|
||||||
|
FI_HILOGD("drag action: MOVE");
|
||||||
|
break;
|
||||||
|
case DragAction::COPY:
|
||||||
|
FI_HILOGD("drag action: COPY");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FI_HILOGD("drag action: UNKNOWN");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class InputEventCallbackTest : public MMI::IInputEventConsumer {
|
class InputEventCallbackTest : public MMI::IInputEventConsumer {
|
||||||
public:
|
public:
|
||||||
InputEventCallbackTest() {}
|
InputEventCallbackTest() {}
|
||||||
@ -767,7 +850,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_Draglistener_Mouse, Test
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -776,7 +860,7 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_Draglistener_Mouse, Test
|
|||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||||
EXPECT_EQ(ret, RET_OK);
|
EXPECT_EQ(ret, RET_OK);
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
@ -809,14 +893,15 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_Draglistener_Touch, Test
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.targetPid, notifyMessage.result);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.targetPid, notifyMessage.result);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||||
std::make_shared<TestStartDragListener>(callback));
|
std::make_shared<TestStartDragListener>(callback));
|
||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
@ -850,7 +935,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_Draglistener, TestSize.L
|
|||||||
dragListeners.push_back(listener);
|
dragListeners.push_back(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -864,7 +950,7 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_Draglistener, TestSize.L
|
|||||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||||
std::make_shared<TestStartDragListener>(callback));
|
std::make_shared<TestStartDragListener>(callback));
|
||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
@ -905,17 +991,19 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_SubscriptListener_001, T
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||||
std::make_shared<TestStartDragListener>(callback));
|
std::make_shared<TestStartDragListener>(callback));
|
||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
SimulateUpEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateUpPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
||||||
std::future_status::timeout);
|
std::future_status::timeout);
|
||||||
@ -952,7 +1040,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_SubscriptListener_002, T
|
|||||||
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ MAX_PIXEL_MAP_WIDTH, MAX_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||||
std::make_shared<TestStartDragListener>(callback));
|
std::make_shared<TestStartDragListener>(callback));
|
||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
@ -961,18 +1050,19 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_SubscriptListener_002, T
|
|||||||
DragCursorStyle style = DragCursorStyle::DEFAULT;
|
DragCursorStyle style = DragCursorStyle::DEFAULT;
|
||||||
ret = InteractionManager::GetInstance()->UpdateDragStyle(style);
|
ret = InteractionManager::GetInstance()->UpdateDragStyle(style);
|
||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
EXPECT_TRUE(listener->futureFlag_.wait_for(std::chrono::milliseconds(TIME_WAIT_FOR_NOTIFY_LINSTER)) !=
|
||||||
SimulateUpEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
|
||||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
|
||||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
|
||||||
std::future_status::timeout);
|
std::future_status::timeout);
|
||||||
DragCursorStyle recvStyle = listener->GetDragStyle();
|
DragCursorStyle recvStyle = listener->GetDragStyle();
|
||||||
FI_HILOGD("Recived style:%{public}d, expected style:%{public}d", static_cast<int32_t>(recvStyle),
|
FI_HILOGD("Recived style:%{public}d, expected style:%{public}d", static_cast<int32_t>(recvStyle),
|
||||||
static_cast<int32_t>(style));
|
static_cast<int32_t>(style));
|
||||||
ASSERT_EQ(recvStyle, style);
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
|
SimulateUpPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
|
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
||||||
|
std::future_status::timeout);
|
||||||
ret = InteractionManager::GetInstance()->RemoveSubscriptListener(listener);
|
ret = InteractionManager::GetInstance()->RemoveSubscriptListener(listener);
|
||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
}
|
}
|
||||||
@ -997,7 +1087,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Mouse, TestSiz
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1006,7 +1097,7 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Mouse, TestSiz
|
|||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||||
EXPECT_EQ(ret, RET_OK);
|
EXPECT_EQ(ret, RET_OK);
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
@ -1029,7 +1120,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Failed_Mouse,
|
|||||||
} else {
|
} else {
|
||||||
std::promise<bool> promiseFlag;
|
std::promise<bool> promiseFlag;
|
||||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
@ -1067,7 +1159,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StopDrag_Mouse, TestSize
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.targetPid, notifyMessage.result);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.targetPid, notifyMessage.result);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1093,7 +1186,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StopDrag_Failed_Mouse, T
|
|||||||
if (g_deviceMouseId < 0) {
|
if (g_deviceMouseId < 0) {
|
||||||
ASSERT_TRUE(g_deviceMouseId < 0);
|
ASSERT_TRUE(g_deviceMouseId < 0);
|
||||||
} else {
|
} else {
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1117,7 +1211,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Touch, TestSiz
|
|||||||
if (g_deviceTouchId < 0) {
|
if (g_deviceTouchId < 0) {
|
||||||
ASSERT_TRUE(g_deviceTouchId < 0);
|
ASSERT_TRUE(g_deviceTouchId < 0);
|
||||||
} else {
|
} else {
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
@ -1134,7 +1229,7 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Touch, TestSiz
|
|||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
ret = InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||||
EXPECT_EQ(ret, RET_OK);
|
EXPECT_EQ(ret, RET_OK);
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
@ -1162,7 +1257,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StopDrag_Touch, TestSize
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
@ -1196,7 +1292,8 @@ HWTEST_F(InteractionManagerTest, GetDragTargetPid_Mouse, TestSize.Level1)
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseStopFlag.set_value(true);
|
promiseStopFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1236,7 +1333,8 @@ HWTEST_F(InteractionManagerTest, GetDragTargetPid_Touch, TestSize.Level1)
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseStopFlag.set_value(true);
|
promiseStopFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
@ -1275,7 +1373,8 @@ HWTEST_F(InteractionManagerTest, TouchEventDispatch, TestSize.Level1)
|
|||||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
@ -1288,7 +1387,7 @@ HWTEST_F(InteractionManagerTest, TouchEventDispatch, TestSize.Level1)
|
|||||||
auto callbackPtr = std::make_shared<InputEventCallbackTest>(
|
auto callbackPtr = std::make_shared<InputEventCallbackTest>(
|
||||||
[&promiseEventFlag]{promiseEventFlag.set_value(true);});
|
[&promiseEventFlag]{promiseEventFlag.set_value(true);});
|
||||||
int32_t monitorId = TestAddMonitor(callbackPtr);
|
int32_t monitorId = TestAddMonitor(callbackPtr);
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||||
ASSERT_TRUE(futureEventFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
ASSERT_TRUE(futureEventFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
||||||
std::future_status::timeout);
|
std::future_status::timeout);
|
||||||
@ -1317,7 +1416,8 @@ HWTEST_F(InteractionManagerTest, MouseEventDispatch, TestSize.Level1)
|
|||||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, 0);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, 0);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, 0, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, 0, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1329,7 +1429,7 @@ HWTEST_F(InteractionManagerTest, MouseEventDispatch, TestSize.Level1)
|
|||||||
auto callbackPtr = std::make_shared<InputEventCallbackTest>(
|
auto callbackPtr = std::make_shared<InputEventCallbackTest>(
|
||||||
[&promiseEventFlag]{promiseEventFlag.set_value(true);});
|
[&promiseEventFlag]{promiseEventFlag.set_value(true);});
|
||||||
int32_t monitorId = TestAddMonitor(callbackPtr);
|
int32_t monitorId = TestAddMonitor(callbackPtr);
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, TOUCH_POINTER_ID, true);
|
||||||
ASSERT_TRUE(futureEventFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
ASSERT_TRUE(futureEventFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
||||||
std::future_status::timeout);
|
std::future_status::timeout);
|
||||||
@ -1378,7 +1478,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_GetShadowOffset, TestSiz
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
@ -1408,7 +1509,8 @@ HWTEST_F(InteractionManagerTest, GetUdKey_Mouse, TestSize.Level1)
|
|||||||
if (g_deviceMouseId < 0) {
|
if (g_deviceMouseId < 0) {
|
||||||
ASSERT_TRUE(g_deviceMouseId < 0);
|
ASSERT_TRUE(g_deviceMouseId < 0);
|
||||||
} else {
|
} else {
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1453,7 +1555,8 @@ HWTEST_F(InteractionManagerTest, GetUdKey_Touch, TestSize.Level1)
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.targetPid, notifyMessage.result);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.targetPid, notifyMessage.result);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
@ -1492,7 +1595,8 @@ HWTEST_F(InteractionManagerTest, GetDragData_Success, TestSize.Level1)
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1505,7 +1609,8 @@ HWTEST_F(InteractionManagerTest, GetDragData_Success, TestSize.Level1)
|
|||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
ASSERT_EQ(replyDragData, dragData.value());
|
ASSERT_EQ(replyDragData, dragData.value());
|
||||||
PrintDragData(replyDragData);
|
PrintDragData(replyDragData);
|
||||||
SimulateUpEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateUpPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
||||||
@ -1525,11 +1630,13 @@ HWTEST_F(InteractionManagerTest, GetDragData_Failed, TestSize.Level1)
|
|||||||
if (g_deviceTouchId < 0) {
|
if (g_deviceTouchId < 0) {
|
||||||
ASSERT_TRUE(g_deviceTouchId < 0);
|
ASSERT_TRUE(g_deviceTouchId < 0);
|
||||||
} else {
|
} else {
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
||||||
DragData dragData;
|
DragData dragData;
|
||||||
int32_t ret = InteractionManager::GetInstance()->GetDragData(dragData);
|
int32_t ret = InteractionManager::GetInstance()->GetDragData(dragData);
|
||||||
SimulateUpEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateUpPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
ASSERT_EQ(ret, RET_ERR);
|
ASSERT_EQ(ret, RET_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1550,7 +1657,8 @@ HWTEST_F(InteractionManagerTest, GetDragState, TestSize.Level1)
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1564,7 +1672,8 @@ HWTEST_F(InteractionManagerTest, GetDragState, TestSize.Level1)
|
|||||||
EXPECT_EQ(ret, RET_OK);
|
EXPECT_EQ(ret, RET_OK);
|
||||||
EXPECT_EQ(dragState, DragState::START);
|
EXPECT_EQ(dragState, DragState::START);
|
||||||
|
|
||||||
SimulateUpEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
SimulateUpPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
|
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
ASSERT_EQ(ret, RET_OK);
|
ASSERT_EQ(ret, RET_OK);
|
||||||
@ -1657,14 +1766,14 @@ HWTEST_F(InteractionManagerTest, AddHotAreaListener_002, TestSize.Level1)
|
|||||||
#else
|
#else
|
||||||
ASSERT_EQ(ret, ERROR_UNSUPPORT);
|
ASSERT_EQ(ret, ERROR_UNSUPPORT);
|
||||||
#endif // OHOS_BUILD_ENABLE_COORDINATION
|
#endif // OHOS_BUILD_ENABLE_COORDINATION
|
||||||
SimulateMoveEvent({ HOT_AREA_STEP, HOT_AREA_COOR }, { HOT_AREA_STEP - HOT_AREA_SPAN, HOT_AREA_COOR },
|
SimulateMovePointerEvent({ HOT_AREA_STEP, HOT_AREA_COOR }, { HOT_AREA_STEP - HOT_AREA_SPAN, HOT_AREA_COOR },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
||||||
SimulateMoveEvent({ HOT_AREA_COOR, HOT_AREA_STEP }, { HOT_AREA_COOR, HOT_AREA_STEP - HOT_AREA_SPAN },
|
SimulateMovePointerEvent({ HOT_AREA_COOR, HOT_AREA_STEP }, { HOT_AREA_COOR, HOT_AREA_STEP - HOT_AREA_SPAN },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
||||||
SimulateMoveEvent({ g_screenWidth - HOT_AREA_STEP, HOT_AREA_COOR },
|
SimulateMovePointerEvent({ g_screenWidth - HOT_AREA_STEP, HOT_AREA_COOR },
|
||||||
{ g_screenWidth - HOT_AREA_SPAN, HOT_AREA_COOR },
|
{ g_screenWidth - HOT_AREA_SPAN, HOT_AREA_COOR },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
||||||
SimulateMoveEvent({ HOT_AREA_COOR, g_screenHeight - HOT_AREA_STEP },
|
SimulateMovePointerEvent({ HOT_AREA_COOR, g_screenHeight - HOT_AREA_STEP },
|
||||||
{ HOT_AREA_COOR, g_screenHeight - HOT_AREA_SPAN },
|
{ HOT_AREA_COOR, g_screenHeight - HOT_AREA_SPAN },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_TOUCH_DOWN_MS));
|
||||||
@ -1729,7 +1838,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_UpdateDragItemStyle, Tes
|
|||||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
promiseFlag.set_value(true);
|
promiseFlag.set_value(true);
|
||||||
};
|
};
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1740,15 +1850,15 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_UpdateDragItemStyle, Tes
|
|||||||
EXPECT_EQ(ret, RET_OK);
|
EXPECT_EQ(ret, RET_OK);
|
||||||
std::pair<int32_t, int32_t> enterPos { 500, 50 };
|
std::pair<int32_t, int32_t> enterPos { 500, 50 };
|
||||||
std::pair<int32_t, int32_t> leavePos { 500, 200 };
|
std::pair<int32_t, int32_t> leavePos { 500, 200 };
|
||||||
SimulateMoveEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { enterPos.first, enterPos.second },
|
SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { enterPos.first, enterPos.second },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||||
ret = InteractionManager::GetInstance()->UpdateDragItemStyle({ FOREGROUND_COLOR_IN, RADIUS_IN, ALPHA_IN });
|
ret = InteractionManager::GetInstance()->UpdateDragItemStyle({ FOREGROUND_COLOR_IN, RADIUS_IN, ALPHA_IN });
|
||||||
EXPECT_EQ(ret, RET_OK);
|
EXPECT_EQ(ret, RET_OK);
|
||||||
SimulateMoveEvent({ enterPos.first, enterPos.second }, { leavePos.first, leavePos.second },
|
SimulateMovePointerEvent({ enterPos.first, enterPos.second }, { leavePos.first, leavePos.second },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||||
ret = InteractionManager::GetInstance()->UpdateDragItemStyle({ FOREGROUND_COLOR_OUT, RADIUS_OUT, ALPHA_OUT });
|
ret = InteractionManager::GetInstance()->UpdateDragItemStyle({ FOREGROUND_COLOR_OUT, RADIUS_OUT, ALPHA_OUT });
|
||||||
EXPECT_EQ(ret, RET_OK);
|
EXPECT_EQ(ret, RET_OK);
|
||||||
SimulateMoveEvent({ leavePos.first, leavePos.second }, { DRAG_DST_X, DRAG_DST_Y },
|
SimulateMovePointerEvent({ leavePos.first, leavePos.second }, { DRAG_DST_X, DRAG_DST_Y },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID, true);
|
||||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
InteractionManager::GetInstance()->StopDrag(dropResult);
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
@ -1783,7 +1893,8 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_GetExtraInfo, TestSize.L
|
|||||||
{
|
{
|
||||||
CALL_TEST_DEBUG;
|
CALL_TEST_DEBUG;
|
||||||
if (g_deviceMouseId >= 0) {
|
if (g_deviceMouseId >= 0) {
|
||||||
SimulateDownEvent({ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
ASSERT_TRUE(dragData);
|
ASSERT_TRUE(dragData);
|
||||||
@ -1831,6 +1942,101 @@ HWTEST_F(InteractionManagerTest, TestDragDataUtil_Packer, TestSize.Level1)
|
|||||||
ASSERT_EQ(dragData.value(), dragDataFromParcel);
|
ASSERT_EQ(dragData.value(), dragDataFromParcel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: InteractionManagerTest_GetDragAction_001
|
||||||
|
* @tc.desc: Get drag action with no keyboard events of keys in dragging
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require:
|
||||||
|
*/
|
||||||
|
HWTEST_F(InteractionManagerTest, GetDragAction_001, TestSize.Level1)
|
||||||
|
{
|
||||||
|
CALL_TEST_DEBUG;
|
||||||
|
std::promise<bool> promiseFlag;
|
||||||
|
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||||
|
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||||
|
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||||
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
|
promiseFlag.set_value(true);
|
||||||
|
};
|
||||||
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
|
ASSERT_TRUE(dragData);
|
||||||
|
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||||
|
std::make_shared<TestStartDragListener>(callback));
|
||||||
|
ASSERT_EQ(ret, RET_OK);
|
||||||
|
DragAction dragAction { DragAction::INVALID };
|
||||||
|
ret = InteractionManager::GetInstance()->GetDragAction(dragAction);
|
||||||
|
EXPECT_EQ(ret, RET_OK);
|
||||||
|
EXPECT_EQ(dragAction, DragAction::MOVE);
|
||||||
|
PrintDragAction(dragAction);
|
||||||
|
SimulateUpPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
|
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
||||||
|
std::future_status::timeout);
|
||||||
|
ret = InteractionManager::GetInstance()->GetDragAction(dragAction);
|
||||||
|
EXPECT_EQ(ret, RET_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: InteractionManagerTest_GetDragAction_002
|
||||||
|
* @tc.desc: Get drag action with simple press and release keyboard events of keys in dragging
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require:
|
||||||
|
*/
|
||||||
|
HWTEST_F(InteractionManagerTest, GetDragAction_002, TestSize.Level1)
|
||||||
|
{
|
||||||
|
CALL_TEST_DEBUG;
|
||||||
|
std::promise<bool> promiseFlag;
|
||||||
|
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||||
|
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||||
|
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||||
|
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||||
|
promiseFlag.set_value(true);
|
||||||
|
};
|
||||||
|
SimulateDownPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID);
|
||||||
|
std::optional<DragData> dragData = CreateDragData({ TEST_PIXEL_MAP_WIDTH, TEST_PIXEL_MAP_HEIGHT },
|
||||||
|
MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, DISPLAY_ID, { DRAG_SRC_X, DRAG_SRC_Y });
|
||||||
|
ASSERT_TRUE(dragData);
|
||||||
|
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(),
|
||||||
|
std::make_shared<TestStartDragListener>(callback));
|
||||||
|
ASSERT_EQ(ret, RET_OK);
|
||||||
|
SimulateDownKeyEvent(MMI::KeyEvent::KEYCODE_CTRL_LEFT);
|
||||||
|
DragAction dragAction { DragAction::INVALID };
|
||||||
|
ret = InteractionManager::GetInstance()->GetDragAction(dragAction);
|
||||||
|
EXPECT_EQ(ret, RET_OK);
|
||||||
|
EXPECT_EQ(dragAction, DragAction::COPY);
|
||||||
|
PrintDragAction(dragAction);
|
||||||
|
SimulateUpKeyEvent(MMI::KeyEvent::KEYCODE_CTRL_LEFT);
|
||||||
|
ret = InteractionManager::GetInstance()->GetDragAction(dragAction);
|
||||||
|
EXPECT_EQ(ret, RET_OK);
|
||||||
|
EXPECT_EQ(dragAction, DragAction::MOVE);
|
||||||
|
PrintDragAction(dragAction);
|
||||||
|
ClearUpKeyEvent();
|
||||||
|
SimulateDownKeyEvent(MMI::KeyEvent::KEYCODE_A);
|
||||||
|
ret = InteractionManager::GetInstance()->GetDragAction(dragAction);
|
||||||
|
EXPECT_EQ(ret, RET_OK);
|
||||||
|
EXPECT_EQ(dragAction, DragAction::MOVE);
|
||||||
|
PrintDragAction(dragAction);
|
||||||
|
SimulateUpKeyEvent(MMI::KeyEvent::KEYCODE_A);
|
||||||
|
ret = InteractionManager::GetInstance()->GetDragAction(dragAction);
|
||||||
|
EXPECT_EQ(ret, RET_OK);
|
||||||
|
EXPECT_EQ(dragAction, DragAction::MOVE);
|
||||||
|
PrintDragAction(dragAction);
|
||||||
|
ClearUpKeyEvent();
|
||||||
|
SimulateUpPointerEvent(
|
||||||
|
{ DRAG_SRC_X, DRAG_SRC_Y }, MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, TOUCH_POINTER_ID);
|
||||||
|
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||||
|
InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||||
|
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) !=
|
||||||
|
std::future_status::timeout);
|
||||||
|
ret = InteractionManager::GetInstance()->GetDragAction(dragAction);
|
||||||
|
EXPECT_EQ(ret, RET_ERR);
|
||||||
|
}
|
||||||
} // namespace DeviceStatus
|
} // namespace DeviceStatus
|
||||||
} // namespace Msdp
|
} // namespace Msdp
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -112,8 +112,14 @@ int32_t DragDataManager::GetShadowOffset(int32_t& offsetX, int32_t& offsetY, int
|
|||||||
|
|
||||||
void DragDataManager::ResetDragData()
|
void DragDataManager::ResetDragData()
|
||||||
{
|
{
|
||||||
|
CALL_DEBUG_ENTER;
|
||||||
dragData_ = { };
|
dragData_ = { };
|
||||||
dragItemStyle_ = { };
|
dragItemStyle_ = { };
|
||||||
|
dragStyle_ = DragCursorStyle::DEFAULT;
|
||||||
|
visible_ = false;
|
||||||
|
targetTid_ = -1;
|
||||||
|
targetPid_ = -1;
|
||||||
|
isMotionDrag_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DragDataManager::SetMotionDrag(bool isMotionDrag)
|
void DragDataManager::SetMotionDrag(bool isMotionDrag)
|
||||||
|
Loading…
Reference in New Issue
Block a user