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 <exception> 16 #include <iostream> 17 #include <string> 18 #include <thread> 19 #include <gtest/gtest.h> 20 #include <unistd.h> 21 #include <cstring> 22 #include <cstdint> 23 #include <cstdio> 24 #include <functional> 25 #include "FPS.h" 26 27 using namespace testing::ext; 28 using namespace std; 29 30 namespace OHOS { 31 namespace SmartPerf { 32 class SPdaemonFpsTest : public testing::Test { 33 public: SetUpTestCase()34 static void SetUpTestCase() {} TearDownTestCase()35 static void TearDownTestCase() {} SetUp()36 void SetUp() {} TearDown()37 void TearDown() {} 38 }; 39 40 /** 41 * @tc.name: FPS::SetFpsCurrentFpsTime 42 * @tc.desc: Test SetFpsCurrentFpsTime 43 * @tc.type: FUNC 44 */ 45 HWTEST_F(SPdaemonFpsTest, SetFpsCurrentFpsTimeTestCase001, TestSize.Level1) 46 { 47 bool ret = false; 48 FpsInfo fpsInfoResult; 49 FPS::GetInstance().SetFpsCurrentFpsTime(fpsInfoResult); 50 FpsCurrentFpsTime fcf = FPS::GetInstance().GetFpsCurrentFpsTime(); 51 52 if (fcf.currentFpsTime == 0) { 53 ret = true; 54 } 55 56 EXPECT_TRUE(ret); 57 } 58 59 /** 60 * @tc.name: FPS::GetFpsCurrentFpsTime 61 * @tc.desc: Test GetFpsCurrentFpsTime 62 * @tc.type: FUNC 63 */ 64 HWTEST_F(SPdaemonFpsTest, GetFpsCurrentFpsTimeTestCase001, TestSize.Level1) 65 { 66 bool ret = false; 67 FpsCurrentFpsTime fcf = FPS::GetInstance().GetFpsCurrentFpsTime(); 68 69 if (fcf.fps == 0 && fcf.currentFpsTime == 0) { 70 ret = true; 71 } 72 EXPECT_TRUE(ret); 73 } 74 75 } 76 }