1 /* 2 * Copyright (C) 2021 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 <thread> 17 #include <cstdio> 18 #include <ios> 19 #include <vector> 20 #include <iostream> 21 #include <fstream> 22 #include <sstream> 23 #include <regex> 24 #include <sys/wait.h> 25 #include <sys/types.h> 26 #include <unistd.h> 27 #include <sys/types.h> 28 #include <sys/wait.h> 29 #include "startup_delay.h" 30 #include "sp_utils.h" 31 #include "sp_log.h" 32 #include "common.h" 33 34 using namespace testing::ext; 35 using namespace std; 36 37 namespace OHOS { 38 namespace SmartPerf { 39 class StartupDelayTest : public testing::Test { 40 public: SetUpTestCase()41 static void SetUpTestCase() {} TearDownTestCase()42 static void TearDownTestCase() {} SetUp()43 void SetUp() {} TearDown()44 void TearDown() {} 45 }; 46 47 HWTEST_F(StartupDelayTest, GetTraceTest01, TestSize.Level1) 48 { 49 StartUpDelay startUpDelay; 50 std::string result; 51 std::string cmdString; 52 std::string traceName = "testTrace"; 53 cmdString = "hitrace --trace_clock mono -t 10 -b 102400 --overwrite idle ace app ohos ability graphic nweb"; 54 SPUtils::LoadCmd(cmdString + traceName, result); 55 startUpDelay.GetTrace(traceName); 56 ASSERT_TRUE(true); 57 } 58 59 HWTEST_F(StartupDelayTest, GetTraceTest02, TestSize.Level1) 60 { 61 StartUpDelay startUpDelay; 62 std::string result; 63 std::string cmdString; 64 std::string traceName = "testTrace"; 65 cmdString = "hitrace --trace_clock mono -t 10 -b 204800 --overwrite idle ace app ohos ability graphic nweb"; 66 SPUtils::LoadCmd(cmdString + traceName, result); 67 startUpDelay.GetTrace(traceName); 68 ASSERT_TRUE(true); 69 } 70 71 HWTEST_F(StartupDelayTest, GetHisysIdTest01, TestSize.Level1) 72 { 73 StartUpDelay startUpDelay; 74 startUpDelay.GetHisysId(); 75 ASSERT_TRUE(true); 76 } 77 78 HWTEST_F(StartupDelayTest, GetHisysIdAndKillTest01, TestSize.Level1) 79 { 80 StartUpDelay startUpDelay; 81 startUpDelay.GetHisysIdAndKill(); 82 ASSERT_TRUE(true); 83 } 84 85 HWTEST_F(StartupDelayTest, GetSpTcpTest01, TestSize.Level1) 86 { 87 StartUpDelay startUpDelay; 88 bool result = startUpDelay.GetSpTcp(); 89 EXPECT_FALSE(result); 90 } 91 92 HWTEST_F(StartupDelayTest, GetSpClearTest01, TestSize.Level1) 93 { 94 StartUpDelay startUpDelay; 95 bool result = startUpDelay.GetSpClear(); 96 EXPECT_FALSE(result); 97 } 98 99 HWTEST_F(StartupDelayTest, GetPidByPkgTest01, TestSize.Level1) 100 { 101 StartUpDelay startUpDelay; 102 std::string curPkgName = "testPackage"; 103 EXPECT_EQ(startUpDelay.GetPidByPkg(curPkgName), ""); 104 } 105 106 } 107 }