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_REPORT_TEST 17 #define THERMAL_ACTION_REPORT_TEST 18 19 #include <gtest/gtest.h> 20 #include <string> 21 22 #include "thermal_policy.h" 23 24 namespace OHOS { 25 namespace PowerMgr { 26 class ThermalActionReportTest : public testing::Test { 27 public: 28 static void SetUpTestCase(); 29 static void TearDownTestCase(); 30 void SetUp(); 31 void TearDown(); 32 static void ParserThermalSrvConfigFile(); 33 static int32_t WriteFile(const std::string& path, const std::string& buf, size_t size); 34 static int32_t ReadFile(const char* path, char* buf, size_t size); 35 static int32_t ReadSysfsFile(const char* path, char* buf, size_t size); 36 static int32_t ConvertInt(const std::string& value); 37 static void Trim(char* str); 38 static int32_t InitNode(); 39 static int32_t SetCondition(int32_t value, const std::string& scene); 40 static void SetScene(const std::string& scene); 41 static int32_t GetThermalLevel(int32_t expectValue); 42 static std::string GetActionValue(const std::string& actionName, uint32_t level); 43 static std::string ActionDecision(const std::string& actionName, std::vector<PolicyAction>& vAction); 44 static std::string ActionValueDecision(const std::string& actionName, std::vector<PolicyAction>& vAction); 45 static std::string LcdValueDecision(const std::string& actionName, std::vector<PolicyAction>& vAction); 46 static bool StateDecision(std::map<std::string, std::string>& actionPropMap); 47 static std::string GetScreenState(); 48 static std::string GetChargeState(); 49 static void GetStateMap(std::map<std::string, std::string>& stateMap); 50 static void ThermalActionTriggered(const std::string& actionName, int32_t level, const std::string& dumpInfo); 51 static void ReturnWithLog(bool conditon, int32_t ret, int32_t level, const std::string& info); 52 }; 53 } // namespace PowerMgr 54 } // namespace OHOS 55 #endif // THERMAL_ACTION_REPORT_TEST