19762338dSopenharmony_ci/*
29762338dSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
39762338dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
49762338dSopenharmony_ci * you may not use this file except in compliance with the License.
59762338dSopenharmony_ci * You may obtain a copy of the License at
69762338dSopenharmony_ci *
79762338dSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
89762338dSopenharmony_ci *
99762338dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
109762338dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
119762338dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129762338dSopenharmony_ci * See the License for the specific language governing permissions and
139762338dSopenharmony_ci * limitations under the License.
149762338dSopenharmony_ci */
159762338dSopenharmony_ci
169762338dSopenharmony_ci#include <cmath>
179762338dSopenharmony_ci#include <cstdio>
189762338dSopenharmony_ci#include <fcntl.h>
199762338dSopenharmony_ci#include <functional>
209762338dSopenharmony_ci#include <gtest/gtest.h>
219762338dSopenharmony_ci#include <mutex>
229762338dSopenharmony_ci#include <securec.h>
239762338dSopenharmony_ci#include <unistd.h>
249762338dSopenharmony_ci
259762338dSopenharmony_ci#include "hdf_base.h"
269762338dSopenharmony_ci#include "osal_time.h"
279762338dSopenharmony_ci#include "v1_1/ifan_callback.h"
289762338dSopenharmony_ci#include "v1_1/ithermal_callback.h"
299762338dSopenharmony_ci#include "v1_1/ithermal_interface.h"
309762338dSopenharmony_ci#include "v1_1/thermal_types.h"
319762338dSopenharmony_ci
329762338dSopenharmony_ciusing namespace OHOS::HDI;
339762338dSopenharmony_ciusing namespace OHOS::HDI::Thermal::V1_1;
349762338dSopenharmony_ciusing namespace testing::ext;
359762338dSopenharmony_ci
369762338dSopenharmony_cinamespace {
379762338dSopenharmony_ciint g_onFanDataEventCount = 0;
389762338dSopenharmony_ciint g_onThermalDataEventCount = 0;
399762338dSopenharmony_ciclass ThermalCallbackMock : public IThermalCallback {
409762338dSopenharmony_cipublic:
419762338dSopenharmony_ci    virtual ~ThermalCallbackMock() {}
429762338dSopenharmony_ci    using ThermalEventCallback = std::function<int32_t(const HdfThermalCallbackInfo &event)>;
439762338dSopenharmony_ci    static int32_t RegisterThermalEvent(const ThermalEventCallback &eventCb)
449762338dSopenharmony_ci    {
459762338dSopenharmony_ci        (void)eventCb;
469762338dSopenharmony_ci        return 0;
479762338dSopenharmony_ci    }
489762338dSopenharmony_ci    int32_t OnThermalDataEvent(const HdfThermalCallbackInfo &event) override
499762338dSopenharmony_ci    {
509762338dSopenharmony_ci        (void)event;
519762338dSopenharmony_ci        g_onThermalDataEventCount++;
529762338dSopenharmony_ci        return 0;
539762338dSopenharmony_ci    }
549762338dSopenharmony_ci};
559762338dSopenharmony_ci
569762338dSopenharmony_ciclass FanCallbackMock : public IFanCallback {
579762338dSopenharmony_cipublic:
589762338dSopenharmony_ci    virtual ~FanCallbackMock() {}
599762338dSopenharmony_ci    using FanEventCallback = std::function<int32_t(const HdfThermalCallbackInfo &event)>;
609762338dSopenharmony_ci    static int32_t RegisterFanEvent(const FanEventCallback &eventCb)
619762338dSopenharmony_ci    {
629762338dSopenharmony_ci        (void)eventCb;
639762338dSopenharmony_ci        return 0;
649762338dSopenharmony_ci    }
659762338dSopenharmony_ci    int32_t OnFanDataEvent(const HdfThermalCallbackInfo &event) override
669762338dSopenharmony_ci    {
679762338dSopenharmony_ci        (void)event;
689762338dSopenharmony_ci        g_onFanDataEventCount++;
699762338dSopenharmony_ci        return 0;
709762338dSopenharmony_ci    }
719762338dSopenharmony_ci};
729762338dSopenharmony_ci
739762338dSopenharmony_cisptr<IThermalInterface> g_thermalInterface = nullptr;
749762338dSopenharmony_cisptr<IThermalCallback> g_callback = new ThermalCallbackMock();
759762338dSopenharmony_cisptr<IFanCallback> g_fanCallback = new FanCallbackMock();
769762338dSopenharmony_cistd::mutex g_mutex;
779762338dSopenharmony_ci
789762338dSopenharmony_ciclass HdfThermalHdiTestAdditional : public testing::Test {
799762338dSopenharmony_cipublic:
809762338dSopenharmony_ci    static void SetUpTestCase();
819762338dSopenharmony_ci    static void TearDownTestCase();
829762338dSopenharmony_ci    void SetUp();
839762338dSopenharmony_ci    void TearDown();
849762338dSopenharmony_ci};
859762338dSopenharmony_ci
869762338dSopenharmony_civoid HdfThermalHdiTestAdditional::SetUpTestCase() { g_thermalInterface = IThermalInterface::Get(true); }
879762338dSopenharmony_ci
889762338dSopenharmony_civoid HdfThermalHdiTestAdditional::TearDownTestCase() {}
899762338dSopenharmony_ci
909762338dSopenharmony_civoid HdfThermalHdiTestAdditional::SetUp() {}
919762338dSopenharmony_ci
929762338dSopenharmony_civoid HdfThermalHdiTestAdditional::TearDown() {}
939762338dSopenharmony_ci
949762338dSopenharmony_ci} // namespace
959762338dSopenharmony_ci
969762338dSopenharmony_cinamespace {
979762338dSopenharmony_ci/**
989762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetCpuFreq_0200
999762338dSopenharmony_ci * @tc.name  testSetCpuFreq001
1009762338dSopenharmony_ci * @tc.desc  Reliability of function(SetCpuFreq)
1019762338dSopenharmony_ci */
1029762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq001, Function | MediumTest | Level1)
1039762338dSopenharmony_ci{
1049762338dSopenharmony_ci    int32_t cpuFreq = 1994100;
1059762338dSopenharmony_ci    int32_t ret = 0;
1069762338dSopenharmony_ci    int i = 0;
1079762338dSopenharmony_ci    for (i = 0; i < 1000; i++) {
1089762338dSopenharmony_ci        ret |= g_thermalInterface->SetCpuFreq(cpuFreq);
1099762338dSopenharmony_ci    }
1109762338dSopenharmony_ci    EXPECT_EQ(0, ret);
1119762338dSopenharmony_ci}
1129762338dSopenharmony_ci/**
1139762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetCpuFreq_0300
1149762338dSopenharmony_ci * @tc.name  testSetCpuFreq002
1159762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
1169762338dSopenharmony_ci */
1179762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq002, Function | MediumTest | Level2)
1189762338dSopenharmony_ci{
1199762338dSopenharmony_ci    int32_t cpuFreq = -1;
1209762338dSopenharmony_ci    int32_t ret = g_thermalInterface->SetCpuFreq(cpuFreq);
1219762338dSopenharmony_ci    EXPECT_NE(0, ret);
1229762338dSopenharmony_ci}
1239762338dSopenharmony_ci/**
1249762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetCpuFreq_0400
1259762338dSopenharmony_ci * @tc.name  testSetCpuFreq003
1269762338dSopenharmony_ci * @tc.desc  Test input param
1279762338dSopenharmony_ci */
1289762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq003, Function | MediumTest | Level1)
1299762338dSopenharmony_ci{
1309762338dSopenharmony_ci    int32_t cpuFreq = 0x7fffffff;
1319762338dSopenharmony_ci    int32_t ret = g_thermalInterface->SetCpuFreq(cpuFreq);
1329762338dSopenharmony_ci    EXPECT_EQ(0, ret);
1339762338dSopenharmony_ci}
1349762338dSopenharmony_ci/**
1359762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetCpuFreq_0500
1369762338dSopenharmony_ci * @tc.name  testSetCpuFreq004
1379762338dSopenharmony_ci * @tc.desc  Test input param
1389762338dSopenharmony_ci */
1399762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq004, Function | MediumTest | Level1)
1409762338dSopenharmony_ci{
1419762338dSopenharmony_ci    int32_t cpuFreq = 1024;
1429762338dSopenharmony_ci    int32_t ret = g_thermalInterface->SetCpuFreq(cpuFreq);
1439762338dSopenharmony_ci    EXPECT_EQ(0, ret);
1449762338dSopenharmony_ci}
1459762338dSopenharmony_ci/**
1469762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetCpuFreq_0600
1479762338dSopenharmony_ci * @tc.name  testSetCpuFreq005
1489762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
1499762338dSopenharmony_ci */
1509762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetCpuFreq005, Function | MediumTest | Level2)
1519762338dSopenharmony_ci{
1529762338dSopenharmony_ci    int32_t cpuFreq = 0;
1539762338dSopenharmony_ci    int32_t ret = g_thermalInterface->SetCpuFreq(cpuFreq);
1549762338dSopenharmony_ci    EXPECT_NE(0, ret);
1559762338dSopenharmony_ci}
1569762338dSopenharmony_ci/**
1579762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetGpuFreq_0200
1589762338dSopenharmony_ci * @tc.name  testSetGpuFreq001
1599762338dSopenharmony_ci * @tc.desc  Reliability of function(SetGpuFreq)
1609762338dSopenharmony_ci */
1619762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq001, Function | MediumTest | Level1)
1629762338dSopenharmony_ci{
1639762338dSopenharmony_ci    int32_t gpuFreq = 1994100;
1649762338dSopenharmony_ci    int32_t ret = 0;
1659762338dSopenharmony_ci    int i = 0;
1669762338dSopenharmony_ci    for (i = 0; i < 1000; i++) {
1679762338dSopenharmony_ci        ret |= g_thermalInterface->SetGpuFreq(gpuFreq);
1689762338dSopenharmony_ci    }
1699762338dSopenharmony_ci    EXPECT_EQ(0, ret);
1709762338dSopenharmony_ci}
1719762338dSopenharmony_ci/**
1729762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetGpuFreq_0300
1739762338dSopenharmony_ci * @tc.name  testSetGpuFreq002
1749762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
1759762338dSopenharmony_ci */
1769762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq002, Function | MediumTest | Level2)
1779762338dSopenharmony_ci{
1789762338dSopenharmony_ci    int32_t gpuFreq = -1;
1799762338dSopenharmony_ci    int32_t ret = g_thermalInterface->SetGpuFreq(gpuFreq);
1809762338dSopenharmony_ci    EXPECT_NE(0, ret);
1819762338dSopenharmony_ci}
1829762338dSopenharmony_ci/**
1839762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetGpuFreq_0400
1849762338dSopenharmony_ci * @tc.name  testSetGpuFreq003
1859762338dSopenharmony_ci * @tc.desc  Test input param
1869762338dSopenharmony_ci */
1879762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq003, Function | MediumTest | Level1)
1889762338dSopenharmony_ci{
1899762338dSopenharmony_ci    int32_t gpuFreq = 0x7fffffff;
1909762338dSopenharmony_ci    int32_t ret = g_thermalInterface->SetGpuFreq(gpuFreq);
1919762338dSopenharmony_ci    EXPECT_EQ(0, ret);
1929762338dSopenharmony_ci}
1939762338dSopenharmony_ci/**
1949762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetGpuFreq_0500
1959762338dSopenharmony_ci * @tc.name  testSetGpuFreq004
1969762338dSopenharmony_ci * @tc.desc  Test input param
1979762338dSopenharmony_ci */
1989762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq004, Function | MediumTest | Level1)
1999762338dSopenharmony_ci{
2009762338dSopenharmony_ci    int32_t gpuFreq = 1024;
2019762338dSopenharmony_ci    int32_t ret = g_thermalInterface->SetGpuFreq(gpuFreq);
2029762338dSopenharmony_ci    EXPECT_EQ(0, ret);
2039762338dSopenharmony_ci}
2049762338dSopenharmony_ci/**
2059762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetGpuFreq_0600
2069762338dSopenharmony_ci * @tc.name  testSetGpuFreq005
2079762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
2089762338dSopenharmony_ci */
2099762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetGpuFreq005, Function | MediumTest | Level2)
2109762338dSopenharmony_ci{
2119762338dSopenharmony_ci    int32_t gpuFreq = 0;
2129762338dSopenharmony_ci    int32_t ret = g_thermalInterface->SetGpuFreq(gpuFreq);
2139762338dSopenharmony_ci    EXPECT_NE(0, ret);
2149762338dSopenharmony_ci}
2159762338dSopenharmony_ci/**
2169762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetBatteryCurrent_0200
2179762338dSopenharmony_ci * @tc.name  testSetBatteryCurrent001
2189762338dSopenharmony_ci * @tc.desc  Reliability of function(SetBatteryCurrent)
2199762338dSopenharmony_ci */
2209762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent001, Function | MediumTest | Level1)
2219762338dSopenharmony_ci{
2229762338dSopenharmony_ci    int32_t ret = 0;
2239762338dSopenharmony_ci    int32_t batteryCurrent = 1000;
2249762338dSopenharmony_ci    int i = 0;
2259762338dSopenharmony_ci    for (i = 0; i < 1000; i++) {
2269762338dSopenharmony_ci        ret |= g_thermalInterface->SetBatteryCurrent(batteryCurrent);
2279762338dSopenharmony_ci    }
2289762338dSopenharmony_ci    EXPECT_EQ(0, ret);
2299762338dSopenharmony_ci}
2309762338dSopenharmony_ci/**
2319762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetBatteryCurrent_0300
2329762338dSopenharmony_ci * @tc.name  testSetBatteryCurrent002
2339762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
2349762338dSopenharmony_ci */
2359762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent002, Function | MediumTest | Level2)
2369762338dSopenharmony_ci{
2379762338dSopenharmony_ci    int32_t ret = 0;
2389762338dSopenharmony_ci    int32_t batteryCurrent = -1;
2399762338dSopenharmony_ci    ret = g_thermalInterface->SetBatteryCurrent(batteryCurrent);
2409762338dSopenharmony_ci    EXPECT_NE(0, ret);
2419762338dSopenharmony_ci}
2429762338dSopenharmony_ci/**
2439762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetBatteryCurrent_0400
2449762338dSopenharmony_ci * @tc.name  testSetBatteryCurrent003
2459762338dSopenharmony_ci * @tc.desc  Test input param
2469762338dSopenharmony_ci */
2479762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent003, Function | MediumTest | Level1)
2489762338dSopenharmony_ci{
2499762338dSopenharmony_ci    int32_t ret = 0;
2509762338dSopenharmony_ci    int32_t batteryCurrent = 0x7fffffff;
2519762338dSopenharmony_ci    ret = g_thermalInterface->SetBatteryCurrent(batteryCurrent);
2529762338dSopenharmony_ci    EXPECT_EQ(0, ret);
2539762338dSopenharmony_ci}
2549762338dSopenharmony_ci/**
2559762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetBatteryCurrent_0500
2569762338dSopenharmony_ci * @tc.name  testSetBatteryCurrent004
2579762338dSopenharmony_ci * @tc.desc  Test input param
2589762338dSopenharmony_ci */
2599762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent004, Function | MediumTest | Level1)
2609762338dSopenharmony_ci{
2619762338dSopenharmony_ci    int32_t ret = 0;
2629762338dSopenharmony_ci    int32_t batteryCurrent = 1024;
2639762338dSopenharmony_ci    ret = g_thermalInterface->SetBatteryCurrent(batteryCurrent);
2649762338dSopenharmony_ci    EXPECT_EQ(0, ret);
2659762338dSopenharmony_ci}
2669762338dSopenharmony_ci/**
2679762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_SetBatteryCurrent_0600
2689762338dSopenharmony_ci * @tc.name  testSetBatteryCurrent005
2699762338dSopenharmony_ci * @tc.desc  Test input param
2709762338dSopenharmony_ci */
2719762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testSetBatteryCurrent005, Function | MediumTest | Level2)
2729762338dSopenharmony_ci{
2739762338dSopenharmony_ci    int32_t ret = 0;
2749762338dSopenharmony_ci    int32_t batteryCurrent = 0;
2759762338dSopenharmony_ci    ret = g_thermalInterface->SetBatteryCurrent(batteryCurrent);
2769762338dSopenharmony_ci    EXPECT_NE(0, ret);
2779762338dSopenharmony_ci}
2789762338dSopenharmony_ci/**
2799762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_GetThermalZoneInfo_0200
2809762338dSopenharmony_ci * @tc.name  testGetThermalZoneInfo001
2819762338dSopenharmony_ci * @tc.desc  Reliability of function(GetThermalZoneInfo)
2829762338dSopenharmony_ci */
2839762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testGetThermalZoneInfo001, Function | MediumTest | Level1)
2849762338dSopenharmony_ci{
2859762338dSopenharmony_ci    HdfThermalCallbackInfo event;
2869762338dSopenharmony_ci    int i = 0;
2879762338dSopenharmony_ci    int32_t ret = 0;
2889762338dSopenharmony_ci    for (i = 0; i < 30; i++) {
2899762338dSopenharmony_ci        ret |= g_thermalInterface->GetThermalZoneInfo(event);
2909762338dSopenharmony_ci    }
2919762338dSopenharmony_ci    EXPECT_EQ(0, ret);
2929762338dSopenharmony_ci}
2939762338dSopenharmony_ci/**
2949762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_IsolateCpu_0200
2959762338dSopenharmony_ci * @tc.name  testIsolateCpu001
2969762338dSopenharmony_ci * @tc.desc  Reliability of function(IsolateCpu)
2979762338dSopenharmony_ci */
2989762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu001, Function | MediumTest | Level1)
2999762338dSopenharmony_ci{
3009762338dSopenharmony_ci#ifdef PRODUCT_SUPPORT
3019762338dSopenharmony_ci    int i = 0;
3029762338dSopenharmony_ci    int32_t isolateNum = 2;
3039762338dSopenharmony_ci    int32_t ret = 0;
3049762338dSopenharmony_ci    for (i = 0; i < 1000; i++) {
3059762338dSopenharmony_ci        ret |= g_thermalInterface->IsolateCpu(isolateNum);
3069762338dSopenharmony_ci    }
3079762338dSopenharmony_ci    EXPECT_EQ(0, ret);
3089762338dSopenharmony_ci#endif
3099762338dSopenharmony_ci}
3109762338dSopenharmony_ci/**
3119762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_IsolateCpu_0300
3129762338dSopenharmony_ci * @tc.name  testIsolateCpu002
3139762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
3149762338dSopenharmony_ci */
3159762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu002, Function | MediumTest | Level2)
3169762338dSopenharmony_ci{
3179762338dSopenharmony_ci    int32_t isolateNum = -1;
3189762338dSopenharmony_ci    int32_t ret = g_thermalInterface->IsolateCpu(isolateNum);
3199762338dSopenharmony_ci    EXPECT_NE(0, ret);
3209762338dSopenharmony_ci}
3219762338dSopenharmony_ci/**
3229762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_IsolateCpu_0400
3239762338dSopenharmony_ci * @tc.name  testIsolateCpu003
3249762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
3259762338dSopenharmony_ci */
3269762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu003, Function | MediumTest | Level2)
3279762338dSopenharmony_ci{
3289762338dSopenharmony_ci    int32_t isolateNum = 0;
3299762338dSopenharmony_ci    int32_t ret = g_thermalInterface->IsolateCpu(isolateNum);
3309762338dSopenharmony_ci    EXPECT_NE(0, ret);
3319762338dSopenharmony_ci}
3329762338dSopenharmony_ci/**
3339762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_IsolateCpu_0500
3349762338dSopenharmony_ci * @tc.name  testIsolateCpu004
3359762338dSopenharmony_ci * @tc.desc  Test input param
3369762338dSopenharmony_ci */
3379762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu004, Function | MediumTest | Level1)
3389762338dSopenharmony_ci{
3399762338dSopenharmony_ci#ifdef PRODUCT_SUPPORT
3409762338dSopenharmony_ci    int32_t isolateNum = 0x7fffffff;
3419762338dSopenharmony_ci    int32_t ret = g_thermalInterface->IsolateCpu(isolateNum);
3429762338dSopenharmony_ci    EXPECT_EQ(0, ret);
3439762338dSopenharmony_ci#endif
3449762338dSopenharmony_ci}
3459762338dSopenharmony_ci/**
3469762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_IsolateCpu_0600
3479762338dSopenharmony_ci * @tc.name  testIsolateCpu005
3489762338dSopenharmony_ci * @tc.desc  Test input param
3499762338dSopenharmony_ci */
3509762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testIsolateCpu005, Function | MediumTest | Level1)
3519762338dSopenharmony_ci{
3529762338dSopenharmony_ci#ifdef PRODUCT_SUPPORT
3539762338dSopenharmony_ci    int32_t isolateNum = 3;
3549762338dSopenharmony_ci    int32_t ret = g_thermalInterface->IsolateCpu(isolateNum);
3559762338dSopenharmony_ci    EXPECT_EQ(0, ret);
3569762338dSopenharmony_ci#endif
3579762338dSopenharmony_ci}
3589762338dSopenharmony_ci/**
3599762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_Register_0200
3609762338dSopenharmony_ci * @tc.name  testRegister001
3619762338dSopenharmony_ci * @tc.desc  Reliability of function(Register)
3629762338dSopenharmony_ci */
3639762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testRegister001, Function | MediumTest | Level1)
3649762338dSopenharmony_ci{
3659762338dSopenharmony_ci    int i = 0;
3669762338dSopenharmony_ci    int32_t ret = 0;
3679762338dSopenharmony_ci    for (i = 0; i < 1000; i++) {
3689762338dSopenharmony_ci        ret |= g_thermalInterface->Register(g_callback);
3699762338dSopenharmony_ci        g_thermalInterface->Unregister();
3709762338dSopenharmony_ci    }
3719762338dSopenharmony_ci    EXPECT_EQ(0, ret);
3729762338dSopenharmony_ci}
3739762338dSopenharmony_ci/**
3749762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_Register_0200
3759762338dSopenharmony_ci * @tc.name  testRegister002
3769762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
3779762338dSopenharmony_ci */
3789762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testRegister002, Function | MediumTest | Level2)
3799762338dSopenharmony_ci{
3809762338dSopenharmony_ci    int32_t ret;
3819762338dSopenharmony_ci    ret = g_thermalInterface->Register(nullptr);
3829762338dSopenharmony_ci    EXPECT_NE(0, ret);
3839762338dSopenharmony_ci}
3849762338dSopenharmony_ci/**
3859762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_Unregister_0200
3869762338dSopenharmony_ci * @tc.name  testUnregister001
3879762338dSopenharmony_ci * @tc.desc  Reliability of function(Unregister)
3889762338dSopenharmony_ci */
3899762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testUnregister001, Function | MediumTest | Level1)
3909762338dSopenharmony_ci{
3919762338dSopenharmony_ci    int i = 0;
3929762338dSopenharmony_ci    int32_t ret = 0;
3939762338dSopenharmony_ci    for (i = 0; i < 1000; i++) {
3949762338dSopenharmony_ci        g_thermalInterface->Register(g_callback);
3959762338dSopenharmony_ci        ret |= g_thermalInterface->Unregister();
3969762338dSopenharmony_ci    }
3979762338dSopenharmony_ci    EXPECT_EQ(0, ret);
3989762338dSopenharmony_ci}
3999762338dSopenharmony_ci/**
4009762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_Unregister_0300
4019762338dSopenharmony_ci * @tc.name  testUnregister002
4029762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
4039762338dSopenharmony_ci */
4049762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testUnregister002, Function | MediumTest | Level2)
4059762338dSopenharmony_ci{
4069762338dSopenharmony_ci    int32_t ret = g_thermalInterface->Unregister();
4079762338dSopenharmony_ci    EXPECT_NE(0, ret);
4089762338dSopenharmony_ci}
4099762338dSopenharmony_ci/**
4109762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_RegisterFanCallback_0200
4119762338dSopenharmony_ci * @tc.name  testRegisterFanCallback001
4129762338dSopenharmony_ci * @tc.desc  Reliability of function(RegisterFanCallback)
4139762338dSopenharmony_ci */
4149762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testRegisterFanCallback001, Function | MediumTest | Level1)
4159762338dSopenharmony_ci{
4169762338dSopenharmony_ci    int i = 0;
4179762338dSopenharmony_ci    int32_t ret = 0;
4189762338dSopenharmony_ci    for (i = 0; i < 1000; i++) {
4199762338dSopenharmony_ci        ret |= g_thermalInterface->RegisterFanCallback(g_fanCallback);
4209762338dSopenharmony_ci        g_thermalInterface->UnregisterFanCallback();
4219762338dSopenharmony_ci    }
4229762338dSopenharmony_ci    EXPECT_EQ(0, ret);
4239762338dSopenharmony_ci}
4249762338dSopenharmony_ci/**
4259762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_RegisterFanCallback_0300
4269762338dSopenharmony_ci * @tc.name  testRegisterFanCallback002
4279762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
4289762338dSopenharmony_ci */
4299762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testRegisterFanCallback002, Function | MediumTest | Level2)
4309762338dSopenharmony_ci{
4319762338dSopenharmony_ci    int32_t ret = g_thermalInterface->RegisterFanCallback(nullptr);
4329762338dSopenharmony_ci    EXPECT_NE(0, ret);
4339762338dSopenharmony_ci}
4349762338dSopenharmony_ci/**
4359762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_UnregisterFanCallback_0200
4369762338dSopenharmony_ci * @tc.name  testUnregisterFanCallback001
4379762338dSopenharmony_ci * @tc.desc  Test input param
4389762338dSopenharmony_ci */
4399762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testUnregisterFanCallback001, Function | MediumTest | Level1)
4409762338dSopenharmony_ci{
4419762338dSopenharmony_ci    int i = 0;
4429762338dSopenharmony_ci    int32_t ret = 0;
4439762338dSopenharmony_ci    for (i = 0; i < 1000; i++) {
4449762338dSopenharmony_ci        g_thermalInterface->RegisterFanCallback(g_fanCallback);
4459762338dSopenharmony_ci        ret |= g_thermalInterface->UnregisterFanCallback();
4469762338dSopenharmony_ci    }
4479762338dSopenharmony_ci    EXPECT_EQ(0, ret);
4489762338dSopenharmony_ci}
4499762338dSopenharmony_ci/**
4509762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_UnregisterFanCallback_0300
4519762338dSopenharmony_ci * @tc.name  testUnregisterFanCallback002
4529762338dSopenharmony_ci * @tc.desc  Test parameters with abnormal input
4539762338dSopenharmony_ci */
4549762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testUnregisterFanCallback002, Function | MediumTest | Level2)
4559762338dSopenharmony_ci{
4569762338dSopenharmony_ci    int32_t ret = g_thermalInterface->UnregisterFanCallback();
4579762338dSopenharmony_ci    EXPECT_NE(0, ret);
4589762338dSopenharmony_ci}
4599762338dSopenharmony_ci/**
4609762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_OnThermalDataEvent_0100
4619762338dSopenharmony_ci * @tc.name  testOnThermalDataEvent001
4629762338dSopenharmony_ci * @tc.desc  Test callback
4639762338dSopenharmony_ci */
4649762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testOnThermalDataEvent001, Function | MediumTest | Level1)
4659762338dSopenharmony_ci{
4669762338dSopenharmony_ci    int32_t ret = g_thermalInterface->Register(g_callback);
4679762338dSopenharmony_ci    EXPECT_EQ(0, ret);
4689762338dSopenharmony_ci    sleep(35);
4699762338dSopenharmony_ci    EXPECT_EQ(true, (g_onThermalDataEventCount != 0));
4709762338dSopenharmony_ci    g_thermalInterface->Unregister();
4719762338dSopenharmony_ci    g_onThermalDataEventCount = 0;
4729762338dSopenharmony_ci}
4739762338dSopenharmony_ci/**
4749762338dSopenharmony_ci * @tc.number  SUB_Powermgr_Thermal_OnThermalDataEvent_0200
4759762338dSopenharmony_ci * @tc.name  testOnThermalDataEvent002
4769762338dSopenharmony_ci * @tc.desc  Test callback
4779762338dSopenharmony_ci */
4789762338dSopenharmony_ciHWTEST_F(HdfThermalHdiTestAdditional, testOnThermalDataEvent002, Function | MediumTest | Level2)
4799762338dSopenharmony_ci{
4809762338dSopenharmony_ci    sleep(35);
4819762338dSopenharmony_ci    EXPECT_EQ(false, (g_onThermalDataEventCount != 0));
4829762338dSopenharmony_ci    g_onThermalDataEventCount = 0;
4839762338dSopenharmony_ci}
4849762338dSopenharmony_ci} // namespace
485