• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef THERMAL_MGR_INTERFACE_TEST_H
17 #define THERMAL_MGR_INTERFACE_TEST_H
18 
19 #include <gtest/gtest.h>
20 #include "ithermal_temp_callback.h"
21 #include "ithermal_level_callback.h"
22 #include "thermal_temp_callback_stub.h"
23 #include "thermal_level_callback_stub.h"
24 
25 namespace OHOS {
26 namespace PowerMgr {
27 constexpr int SLEEP_WAIT_TIME_S = 1;
28 constexpr int SLEEP_WAIT_TIME_LOOP_S = 3;
29 const uint32_t MAX_PATH = 256;
30 const uint32_t WAIT_TIME = 10;
31 std::string batteryCurrentPath = "/data/mitigation/charger/current";
32 std::string cpuFreqPath = "/data/mitigation/cpu/freq";
33 std::string batteryPath = "/data/sensor/battery/temp";
34 std::string shellPath = "/data/sensor/shell/temp";
35 std::string chargerPath = "/data/sensor/charger/temp";
36 std::string socPath = "/data/sensor/soc/temp";
37 std::string ambientPath = "/data/sensor/ambient/temp";
38 std::string cpuPath = "/data/sensor/cpu/temp";
39 std::string paPath = "/data/sensor/pa/temp";
40 std::string apPath = "/data/sensor/ap/temp";
41 
42 class ThermalMgrInterfaceTest : public testing::Test {
43 public:
44     static void SetUpTestCase(void);
45     static void TearDownTestCase(void);
46     void SetUp();
47     void TearDown();
48     static int32_t WriteFile(std::string path, std::string buf, size_t size);
49     static int32_t ReadFile(const char *path, char *buf, size_t size);
50     static int32_t ConvertInt(const std::string &value);
51     void InitData();
52 
53     class ThermalTempTest1Callback : public ThermalTempCallbackStub {
54     public:
ThermalTempTest1Callback()55         ThermalTempTest1Callback() {};
~ThermalTempTest1Callback()56         virtual ~ThermalTempTest1Callback() {};
57         virtual void OnThermalTempChanged(TempCallbackMap &tempCbMap) override;
58     };
59 
60     class ThermalTempTest2Callback : public ThermalTempCallbackStub {
61     public:
ThermalTempTest2Callback()62         ThermalTempTest2Callback() {};
~ThermalTempTest2Callback()63         virtual ~ThermalTempTest2Callback() {};
64         virtual void OnThermalTempChanged(TempCallbackMap &tempCbMap) override;
65     };
66 
67     class ThermalLevelTest1Callback : public ThermalLevelCallbackStub {
68     public:
ThermalLevelTest1Callback()69         ThermalLevelTest1Callback() {};
~ThermalLevelTest1Callback()70         virtual ~ThermalLevelTest1Callback() {};
71         virtual void GetThermalLevel(ThermalLevel level) override;
72     };
73 
74     class ThermalLevelTest2Callback : public ThermalLevelCallbackStub {
75     public:
ThermalLevelTest2Callback()76         ThermalLevelTest2Callback() {};
~ThermalLevelTest2Callback()77         virtual ~ThermalLevelTest2Callback() {};
78         virtual void GetThermalLevel(ThermalLevel level) override;
79     };
80 
81     class ThermalLevelTest3Callback : public ThermalLevelCallbackStub {
82     public:
ThermalLevelTest3Callback()83         ThermalLevelTest3Callback() {};
~ThermalLevelTest3Callback()84         virtual ~ThermalLevelTest3Callback() {};
85         virtual void GetThermalLevel(ThermalLevel level) override;
86     };
87 };
88 } // namespace PowerMgr
89 } // namespace OHOS
90 #endif // THERMAL_MGR_INTERFACE_TEST_H
91