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 "window_impl.h"
19 #include "mock_window_adapter.h"
20 #include "singleton_mocker.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 {
37 }
38
TearDownTestCase()39 void GtxInputEventSenderTest::TearDownTestCase()
40 {
41 }
42
SetUp()43 void GtxInputEventSenderTest::SetUp()
44 {
45 }
46
TearDown()47 void GtxInputEventSenderTest::TearDown()
48 {
49 }
50
51 namespace {
52 /**
53 * @tc.name: GetTouchEvent
54 * @tc.desc: GetTouchEvent.
55 * @tc.type: FUNC
56 */
57 HWTEST_F(GtxInputEventSenderTest, GetTouchEvent, Function | SmallTest | Level2)
58 {
59 int32_t testPointerId = 1234;
60 auto pointerEvent = MMI::PointerEvent::Create();
61 pointerEvent->SetPointerId(testPointerId);
62 Rect testRect{};
63
64 GtxTouchEventInfo touchEvent{};
65 GtxInputEventSender::GetInstance().SetOpt(true);
66 GtxInputEventSender::GetInstance().SetTouchEvent(testRect, pointerEvent);
67 GtxInputEventSender::GetInstance().GetTouchEvent(touchEvent);
68 GtxInputEventSender::GetInstance().SetOpt(false);
69
70 EXPECT_EQ(testPointerId, touchEvent.pointerId);
71 }
72
73 }
74 } // namespace Rosen
75 } // namespace OHOS