• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 #include <gtest/gtest.h>
16 #include "unistd.h"
17 #include <thread>
18 #include <cstdio>
19 #include <cstring>
20 #include <map>
21 #include <sstream>
22 #include <iomanip>
23 #include <future>
24 #include "control_call_cmd.h"
25 #include "startup_delay.h"
26 #include "sp_utils.h"
27 #include "parse_click_complete_trace.h"
28 #include "parse_click_response_trace.h"
29 #include "parse_radar.h"
30 #include "parse_slide_fps_trace.h"
31 #include "sp_log.h"
32 #include "stalling_rate_trace.h"
33 #include "common.h"
34 
35 
36 using namespace testing::ext;
37 using namespace std;
38 
39 namespace OHOS {
40 namespace SmartPerf {
41 class ControlCallCmdTest : public testing::Test {
42 public:
SetUpTestCase()43     static void SetUpTestCase() {}
TearDownTestCase()44     static void TearDownTestCase() {}
45 
SetUp()46     void SetUp() {}
TearDown()47     void TearDown() {}
48 
49     bool isOhTest = false;
50     double time = 0.0;
51     double noNameType = -1.0;
52 };
53 
54 HWTEST_F(ControlCallCmdTest, GetResultTest01, TestSize.Level1)
55 {
56     ControlCallCmd cmd;
57     time = cmd.ResponseTime();
58     std::vector<std::string> v = {"responseTime"};
59     EXPECT_EQ("", cmd.GetResult(v));
60 }
61 
62 HWTEST_F(ControlCallCmdTest, GetResultTest02, TestSize.Level1)
63 {
64     ControlCallCmd cmd;
65     std::vector<std::string> v = {"completeTime"};
66     time = cmd.CompleteTime();
67     EXPECT_EQ("", cmd.GetResult(v));
68 }
69 
70 HWTEST_F(ControlCallCmdTest, GetResultTest03, TestSize.Level1)
71 {
72     ControlCallCmd cmd;
73     std::vector<std::string> v = {"frameLoss"};
74     EXPECT_EQ("", cmd.GetResult(v));
75 }
76 
77 HWTEST_F(ControlCallCmdTest, GetResultTest04, TestSize.Level1)
78 {
79     ControlCallCmd cmd;
80     std::vector<std::string> v = {"appStartTime"};
81     EXPECT_EQ("", cmd.GetResult(v));
82 }
83 
84 HWTEST_F(ControlCallCmdTest, GetResultTest05, TestSize.Level1)
85 {
86     ControlCallCmd cmd;
87     std::vector<std::string> v = {"slideList"};
88     EXPECT_EQ("", cmd.GetResult(v));
89 }
90 
91 HWTEST_F(ControlCallCmdTest, GetResultTest06, TestSize.Level1)
92 {
93     ControlCallCmd cmd;
94     std::vector<std::string> v = {"timeDelay"};
95     EXPECT_EQ("", cmd.GetResult(v));
96 }
97 
98 HWTEST_F(ControlCallCmdTest, TimeDelayTest01, TestSize.Level1)
99 {
100     OHOS::SmartPerf::ControlCallCmd controlCallCmd;
101     std::string expected = "ResponseTime:-1ms\nCompleteTime:-1ms\nHitchTimeRate:-1.00ms/s ";
102     std::string expectedResult = expected + "\nMAX_RENDER_SEQ_MISSED_FRAMES:-1";
103     EXPECT_EQ(controlCallCmd.TimeDelay(), expectedResult);
104 }
105 
106 HWTEST_F(ControlCallCmdTest, SlideListTest01, TestSize.Level1)
107 {
108     OHOS::SmartPerf::ControlCallCmd controlCallCmd;
109     std::string expected = "FPS:-1fps\nResponseTime:-1ms\nHitchTimeRate:-1.00ms/s ";
110     std::string expectedResult = expected + "\nMAX_RENDER_SEQ_MISSED_FRAMES:-1";
111     std::string resultStream = controlCallCmd.SlideList();
112     EXPECT_EQ(resultStream, expectedResult);
113 }
114 
115 HWTEST_F(ControlCallCmdTest, GetFrameTest01, TestSize.Level1)
116 {
117     OHOS::SmartPerf::ControlCallCmd controlCallCmd;
118     std::string result = controlCallCmd.GetFrame();
119     EXPECT_EQ(result, "");
120 }
121 
122 HWTEST_F(ControlCallCmdTest, ResponseTimeTest01, TestSize.Level1)
123 {
124     OHOS::SmartPerf::ControlCallCmd controlCallCmd;
125     EXPECT_DOUBLE_EQ(controlCallCmd.ResponseTime(), -1);
126 }
127 
128 HWTEST_F(ControlCallCmdTest, CompleteTimeTest01, TestSize.Level1)
129 {
130     OHOS::SmartPerf::ControlCallCmd cmd;
131     double expectedTime = -1;
132     double result = cmd.CompleteTime();
133     EXPECT_EQ(result, expectedTime);
134 }
135 
136 HWTEST_F(ControlCallCmdTest, IsohTest01, TestSize.Level1)
137 {
138     OHOS::SmartPerf::ControlCallCmd controlCallCmd;
139     bool isOhTest = true;
140     std::vector<std::string> v = {"", "", "ohtest"};
141     controlCallCmd.IsohTest(v);
142     ASSERT_TRUE(isOhTest);
143 }
144 
145 HWTEST_F(ControlCallCmdTest, IsohTest02, TestSize.Level1)
146 {
147     OHOS::SmartPerf::ControlCallCmd controlCallCmd;
148     bool isOhTest = false;
149     std::vector<std::string> v = {"", "", "notohtest"};
150     controlCallCmd.IsohTest(v);
151     ASSERT_FALSE(isOhTest);
152 }
153 }
154 }