1 /*
2 * Copyright (c) 2024 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 <gtest/gtest.h>
17 #include "gtx_input_event_sender.h"
18 #include "mock_window_adapter.h"
19 #include "singleton_mocker.h"
20 #include "window_impl.h"
21
22 using namespace testing;
23 using namespace testing::ext;
24
25 namespace OHOS {
26 namespace Rosen {
27 using WindowMocker = SingletonMocker<WindowAdapter, MockWindowAdapter>;
28 class GtxInputEventSenderTest : public testing::Test {
29 public:
30 static void SetUpTestCase();
31 static void TearDownTestCase();
32 void SetUp() override;
33 void TearDown() override;
34 };
SetUpTestCase()35 void GtxInputEventSenderTest::SetUpTestCase() {}
36
TearDownTestCase()37 void GtxInputEventSenderTest::TearDownTestCase() {}
38
SetUp()39 void GtxInputEventSenderTest::SetUp() {}
40
TearDown()41 void GtxInputEventSenderTest::TearDown() {}
42
43 namespace {
44 /**
45 * @tc.name: GetTouchEvent
46 * @tc.desc: GetTouchEvent.
47 * @tc.type: FUNC
48 */
49 HWTEST_F(GtxInputEventSenderTest, GetTouchEvent, Function | SmallTest | Level2)
50 {
51 int32_t testPointerId = 1234;
52 auto pointerEvent = MMI::PointerEvent::Create();
53 pointerEvent->SetPointerId(testPointerId);
54 Rect testRect{};
55
56 GtxTouchEventInfo touchEvent{};
57 GtxInputEventSender::GetInstance().SetOpt(true);
58 GtxInputEventSender::GetInstance().SetTouchEvent(testRect, pointerEvent);
59 GtxInputEventSender::GetInstance().GetTouchEvent(touchEvent);
60 GtxInputEventSender::GetInstance().SetOpt(false);
61
62 EXPECT_EQ(testPointerId, touchEvent.pointerId);
63 }
64
65 } // namespace
66 } // namespace Rosen
67 } // namespace OHOS