• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_ACTION_HUB_TEST_H
17 #define THERMAL_ACTION_HUB_TEST_H
18 
19 #include "ithermal_action_callback.h"
20 #include "thermal_action_callback_stub.h"
21 #include <gtest/gtest.h>
22 
23 namespace OHOS {
24 namespace PowerMgr {
25 const uint32_t MAX_PATH = 256;
26 const std::string BATTERY_PATH = "/data/service/el0/thermal/sensor/battery/temp";
27 const std::string SOC_PATH = "/data/service/el0/thermal/sensor/soc/temp";
28 
29 class ThermalActionHubTest : public testing::Test {
30 public:
31     static void SetUpTestCase();
32     static void TearDownTestCase();
33     void SetUp();
34     void TearDown();
35     static int32_t WriteFile(std::string path, std::string buf, size_t size);
36     static int32_t ReadFile(const char* path, char* buf, size_t size);
37     void InitData();
38 
39     class ThermalActionTest1Callback : public ThermalActionCallbackStub {
40     public:
ThermalActionTest1Callback()41         ThermalActionTest1Callback() {};
~ThermalActionTest1Callback()42         virtual ~ThermalActionTest1Callback() {};
43         virtual bool OnThermalActionChanged(ActionCallbackMap& actionCbMap) override;
44     };
45 
46     class ThermalActionTest2Callback : public ThermalActionCallbackStub {
47     public:
ThermalActionTest2Callback()48         ThermalActionTest2Callback() {};
~ThermalActionTest2Callback()49         virtual ~ThermalActionTest2Callback() {};
50         virtual bool OnThermalActionChanged(ActionCallbackMap& actionCbMap) override;
51     };
52 
53     class ThermalActionTest3Callback : public ThermalActionCallbackStub {
54     public:
ThermalActionTest3Callback()55         ThermalActionTest3Callback() {};
~ThermalActionTest3Callback()56         virtual ~ThermalActionTest3Callback() {};
57         virtual bool OnThermalActionChanged(ActionCallbackMap& actionCbMap) override;
58     };
59 
60     class ThermalActionTest4Callback : public ThermalActionCallbackStub {
61     public:
ThermalActionTest4Callback()62         ThermalActionTest4Callback() {};
~ThermalActionTest4Callback()63         virtual ~ThermalActionTest4Callback() {};
64         virtual bool OnThermalActionChanged(ActionCallbackMap& actionCbMap) override;
65     };
66 
67     class ThermalActionTest5Callback : public ThermalActionCallbackStub {
68     public:
ThermalActionTest5Callback()69         ThermalActionTest5Callback() {};
~ThermalActionTest5Callback()70         virtual ~ThermalActionTest5Callback() {};
71         virtual bool OnThermalActionChanged(ActionCallbackMap& actionCbMap) override;
72     };
73 
74     class ThermalActionTest6Callback : public ThermalActionCallbackStub {
75     public:
ThermalActionTest6Callback()76         ThermalActionTest6Callback() {};
~ThermalActionTest6Callback()77         virtual ~ThermalActionTest6Callback() {};
78         virtual bool OnThermalActionChanged(ActionCallbackMap& actionCbMap) override;
79     };
80 };
81 } // namespace PowerMgr
82 } // namespace OHOS
83 #endif // THERMAL_ACTION_HUB_TEST_H
84