/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include "mmi_log.h" #include "pointer_event.h" #include "touch_drawing_manager.h" #include "window_info.h" namespace OHOS { namespace MMI { namespace { using namespace testing::ext; constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "TouchDrawingManagerTest" }; } // namespace class TouchDrawingManagerTest : public testing::Test { public: static void SetUpTestCase(void) {}; static void TearDownTestCase(void) {}; void SetUp(void) { // 创建displayInfo_ DisplayInfo info; info.id = 1; info.x =1; info.y = 1; info.width = 1; info.height = 1; int32_t displayDpi = 240; info.dpi = displayDpi; info.name = "xx"; info.uniq = "xx"; info.direction = DIRECTION0; TOUCH_DRAWING_MANAGER->UpdateDisplayInfo(info); } // void SetUp(void) }; /** * @tc.name: TouchDrawingManagerTest_TouchDrawHandler_001 * @tc.desc: Test TouchDrawHandler * @tc.type: Function * @tc.require: */ HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_TouchDrawHandler_001, TestSize.Level1) { CALL_TEST_DEBUG; auto pointerEvent = PointerEvent::Create(); EXPECT_NE(pointerEvent, nullptr); PointerEvent::PointerItem item; item.SetPointerId(0); int32_t displayX = 100; int32_t displayY = 100; item.SetDisplayX(displayX); item.SetDisplayY(displayY); pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN); pointerEvent->SetTargetDisplayId(0); pointerEvent->SetPointerId(0); pointerEvent->AddPointerItem(item); EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MANAGER->TouchDrawHandler(pointerEvent)); } /** * @tc.name: TouchDrawingManagerTest_TouchDrawHandler_002 * @tc.desc: Test TouchDrawHandler * @tc.type: Function * @tc.require: */ HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_TouchDrawHandler_002, TestSize.Level1) { CALL_TEST_DEBUG; auto pointerEvent = PointerEvent::Create(); EXPECT_NE(pointerEvent, nullptr); PointerEvent::PointerItem item; item.SetPointerId(0); int32_t displayX = 200; int32_t displayY = 200; item.SetDisplayX(displayX); item.SetDisplayY(displayY); pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP); pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN); pointerEvent->SetTargetDisplayId(0); pointerEvent->SetPointerId(0); pointerEvent->AddPointerItem(item); EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MANAGER->TouchDrawHandler(pointerEvent)); } } // namespace MMI } // namespace OHOS