• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "base/ressched/ressched_report.h"
18 #include "core/common/ace_application_info.h"
19 #include "core/event/touch_event.h"
20 #include "core/pipeline_ng/pipeline_context.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 
25 namespace OHOS::Ace {
26 
27 namespace {
28 } // namespace
29 
30 class ResSchedReportTest : public testing::Test {
31 public:
SetUpTestSuite()32     static void SetUpTestSuite()
33     {
34     }
TearDownTestSuite()35     static void TearDownTestSuite()
36     {
37     }
SetUp()38     void SetUp() {};
TearDown()39     void TearDown() {};
40 };
41 
42 /**
43  * @tc.name: ResSchedReportTest001
44  * @tc.desc: test touch up
45  * @tc.type: FUNC
46  */
47 HWTEST_F(ResSchedReportTest, ResSchedReportTest001, TestSize.Level1)
48 {
49     TouchEvent touchEvent;
50     touchEvent.type = TouchType::UP;
51     touchEvent.localX = 100.0f;
52     touchEvent.localY = 200.0f;
53     ReportConfig config;
54     config.isReportTid = true;
55     config.tid = 98765;
56     ResSchedReport::GetInstance().OnTouchEvent(touchEvent, config);
57     EXPECT_NE(touchEvent.localX, touchEvent.localY);
58 }
59 
60 /**
61  * @tc.name: ResSchedReportTest002
62  * @tc.desc: test touch move
63  * @tc.type: FUNC
64  */
65 HWTEST_F(ResSchedReportTest, ResSchedReportTest002, TestSize.Level1)
66 {
67     TouchEvent touchEvent;
68     touchEvent.type = TouchType::MOVE;
69     touchEvent.localX = 100.0f;
70     touchEvent.localY = 200.0f;
71     ReportConfig config;
72     config.isReportTid = true;
73     config.tid = 12345;
74     ResSchedReport::GetInstance().OnTouchEvent(touchEvent, config);
75     EXPECT_NE(touchEvent.localX, touchEvent.localY);
76 }
77 } // namespace OHOS::Ace
78